Commit f13bce6f authored by reedmi's avatar reedmi

删除多余的project相关

parent 4365dd18
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
.settings .settings
/filters/dev /filters/dev
upload/ upload/
.springBeans
...@@ -78,7 +78,7 @@ public class BaseController extends HandlerInterceptorAdapter { ...@@ -78,7 +78,7 @@ public class BaseController extends HandlerInterceptorAdapter {
} }
public User getCurrentUser() { public User getCurrentUser() {
return (User)session().getAttribute("user"); return (User) session().getAttribute("user");
} }
// 一般用于create、update、delete的返回值 // 一般用于create、update、delete的返回值
......
...@@ -8,12 +8,12 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -8,12 +8,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
public class MainController { public class MainController {
@RequestMapping("index") @RequestMapping("index")
public String index(){ public String index() {
return "index"; return "index";
} }
@RequestMapping(value="main",method=RequestMethod.GET) @RequestMapping(value = "main", method = RequestMethod.GET)
public String main(){ public String main() {
return "main"; return "main";
} }
} }
...@@ -15,9 +15,9 @@ import com.originspark.drp.util.json.PasswordJson; ...@@ -15,9 +15,9 @@ import com.originspark.drp.util.json.PasswordJson;
@RequestMapping("profile") @RequestMapping("profile")
public class ProfileController extends BaseController { public class ProfileController extends BaseController {
@RequestMapping(value="/password/update",method = RequestMethod.GET) @RequestMapping(value = "/password/update", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public String updatePassword(@RequestParam String data){ public String updatePassword(@RequestParam String data) {
System.out.println(request().getSession()); System.out.println(request().getSession());
...@@ -25,7 +25,7 @@ public class ProfileController extends BaseController { ...@@ -25,7 +25,7 @@ public class ProfileController extends BaseController {
try { try {
PasswordJson json = mapper.readValue(data, PasswordJson.class); PasswordJson json = mapper.readValue(data, PasswordJson.class);
if(!json.getNewpwd().equals(json.getNewpwdagain())){ if (!json.getNewpwd().equals(json.getNewpwdagain())) {
return failure("修改失败,密码两次输入不一致"); return failure("修改失败,密码两次输入不一致");
} }
...@@ -33,7 +33,7 @@ public class ProfileController extends BaseController { ...@@ -33,7 +33,7 @@ public class ProfileController extends BaseController {
Blowfish bf = new Blowfish(); Blowfish bf = new Blowfish();
String pwd = bf.decryptString(user.getPassword()); String pwd = bf.decryptString(user.getPassword());
if(!json.getPwd().equals(pwd)){ if (!json.getPwd().equals(pwd)) {
return failure("修改失败,请输入正确的原始密码"); return failure("修改失败,请输入正确的原始密码");
} }
......
...@@ -26,14 +26,14 @@ import com.originspark.drp.util.json.JsonUtils; ...@@ -26,14 +26,14 @@ import com.originspark.drp.util.json.JsonUtils;
@RequestMapping("users") @RequestMapping("users")
public class UserController extends BaseController { public class UserController extends BaseController {
@RequestMapping(value="/{type}", method = RequestMethod.POST) @RequestMapping(value = "/{type}", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public String create(@PathVariable String type, @RequestBody User user) { public String create(@PathVariable String type, @RequestBody User user) {
if(type == null || "".equals(type)) { if (type == null || "".equals(type)) {
return ok("参数错误"); return ok("参数错误");
} }
User currentUser = getCurrentUser(); User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) { if (currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足"); return ok("权限不足");
} }
user.setType(UserType.valueOf(type.toUpperCase())); user.setType(UserType.valueOf(type.toUpperCase()));
...@@ -45,11 +45,11 @@ public class UserController extends BaseController { ...@@ -45,11 +45,11 @@ public class UserController extends BaseController {
@RequestMapping(value = "/{type}/{id}", method = RequestMethod.DELETE) @RequestMapping(value = "/{type}/{id}", method = RequestMethod.DELETE)
@ResponseBody @ResponseBody
public String delete(@PathVariable String type, @PathVariable Long id) { public String delete(@PathVariable String type, @PathVariable Long id) {
if(type == null || "".equals(type) || id == null || id < 1) { if (type == null || "".equals(type) || id == null || id < 1) {
return ok("参数错误"); return ok("参数错误");
} }
User currentUser = getCurrentUser(); User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) { if (currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足"); return ok("权限不足");
} }
User leader = userService.findById(User.class, id); User leader = userService.findById(User.class, id);
...@@ -58,28 +58,28 @@ public class UserController extends BaseController { ...@@ -58,28 +58,28 @@ public class UserController extends BaseController {
return ok("注销成功"); return ok("注销成功");
} }
@RequestMapping(value= "/{type}/deleteBatch",method = RequestMethod.GET) @RequestMapping(value = "/{type}/deleteBatch", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public String deleteBatch(@PathVariable String type, HttpServletRequest request){ public String deleteBatch(@PathVariable String type, HttpServletRequest request) {
if(type == null || "".equals(type)) { if (type == null || "".equals(type)) {
return ok("参数错误"); return ok("参数错误");
} }
User currentUser = getCurrentUser(); User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) { if (currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足"); return ok("权限不足");
} }
String data = request.getParameter("data"); String data = request.getParameter("data");
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
IdsJson json=null; IdsJson json = null;
try { try {
json = mapper.readValue(data, IdsJson.class); json = mapper.readValue(data, IdsJson.class);
} catch (Exception e) { } catch (Exception e) {
return failure("提交数据有误"); return failure("提交数据有误");
} }
if(json == null){ if (json == null) {
return failure("没有需要审核的数据"); return failure("没有需要审核的数据");
} }
for(long id:json.getIds()){ for (long id : json.getIds()) {
User leader = userService.findById(User.class, id); User leader = userService.findById(User.class, id);
leader.setStatus(Status.DESTORYED); leader.setStatus(Status.DESTORYED);
userService.update(leader); userService.update(leader);
...@@ -90,11 +90,11 @@ public class UserController extends BaseController { ...@@ -90,11 +90,11 @@ public class UserController extends BaseController {
@RequestMapping(value = "/{type}/{id}", method = RequestMethod.PUT) @RequestMapping(value = "/{type}/{id}", method = RequestMethod.PUT)
@ResponseBody @ResponseBody
public String update(@PathVariable String type, @PathVariable Long id, @RequestBody User user) { public String update(@PathVariable String type, @PathVariable Long id, @RequestBody User user) {
if(type == null || "".equals(type) || id == null || id < 1) { if (type == null || "".equals(type) || id == null || id < 1) {
return ok("参数错误"); return ok("参数错误");
} }
User currentUser = getCurrentUser(); User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) { if (currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足"); return ok("权限不足");
} }
User existingLeader = userService.findById(User.class, id); User existingLeader = userService.findById(User.class, id);
...@@ -114,9 +114,9 @@ public class UserController extends BaseController { ...@@ -114,9 +114,9 @@ public class UserController extends BaseController {
return ok("更新成功"); return ok("更新成功");
} }
@RequestMapping(value="/{type}", method = RequestMethod.GET) @RequestMapping(value = "/{type}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public String list(@PathVariable String type, @RequestParam int start, @RequestParam int limit,@RequestParam(required = false) Object filter) { public String list(@PathVariable String type, @RequestParam int start, @RequestParam int limit, @RequestParam(required = false) Object filter) {
List<FilterRequest> filters = new ArrayList<FilterRequest>(); List<FilterRequest> filters = new ArrayList<FilterRequest>();
filters.add(new FilterRequest("type", type.toUpperCase())); filters.add(new FilterRequest("type", type.toUpperCase()));
...@@ -125,7 +125,7 @@ public class UserController extends BaseController { ...@@ -125,7 +125,7 @@ public class UserController extends BaseController {
filters.addAll(JsonUtils.getListFromJsonArray(filter)); filters.addAll(JsonUtils.getListFromJsonArray(filter));
} }
List<User> data = userService.pagedDataSet(start, limit,filters); List<User> data = userService.pagedDataSet(start, limit, filters);
Long count = userService.pagedDataCount(filters); Long count = userService.pagedDataCount(filters);
return ok(data, count); return ok(data, count);
......
package com.originspark.drp.dao; package com.originspark.drp.dao;
public interface BaseDAO<T> { public interface BaseDAO<T> {
T findById(Class<T> c,Long id); T findById(Class<T> c, Long id);
T getReferance(Class<T> c,Long id);
T getReferance(Class<T> c, Long id);
T save(T entity); T save(T entity);
T update(T entity); T update(T entity);
void delete(T entity); void delete(T entity);
} }
...@@ -5,7 +5,7 @@ import javax.persistence.PersistenceContext; ...@@ -5,7 +5,7 @@ import javax.persistence.PersistenceContext;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Transactional @Transactional
public abstract class BaseDAOSupport<T> implements BaseDAO<T>{ public abstract class BaseDAOSupport<T> implements BaseDAO<T> {
@PersistenceContext @PersistenceContext
protected EntityManager em; protected EntityManager em;
...@@ -14,8 +14,8 @@ public abstract class BaseDAOSupport<T> implements BaseDAO<T>{ ...@@ -14,8 +14,8 @@ public abstract class BaseDAOSupport<T> implements BaseDAO<T>{
em.remove(entity); em.remove(entity);
} }
@Transactional(readOnly=true) @Transactional(readOnly = true)
public T findById(Class<T> c,Long id) { public T findById(Class<T> c, Long id) {
return em.find(c, id); return em.find(c, id);
} }
...@@ -28,8 +28,8 @@ public abstract class BaseDAOSupport<T> implements BaseDAO<T>{ ...@@ -28,8 +28,8 @@ public abstract class BaseDAOSupport<T> implements BaseDAO<T>{
return em.merge(entity); return em.merge(entity);
} }
@Transactional(readOnly=true) @Transactional(readOnly = true)
public T getReferance(Class<T> c,Long id){ public T getReferance(Class<T> c, Long id) {
return em.getReference(c, id); return em.getReference(c, id);
} }
......
...@@ -23,25 +23,25 @@ public abstract class AbstractModel { ...@@ -23,25 +23,25 @@ public abstract class AbstractModel {
/** /**
* 维护信息:记录创建日期 * 维护信息:记录创建日期
*/ */
@Column(name="createdOn", nullable=false) @Column(name = "createdOn", nullable = false)
private Date createdOn; private Date createdOn;
/** /**
* 维护信息:记录创建者 * 维护信息:记录创建者
*/ */
@Column(name="createdBy",length=10) @Column(name = "createdBy", length = 10)
private String createdBy; private String createdBy;
/** /**
* 维护信息:记录更新日期 * 维护信息:记录更新日期
*/ */
@Column(name="updatedOn", nullable=false) @Column(name = "updatedOn", nullable = false)
private Date updatedOn; private Date updatedOn;
/** /**
* 维护信息:记录更新者 * 维护信息:记录更新者
*/ */
@Column(name="updatedBy",length=10) @Column(name = "updatedBy", length = 10)
private String updatedBy; private String updatedBy;
/** /**
...@@ -105,12 +105,12 @@ public abstract class AbstractModel { ...@@ -105,12 +105,12 @@ public abstract class AbstractModel {
} }
@PreUpdate @PreUpdate
private void preUpdate(){ private void preUpdate() {
updatedOn = new Date(); updatedOn = new Date();
} }
@Override @Override
public String toString() { public String toString() {
return "id="+id+", updateOn="+updatedOn; return "id=" + id + ", updateOn=" + updatedOn;
} }
} }
...@@ -11,7 +11,7 @@ import com.originspark.drp.util.enums.Gender; ...@@ -11,7 +11,7 @@ import com.originspark.drp.util.enums.Gender;
import com.originspark.drp.util.enums.UserType; import com.originspark.drp.util.enums.UserType;
@Entity @Entity
@Table(name="users") @Table(name = "users")
public class User extends AbstractModel { public class User extends AbstractModel {
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
......
package com.originspark.drp.processor; package com.originspark.drp.processor;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -12,7 +13,7 @@ public class UTF8StringBeanPostProcessor implements BeanPostProcessor { ...@@ -12,7 +13,7 @@ public class UTF8StringBeanPostProcessor implements BeanPostProcessor {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException { throws BeansException {
if(bean instanceof StringHttpMessageConverter){ if (bean instanceof StringHttpMessageConverter) {
MediaType mediaType = new MediaType("text", "plain", Charset.forName("UTF-8")); MediaType mediaType = new MediaType("text", "plain", Charset.forName("UTF-8"));
List<MediaType> types = new ArrayList<MediaType>(); List<MediaType> types = new ArrayList<MediaType>();
types.add(mediaType); types.add(mediaType);
......
...@@ -18,7 +18,8 @@ import java.util.*; ...@@ -18,7 +18,8 @@ import java.util.*;
import java.security.*; import java.security.*;
/** /**
* A class that provides easy Blowfish encryption.<p> * A class that provides easy Blowfish encryption.
* <p>
* *
* @author Markus Hahn <markus_hahn@gmx.net> * @author Markus Hahn <markus_hahn@gmx.net>
*/ */
...@@ -37,12 +38,11 @@ public class Blowfish { ...@@ -37,12 +38,11 @@ public class Blowfish {
// hash down the password to a 160bit key // hash down the password to a 160bit key
MessageDigest digest = null; MessageDigest digest = null;
try { try {
String password="fc4e6e4090e9edfe4dcff438d095954d"; String password = "fc4e6e4090e9edfe4dcff438d095954d";
digest = MessageDigest.getInstance("SHA1"); digest = MessageDigest.getInstance("SHA1");
digest.update(password.getBytes()); digest.update(password.getBytes());
} } catch (Exception e) {
catch (Exception e) { // Log.error(e);
// Log.error(e);
e.printStackTrace(); e.printStackTrace();
} }
...@@ -78,7 +78,7 @@ public class Blowfish { ...@@ -78,7 +78,7 @@ public class Blowfish {
{ {
// allocate the buffer (align to the next 8 byte border plus padding) // allocate the buffer (align to the next 8 byte border plus padding)
int nStrLen = sPlainText.length(); int nStrLen = sPlainText.length();
byte[] buf = new byte [((nStrLen << 1) & 0xfffffff8) + 8]; byte[] buf = new byte[((nStrLen << 1) & 0xfffffff8) + 8];
// copy all bytes of the string into the buffer (use network byte order) // copy all bytes of the string into the buffer (use network byte order)
int nI; int nI;
...@@ -87,11 +87,11 @@ public class Blowfish { ...@@ -87,11 +87,11 @@ public class Blowfish {
{ {
char cActChar = sPlainText.charAt(nI); char cActChar = sPlainText.charAt(nI);
buf[nPos++] = (byte) ((cActChar >> 8) & 0x0ff); buf[nPos++] = (byte) ((cActChar >> 8) & 0x0ff);
buf[nPos++] = (byte) (cActChar & 0x0ff) ; buf[nPos++] = (byte) (cActChar & 0x0ff);
} }
// pad the rest with the PKCS5 scheme // pad the rest with the PKCS5 scheme
byte bPadVal = (byte)(buf.length - (nStrLen << 1)); byte bPadVal = (byte) (buf.length - (nStrLen << 1));
while (nPos < buf.length) while (nPos < buf.length)
{ {
buf[nPos++] = bPadVal; buf[nPos++] = bPadVal;
...@@ -116,6 +116,7 @@ public class Blowfish { ...@@ -116,6 +116,7 @@ public class Blowfish {
/** /**
* decrypts a hexbin string (handling is case sensitive) * decrypts a hexbin string (handling is case sensitive)
*
* @param sCipherText hexbin string to decrypt * @param sCipherText hexbin string to decrypt
* @return decrypted string (null equals an error) * @return decrypted string (null equals an error)
*/ */
...@@ -168,7 +169,7 @@ public class Blowfish { ...@@ -168,7 +169,7 @@ public class Blowfish {
m_bfish.decrypt(buf); m_bfish.decrypt(buf);
// get the last padding byte // get the last padding byte
int nPadByte = (int)buf[buf.length - 1] & 0x0ff; int nPadByte = (int) buf[buf.length - 1] & 0x0ff;
// ( try to get all information if the padding doesn't seem to be correct) // ( try to get all information if the padding doesn't seem to be correct)
if ((nPadByte > 8) || (nPadByte < 0)) if ((nPadByte > 8) || (nPadByte < 0))
...@@ -199,6 +200,7 @@ public class Blowfish { ...@@ -199,6 +200,7 @@ public class Blowfish {
/** /**
* implementation of the Blowfish encryption algorithm in ECB mode * implementation of the Blowfish encryption algorithm in ECB mode
*
* @author Markus Hahn <markus_hahn@gmx.net> * @author Markus Hahn <markus_hahn@gmx.net>
* @version Feburary 14, 2001 * @version Feburary 14, 2001
*/ */
...@@ -225,6 +227,7 @@ public class Blowfish { ...@@ -225,6 +227,7 @@ public class Blowfish {
/** /**
* default constructor * default constructor
*
* @param bfkey key material, up to MAXKEYLENGTH bytes * @param bfkey key material, up to MAXKEYLENGTH bytes
*/ */
public BlowfishECB(byte[] bfkey) public BlowfishECB(byte[] bfkey)
...@@ -283,31 +286,31 @@ public class Blowfish { ...@@ -283,31 +286,31 @@ public class Blowfish {
{ {
lZero = encryptBlock(lZero); lZero = encryptBlock(lZero);
m_pbox[nI] = (int) (lZero >>> 32); m_pbox[nI] = (int) (lZero >>> 32);
m_pbox[nI+1] = (int) (lZero & 0x0ffffffffL); m_pbox[nI + 1] = (int) (lZero & 0x0ffffffffL);
} }
for (nI = 0; nI < SBOX_ENTRIES; nI += 2) for (nI = 0; nI < SBOX_ENTRIES; nI += 2)
{ {
lZero = encryptBlock(lZero); lZero = encryptBlock(lZero);
m_sbox1[nI] = (int) (lZero >>> 32); m_sbox1[nI] = (int) (lZero >>> 32);
m_sbox1[nI+1] = (int) (lZero & 0x0ffffffffL); m_sbox1[nI + 1] = (int) (lZero & 0x0ffffffffL);
} }
for (nI = 0; nI < SBOX_ENTRIES; nI += 2) for (nI = 0; nI < SBOX_ENTRIES; nI += 2)
{ {
lZero = encryptBlock(lZero); lZero = encryptBlock(lZero);
m_sbox2[nI] = (int) (lZero >>> 32); m_sbox2[nI] = (int) (lZero >>> 32);
m_sbox2[nI+1] = (int) (lZero & 0x0ffffffffL); m_sbox2[nI + 1] = (int) (lZero & 0x0ffffffffL);
} }
for (nI = 0; nI < SBOX_ENTRIES; nI += 2) for (nI = 0; nI < SBOX_ENTRIES; nI += 2)
{ {
lZero = encryptBlock(lZero); lZero = encryptBlock(lZero);
m_sbox3[nI] = (int) (lZero >>> 32); m_sbox3[nI] = (int) (lZero >>> 32);
m_sbox3[nI+1] = (int) (lZero & 0x0ffffffffL); m_sbox3[nI + 1] = (int) (lZero & 0x0ffffffffL);
} }
for (nI = 0; nI < SBOX_ENTRIES; nI += 2) for (nI = 0; nI < SBOX_ENTRIES; nI += 2)
{ {
lZero = encryptBlock(lZero); lZero = encryptBlock(lZero);
m_sbox4[nI] = (int) (lZero >>> 32); m_sbox4[nI] = (int) (lZero >>> 32);
m_sbox4[nI+1] = (int) (lZero & 0x0ffffffffL); m_sbox4[nI + 1] = (int) (lZero & 0x0ffffffffL);
} }
} }
...@@ -331,23 +334,34 @@ public class Blowfish { ...@@ -331,23 +334,34 @@ public class Blowfish {
/** /**
* selftest routine, to check e.g. for a valid class file transmission * selftest routine, to check e.g. for a valid class file transmission
*
* @return true: selftest passed / false: selftest failed * @return true: selftest passed / false: selftest failed
*/ */
public static boolean selfTest() public static boolean selfTest()
{ {
// test vector #1 (checking for the "signed bug") // test vector #1 (checking for the "signed bug")
byte[] testKey1 = { (byte) 0x1c, (byte) 0x58, (byte) 0x7f, (byte) 0x1c, byte[] testKey1 = {
(byte) 0x13, (byte) 0x92, (byte) 0x4f, (byte) 0xef }; (byte) 0x1c, (byte) 0x58, (byte) 0x7f, (byte) 0x1c,
int[] tv_p1 = { 0x30553228, 0x6d6f295a }; (byte) 0x13, (byte) 0x92, (byte) 0x4f, (byte) 0xef
int[] tv_c1 = { 0x55cb3774, 0xd13ef201 }; };
int[] tv_p1 = {
0x30553228, 0x6d6f295a
};
int[] tv_c1 = {
0x55cb3774, 0xd13ef201
};
int[] tv_t1 = new int[2]; int[] tv_t1 = new int[2];
// test vector #2 (offical vector by Bruce Schneier) // test vector #2 (offical vector by Bruce Schneier)
String sTestKey2 = "Who is John Galt?"; String sTestKey2 = "Who is John Galt?";
byte[] testKey2 = sTestKey2.getBytes(); byte[] testKey2 = sTestKey2.getBytes();
int[] tv_p2 = { 0xfedcba98, 0x76543210 }; int[] tv_p2 = {
int[] tv_c2 = { 0xcc91732b, 0x8022f684 }; 0xfedcba98, 0x76543210
};
int[] tv_c2 = {
0xcc91732b, 0x8022f684
};
int[] tv_t2 = new int[2]; int[] tv_t2 = new int[2];
...@@ -474,7 +488,7 @@ public class Blowfish { ...@@ -474,7 +488,7 @@ public class Blowfish {
public void encrypt(byte[] inbuffer, byte[] outbuffer) { public void encrypt(byte[] inbuffer, byte[] outbuffer) {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = byteArrayToLong(inbuffer, nI); lTemp = byteArrayToLong(inbuffer, nI);
...@@ -485,13 +499,14 @@ public class Blowfish { ...@@ -485,13 +499,14 @@ public class Blowfish {
/** /**
* encrypts a byte buffer (should be aligned to an 8 byte border) to itself * encrypts a byte buffer (should be aligned to an 8 byte border) to itself
*
* @param buffer buffer to encrypt * @param buffer buffer to encrypt
*/ */
public void encrypt(byte[] buffer) public void encrypt(byte[] buffer)
{ {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = byteArrayToLong(buffer, nI); lTemp = byteArrayToLong(buffer, nI);
...@@ -504,13 +519,14 @@ public class Blowfish { ...@@ -504,13 +519,14 @@ public class Blowfish {
* encrypts an integer buffer (should be aligned to an * encrypts an integer buffer (should be aligned to an
* two integer border) to another int buffer (of the * two integer border) to another int buffer (of the
* same size or bigger) * same size or bigger)
*
* @param inbuffer buffer with plaintext data * @param inbuffer buffer with plaintext data
* @param outbuffer buffer to get the ciphertext data * @param outbuffer buffer to get the ciphertext data
*/ */
public void encrypt(int[] inbuffer, int[] outbuffer) { public void encrypt(int[] inbuffer, int[] outbuffer) {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = intArrayToLong(inbuffer, nI); lTemp = intArrayToLong(inbuffer, nI);
...@@ -522,12 +538,13 @@ public class Blowfish { ...@@ -522,12 +538,13 @@ public class Blowfish {
/** /**
* encrypts an int buffer (should be aligned to a * encrypts an int buffer (should be aligned to a
* two integer border) * two integer border)
*
* @param buffer buffer to encrypt * @param buffer buffer to encrypt
*/ */
public void encrypt(int[] buffer) { public void encrypt(int[] buffer) {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = intArrayToLong(buffer, nI); lTemp = intArrayToLong(buffer, nI);
...@@ -538,6 +555,7 @@ public class Blowfish { ...@@ -538,6 +555,7 @@ public class Blowfish {
/** /**
* encrypts a long buffer to another long buffer (of the same size or bigger) * encrypts a long buffer to another long buffer (of the same size or bigger)
*
* @param inbuffer buffer with plaintext data * @param inbuffer buffer with plaintext data
* @param outbuffer buffer to get the ciphertext data * @param outbuffer buffer to get the ciphertext data
*/ */
...@@ -551,6 +569,7 @@ public class Blowfish { ...@@ -551,6 +569,7 @@ public class Blowfish {
/** /**
* encrypts a long buffer to itself * encrypts a long buffer to itself
*
* @param buffer buffer to encrypt * @param buffer buffer to encrypt
*/ */
public void encrypt(long[] buffer) { public void encrypt(long[] buffer) {
...@@ -564,6 +583,7 @@ public class Blowfish { ...@@ -564,6 +583,7 @@ public class Blowfish {
/** /**
* decrypts a byte buffer (should be aligned to an 8 byte border) * decrypts a byte buffer (should be aligned to an 8 byte border)
* to another byte buffer (of the same size or bigger) * to another byte buffer (of the same size or bigger)
*
* @param inbuffer buffer with ciphertext data * @param inbuffer buffer with ciphertext data
* @param outbuffer buffer to get the plaintext data * @param outbuffer buffer to get the plaintext data
*/ */
...@@ -572,7 +592,7 @@ public class Blowfish { ...@@ -572,7 +592,7 @@ public class Blowfish {
{ {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// decrypt a temporary 64bit block // decrypt a temporary 64bit block
lTemp = byteArrayToLong(inbuffer, nI); lTemp = byteArrayToLong(inbuffer, nI);
...@@ -583,13 +603,14 @@ public class Blowfish { ...@@ -583,13 +603,14 @@ public class Blowfish {
/** /**
* decrypts a byte buffer (should be aligned to an 8 byte border) to itself * decrypts a byte buffer (should be aligned to an 8 byte border) to itself
*
* @param buffer buffer to decrypt * @param buffer buffer to decrypt
*/ */
public void decrypt(byte[] buffer) public void decrypt(byte[] buffer)
{ {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// decrypt over a temporary 64bit block // decrypt over a temporary 64bit block
lTemp = byteArrayToLong(buffer, nI); lTemp = byteArrayToLong(buffer, nI);
...@@ -601,6 +622,7 @@ public class Blowfish { ...@@ -601,6 +622,7 @@ public class Blowfish {
/** /**
* decrypts an integer buffer (should be aligned to an * decrypts an integer buffer (should be aligned to an
* two integer border) to another int buffer (of the same size or bigger) * two integer border) to another int buffer (of the same size or bigger)
*
* @param inbuffer buffer with ciphertext data * @param inbuffer buffer with ciphertext data
* @param outbuffer buffer to get the plaintext data * @param outbuffer buffer to get the plaintext data
*/ */
...@@ -609,7 +631,7 @@ public class Blowfish { ...@@ -609,7 +631,7 @@ public class Blowfish {
{ {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// decrypt a temporary 64bit block // decrypt a temporary 64bit block
lTemp = intArrayToLong(inbuffer, nI); lTemp = intArrayToLong(inbuffer, nI);
...@@ -621,13 +643,14 @@ public class Blowfish { ...@@ -621,13 +643,14 @@ public class Blowfish {
/** /**
* decrypts an int buffer (should be aligned to an * decrypts an int buffer (should be aligned to an
* two integer border) * two integer border)
*
* @param buffer buffer to decrypt * @param buffer buffer to decrypt
*/ */
public void decrypt(int[] buffer) public void decrypt(int[] buffer)
{ {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// decrypt a temporary 64bit block // decrypt a temporary 64bit block
lTemp = intArrayToLong(buffer, nI); lTemp = intArrayToLong(buffer, nI);
...@@ -638,6 +661,7 @@ public class Blowfish { ...@@ -638,6 +661,7 @@ public class Blowfish {
/** /**
* decrypts a long buffer to another long buffer (of the same size or bigger) * decrypts a long buffer to another long buffer (of the same size or bigger)
*
* @param inbuffer buffer with ciphertext data * @param inbuffer buffer with ciphertext data
* @param outbuffer buffer to get the plaintext data * @param outbuffer buffer to get the plaintext data
*/ */
...@@ -653,6 +677,7 @@ public class Blowfish { ...@@ -653,6 +677,7 @@ public class Blowfish {
/** /**
* decrypts a long buffer to itself * decrypts a long buffer to itself
*
* @param buffer buffer to decrypt * @param buffer buffer to decrypt
*/ */
public void decrypt(long[] buffer) { public void decrypt(long[] buffer) {
...@@ -673,7 +698,8 @@ public class Blowfish { ...@@ -673,7 +698,8 @@ public class Blowfish {
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b }; 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b
};
final static int sbox_init_1[] = { final static int sbox_init_1[] = {
...@@ -719,7 +745,8 @@ public class Blowfish { ...@@ -719,7 +745,8 @@ public class Blowfish {
0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a }; 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
};
final static int sbox_init_2[] = { final static int sbox_init_2[] = {
...@@ -767,7 +794,8 @@ public class Blowfish { ...@@ -767,7 +794,8 @@ public class Blowfish {
0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, 0x9e447a2e, 0xc3453484, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, 0x9e447a2e, 0xc3453484,
0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a,
0xe6e39f2b, 0xdb83adf7 }; 0xe6e39f2b, 0xdb83adf7
};
final static int sbox_init_3[] = { final static int sbox_init_3[] = {
...@@ -813,7 +841,8 @@ public class Blowfish { ...@@ -813,7 +841,8 @@ public class Blowfish {
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9,
0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4,
0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 }; 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
};
final static int sbox_init_4[] = { final static int sbox_init_4[] = {
...@@ -860,7 +889,8 @@ public class Blowfish { ...@@ -860,7 +889,8 @@ public class Blowfish {
0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 }; 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
};
} }
...@@ -872,6 +902,7 @@ public class Blowfish { ...@@ -872,6 +902,7 @@ public class Blowfish {
/** /**
* get the current CBC IV (for cipher resets) * get the current CBC IV (for cipher resets)
*
* @return current CBC IV * @return current CBC IV
*/ */
public long getCBCIV() public long getCBCIV()
...@@ -881,6 +912,7 @@ public class Blowfish { ...@@ -881,6 +912,7 @@ public class Blowfish {
/** /**
* get the current CBC IV (for cipher resets) * get the current CBC IV (for cipher resets)
*
* @param dest wher eto put current CBC IV in network byte ordered array * @param dest wher eto put current CBC IV in network byte ordered array
*/ */
public void getCBCIV(byte[] dest) public void getCBCIV(byte[] dest)
...@@ -890,6 +922,7 @@ public class Blowfish { ...@@ -890,6 +922,7 @@ public class Blowfish {
/** /**
* set the current CBC IV (for cipher resets) * set the current CBC IV (for cipher resets)
*
* @param lNewCBCIV the new CBC IV * @param lNewCBCIV the new CBC IV
*/ */
public void setCBCIV(long lNewCBCIV) public void setCBCIV(long lNewCBCIV)
...@@ -899,6 +932,7 @@ public class Blowfish { ...@@ -899,6 +932,7 @@ public class Blowfish {
/** /**
* set the current CBC IV (for cipher resets) * set the current CBC IV (for cipher resets)
*
* @param newCBCIV the new CBC IV in network byte ordered array * @param newCBCIV the new CBC IV in network byte ordered array
*/ */
public void setCBCIV(byte[] newCBCIV) public void setCBCIV(byte[] newCBCIV)
...@@ -909,6 +943,7 @@ public class Blowfish { ...@@ -909,6 +943,7 @@ public class Blowfish {
/** /**
* constructor, stores a zero CBC IV * constructor, stores a zero CBC IV
*
* @param bfkey key material, up to MAXKEYLENGTH bytes * @param bfkey key material, up to MAXKEYLENGTH bytes
*/ */
public BlowfishCBC(byte[] bfkey) public BlowfishCBC(byte[] bfkey)
...@@ -922,6 +957,7 @@ public class Blowfish { ...@@ -922,6 +957,7 @@ public class Blowfish {
/** /**
* constructor * constructor
*
* @param bfkey key material, up to MAXKEYLENGTH bytes * @param bfkey key material, up to MAXKEYLENGTH bytes
* @param lInitCBCIV the CBC IV * @param lInitCBCIV the CBC IV
*/ */
...@@ -937,6 +973,7 @@ public class Blowfish { ...@@ -937,6 +973,7 @@ public class Blowfish {
/** /**
* constructor * constructor
*
* @param bfkey key material, up to MAXKEYLENGTH bytes * @param bfkey key material, up to MAXKEYLENGTH bytes
* @param initCBCIV the CBC IV (array with min. BLOCKSIZE bytes) * @param initCBCIV the CBC IV (array with min. BLOCKSIZE bytes)
*/ */
...@@ -999,6 +1036,7 @@ public class Blowfish { ...@@ -999,6 +1036,7 @@ public class Blowfish {
/** /**
* encrypts a byte buffer (should be aligned to an 8 byte border) * encrypts a byte buffer (should be aligned to an 8 byte border)
* to another buffer (of the same size or bigger) * to another buffer (of the same size or bigger)
*
* @param inbuffer buffer with plaintext data * @param inbuffer buffer with plaintext data
* @param outbuffer buffer to get the ciphertext data * @param outbuffer buffer to get the ciphertext data
*/ */
...@@ -1007,7 +1045,7 @@ public class Blowfish { ...@@ -1007,7 +1045,7 @@ public class Blowfish {
{ {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = byteArrayToLong(inbuffer, nI); lTemp = byteArrayToLong(inbuffer, nI);
...@@ -1020,6 +1058,7 @@ public class Blowfish { ...@@ -1020,6 +1058,7 @@ public class Blowfish {
/** /**
* encrypts a byte buffer (should be aligned to an 8 byte border) to itself * encrypts a byte buffer (should be aligned to an 8 byte border) to itself
*
* @param buffer buffer to encrypt * @param buffer buffer to encrypt
*/ */
public void encrypt(byte[] buffer) public void encrypt(byte[] buffer)
...@@ -1027,7 +1066,7 @@ public class Blowfish { ...@@ -1027,7 +1066,7 @@ public class Blowfish {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = byteArrayToLong(buffer, nI); lTemp = byteArrayToLong(buffer, nI);
...@@ -1038,11 +1077,11 @@ public class Blowfish { ...@@ -1038,11 +1077,11 @@ public class Blowfish {
/** /**
* encrypts an int buffer (should be aligned to an * encrypts an int buffer (should be aligned to an
* two integer border) to another int buffer (of the same * two integer border) to another int buffer (of the same
* size or bigger) * size or bigger)
*
* @param inbuffer buffer with plaintext data * @param inbuffer buffer with plaintext data
* @param outbuffer buffer to get the ciphertext data * @param outbuffer buffer to get the ciphertext data
*/ */
...@@ -1051,7 +1090,7 @@ public class Blowfish { ...@@ -1051,7 +1090,7 @@ public class Blowfish {
{ {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = intArrayToLong(inbuffer, nI); lTemp = intArrayToLong(inbuffer, nI);
...@@ -1063,13 +1102,14 @@ public class Blowfish { ...@@ -1063,13 +1102,14 @@ public class Blowfish {
/** /**
* encrypts an integer buffer (should be aligned to an * encrypts an integer buffer (should be aligned to an
*
* @param buffer buffer to encrypt * @param buffer buffer to encrypt
*/ */
public void encrypt(int[] buffer) public void encrypt(int[] buffer)
{ {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// encrypt a temporary 64bit block // encrypt a temporary 64bit block
lTemp = intArrayToLong(buffer, nI); lTemp = intArrayToLong(buffer, nI);
...@@ -1082,6 +1122,7 @@ public class Blowfish { ...@@ -1082,6 +1122,7 @@ public class Blowfish {
/** /**
* encrypts a long buffer to another long buffer (of the same size or bigger) * encrypts a long buffer to another long buffer (of the same size or bigger)
*
* @param inbuffer buffer with plaintext data * @param inbuffer buffer with plaintext data
* @param outbuffer buffer to get the ciphertext data * @param outbuffer buffer to get the ciphertext data
*/ */
...@@ -1099,6 +1140,7 @@ public class Blowfish { ...@@ -1099,6 +1140,7 @@ public class Blowfish {
/** /**
* encrypts a long buffer to itself * encrypts a long buffer to itself
*
* @param buffer buffer to encrypt * @param buffer buffer to encrypt
*/ */
public void encrypt(long[] buffer) public void encrypt(long[] buffer)
...@@ -1115,6 +1157,7 @@ public class Blowfish { ...@@ -1115,6 +1157,7 @@ public class Blowfish {
/** /**
* decrypts a byte buffer (should be aligned to an 8 byte border) * decrypts a byte buffer (should be aligned to an 8 byte border)
* to another buffer (of the same size or bigger) * to another buffer (of the same size or bigger)
*
* @param inbuffer buffer with ciphertext data * @param inbuffer buffer with ciphertext data
* @param outbuffer buffer to get the plaintext data * @param outbuffer buffer to get the plaintext data
*/ */
...@@ -1123,7 +1166,7 @@ public class Blowfish { ...@@ -1123,7 +1166,7 @@ public class Blowfish {
{ {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// decrypt a temporary 64bit block // decrypt a temporary 64bit block
lTemp = byteArrayToLong(inbuffer, nI); lTemp = byteArrayToLong(inbuffer, nI);
...@@ -1136,13 +1179,14 @@ public class Blowfish { ...@@ -1136,13 +1179,14 @@ public class Blowfish {
/** /**
* decrypts a byte buffer (should be aligned to an 8 byte border) to itself * decrypts a byte buffer (should be aligned to an 8 byte border) to itself
*
* @param buffer buffer to decrypt * @param buffer buffer to decrypt
*/ */
public void decrypt(byte[] buffer) public void decrypt(byte[] buffer)
{ {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=8) for (int nI = 0; nI < nLen; nI += 8)
{ {
// decrypt over a temporary 64bit block // decrypt over a temporary 64bit block
lTemp = byteArrayToLong(buffer, nI); lTemp = byteArrayToLong(buffer, nI);
...@@ -1153,10 +1197,10 @@ public class Blowfish { ...@@ -1153,10 +1197,10 @@ public class Blowfish {
/** /**
* decrypts an integer buffer (should be aligned to an * decrypts an integer buffer (should be aligned to an
* two integer border) to another int buffer (of the same size or bigger) * two integer border) to another int buffer (of the same size or bigger)
*
* @param inbuffer buffer with ciphertext data * @param inbuffer buffer with ciphertext data
* @param outbuffer buffer to get the plaintext data * @param outbuffer buffer to get the plaintext data
*/ */
...@@ -1166,7 +1210,7 @@ public class Blowfish { ...@@ -1166,7 +1210,7 @@ public class Blowfish {
int nLen = inbuffer.length; int nLen = inbuffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// decrypt a temporary 64bit block // decrypt a temporary 64bit block
lTemp = intArrayToLong(inbuffer, nI); lTemp = intArrayToLong(inbuffer, nI);
...@@ -1179,13 +1223,14 @@ public class Blowfish { ...@@ -1179,13 +1223,14 @@ public class Blowfish {
/** /**
* decrypts an int buffer (should be aligned to a * decrypts an int buffer (should be aligned to a
* two integer border) * two integer border)
*
* @param buffer buffer to decrypt * @param buffer buffer to decrypt
*/ */
public void decrypt(int[] buffer) public void decrypt(int[] buffer)
{ {
int nLen = buffer.length; int nLen = buffer.length;
long lTemp; long lTemp;
for (int nI = 0; nI < nLen; nI +=2) for (int nI = 0; nI < nLen; nI += 2)
{ {
// decrypt a temporary 64bit block // decrypt a temporary 64bit block
lTemp = intArrayToLong(buffer, nI); lTemp = intArrayToLong(buffer, nI);
...@@ -1198,6 +1243,7 @@ public class Blowfish { ...@@ -1198,6 +1243,7 @@ public class Blowfish {
/** /**
* decrypts a long buffer to another long buffer (of the same size or bigger) * decrypts a long buffer to another long buffer (of the same size or bigger)
*
* @param inbuffer buffer with ciphertext data * @param inbuffer buffer with ciphertext data
* @param outbuffer buffer to get the plaintext data * @param outbuffer buffer to get the plaintext data
*/ */
...@@ -1215,6 +1261,7 @@ public class Blowfish { ...@@ -1215,6 +1261,7 @@ public class Blowfish {
/** /**
* decrypts a long buffer to itself * decrypts a long buffer to itself
*
* @param buffer buffer to decrypt * @param buffer buffer to decrypt
*/ */
public void decrypt(long[] buffer) public void decrypt(long[] buffer)
...@@ -1230,6 +1277,7 @@ public class Blowfish { ...@@ -1230,6 +1277,7 @@ public class Blowfish {
/** /**
* gets bytes from an array into a long * gets bytes from an array into a long
*
* @param buffer where to get the bytes * @param buffer where to get the bytes
* @param nStartIndex index from where to read the data * @param nStartIndex index from where to read the data
* @return the 64bit integer * @return the 64bit integer
...@@ -1237,19 +1285,20 @@ public class Blowfish { ...@@ -1237,19 +1285,20 @@ public class Blowfish {
private static long byteArrayToLong(byte[] buffer, private static long byteArrayToLong(byte[] buffer,
int nStartIndex) int nStartIndex)
{ {
return (((long)buffer[nStartIndex]) << 56) | return (((long) buffer[nStartIndex]) << 56) |
(((long)buffer[nStartIndex + 1] & 0x0ffL) << 48) | (((long) buffer[nStartIndex + 1] & 0x0ffL) << 48) |
(((long)buffer[nStartIndex + 2] & 0x0ffL) << 40) | (((long) buffer[nStartIndex + 2] & 0x0ffL) << 40) |
(((long)buffer[nStartIndex + 3] & 0x0ffL) << 32) | (((long) buffer[nStartIndex + 3] & 0x0ffL) << 32) |
(((long)buffer[nStartIndex + 4] & 0x0ffL) << 24) | (((long) buffer[nStartIndex + 4] & 0x0ffL) << 24) |
(((long)buffer[nStartIndex + 5] & 0x0ffL) << 16) | (((long) buffer[nStartIndex + 5] & 0x0ffL) << 16) |
(((long)buffer[nStartIndex + 6] & 0x0ffL) << 8) | (((long) buffer[nStartIndex + 6] & 0x0ffL) << 8) |
((long)buffer[nStartIndex + 7] & 0x0ff); ((long) buffer[nStartIndex + 7] & 0x0ff);
} }
/** /**
* converts a long o bytes which are put into a given array * converts a long o bytes which are put into a given array
*
* @param lValue the 64bit integer to convert * @param lValue the 64bit integer to convert
* @param buffer the target buffer * @param buffer the target buffer
* @param nStartIndex where to place the bytes in the buffer * @param nStartIndex where to place the bytes in the buffer
...@@ -1271,6 +1320,7 @@ public class Blowfish { ...@@ -1271,6 +1320,7 @@ public class Blowfish {
/** /**
* converts values from an integer array to a long * converts values from an integer array to a long
*
* @param buffer where to get the bytes * @param buffer where to get the bytes
* @param nStartIndex index from where to read the data * @param nStartIndex index from where to read the data
* @return the 64bit integer * @return the 64bit integer
...@@ -1285,6 +1335,7 @@ public class Blowfish { ...@@ -1285,6 +1335,7 @@ public class Blowfish {
/** /**
* converts a long to integers which are put into a given array * converts a long to integers which are put into a given array
*
* @param lValue the 64bit integer to convert * @param lValue the 64bit integer to convert
* @param buffer the target buffer * @param buffer the target buffer
* @param nStartIndex where to place the bytes in the buffer * @param nStartIndex where to place the bytes in the buffer
...@@ -1300,6 +1351,7 @@ public class Blowfish { ...@@ -1300,6 +1351,7 @@ public class Blowfish {
/** /**
* makes a long from two integers (treated unsigned) * makes a long from two integers (treated unsigned)
*
* @param nLo lower 32bits * @param nLo lower 32bits
* @param nHi higher 32bits * @param nHi higher 32bits
* @return the built long * @return the built long
...@@ -1307,36 +1359,40 @@ public class Blowfish { ...@@ -1307,36 +1359,40 @@ public class Blowfish {
private static long makeLong(int nLo, private static long makeLong(int nLo,
int nHi) int nHi)
{ {
return (((long)nHi << 32) | return (((long) nHi << 32) | ((long) nLo & 0x00000000ffffffffL));
((long)nLo & 0x00000000ffffffffL));
} }
/** /**
* gets the lower 32 bits of a long * gets the lower 32 bits of a long
*
* @param lVal the long integer * @param lVal the long integer
* @return lower 32 bits * @return lower 32 bits
*/ */
private static int longLo32(long lVal) private static int longLo32(long lVal)
{ {
return (int)lVal; return (int) lVal;
} }
/** /**
* gets the higher 32 bits of a long * gets the higher 32 bits of a long
*
* @param lVal the long integer * @param lVal the long integer
* @return higher 32 bits * @return higher 32 bits
*/ */
private static int longHi32(long lVal) private static int longHi32(long lVal)
{ {
return (int)((lVal >>> 32)); return (int) ((lVal >>> 32));
} }
// our table for binhex conversion // our table for binhex conversion
final static char[] HEXTAB = { '0', '1', '2', '3', '4', '5', '6', '7', final static char[] HEXTAB = {
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
/** /**
* converts a byte array to a binhex string * converts a byte array to a binhex string
*
* @param data the byte array * @param data the byte array
* @param nStartPos start index where to get the bytes * @param nStartPos start index where to get the bytes
* @param nNumOfBytes number of bytes to convert * @param nNumOfBytes number of bytes to convert
...@@ -1360,6 +1416,7 @@ public class Blowfish { ...@@ -1360,6 +1416,7 @@ public class Blowfish {
/** /**
* converts a binhex string back into a byte array (invalid codes will be skipped) * converts a binhex string back into a byte array (invalid codes will be skipped)
*
* @param sBinHex binhex string * @param sBinHex binhex string
* @param data the target array * @param data the target array
* @param nSrcPos from which character in the string the conversion should begin, * @param nSrcPos from which character in the string the conversion should begin,
...@@ -1402,13 +1459,13 @@ public class Blowfish { ...@@ -1402,13 +1459,13 @@ public class Blowfish {
if ((cActChar >= 'a') && (cActChar <= 'f')) if ((cActChar >= 'a') && (cActChar <= 'f'))
{ {
bActByte |= (byte)(cActChar - 'a') + 10; bActByte |= (byte) (cActChar - 'a') + 10;
} }
else else
{ {
if ((cActChar >= '0') && (cActChar <= '9')) if ((cActChar >= '0') && (cActChar <= '9'))
{ {
bActByte |= (byte)(cActChar - '0'); bActByte |= (byte) (cActChar - '0');
} }
else else
{ {
...@@ -1428,6 +1485,7 @@ public class Blowfish { ...@@ -1428,6 +1485,7 @@ public class Blowfish {
/** /**
* converts a byte array into an UNICODE string * converts a byte array into an UNICODE string
*
* @param data the byte array * @param data the byte array
* @param nStartPos where to begin the conversion * @param nStartPos where to begin the conversion
* @param nNumOfBytes number of bytes to handle * @param nNumOfBytes number of bytes to handle
...@@ -1456,7 +1514,7 @@ public class Blowfish { ...@@ -1456,7 +1514,7 @@ public class Blowfish {
while (nNumOfBytes > 0) while (nNumOfBytes > 0)
{ {
sbuf.setCharAt(nSBufPos++, sbuf.setCharAt(nSBufPos++,
(char)(((int)data[nStartPos] << 8) | ((int)data[nStartPos + 1] & 0x0ff))); (char) (((int) data[nStartPos] << 8) | ((int) data[nStartPos + 1] & 0x0ff)));
nStartPos += 2; nStartPos += 2;
nNumOfBytes -= 2; nNumOfBytes -= 2;
} }
......
package com.originspark.drp.util; package com.originspark.drp.util;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.originspark.drp.models.User; import com.originspark.drp.models.User;
public class SessionUtil { public class SessionUtil {
//返回当前登陆的用户信息 // 返回当前登陆的用户信息
public static User getCurrentUser(HttpServletRequest request){ public static User getCurrentUser(HttpServletRequest request) {
User user=(User) request.getSession().getAttribute("user"); User user = (User) request.getSession().getAttribute("user");
return user; return user;
} }
public static String getCurrentUserName(HttpServletRequest request){ public static String getCurrentUserName(HttpServletRequest request) {
return getCurrentUser(request).getName(); return getCurrentUser(request).getName();
} }
} }
...@@ -10,12 +10,12 @@ public class StringUtil { ...@@ -10,12 +10,12 @@ public class StringUtil {
static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
public static Date String2Date(String str) throws ParseException{ public static Date String2Date(String str) throws ParseException {
return sdf.parse(str); return sdf.parse(str);
} }
public static BigDecimal String2BigDecimal(String str){ public static BigDecimal String2BigDecimal(String str) {
return BigDecimal.valueOf(Double.parseDouble(str)); return BigDecimal.valueOf(Double.parseDouble(str));
} }
...@@ -25,16 +25,16 @@ public class StringUtil { ...@@ -25,16 +25,16 @@ public class StringUtil {
* @param thisMonth="2014-02"/"2014-01" * @param thisMonth="2014-02"/"2014-01"
* @return "2014-01"/"2013-12" * @return "2014-01"/"2013-12"
*/ */
public static String getPreMonth(String thisMonth){ public static String getPreMonth(String thisMonth) {
String yearMonth[] = thisMonth.split("-"); String yearMonth[] = thisMonth.split("-");
int month = Integer.parseInt(yearMonth[1]); int month = Integer.parseInt(yearMonth[1]);
if(month > 1){ if (month > 1) {
return yearMonth[0]+"-"+String.format("%02d", month-1); return yearMonth[0] + "-" + String.format("%02d", month - 1);
} }
int year = Integer.parseInt(yearMonth[0]); int year = Integer.parseInt(yearMonth[0]);
return (year-1)+"-12"; return (year - 1) + "-12";
} }
} }
...@@ -26,11 +26,11 @@ public class MonthendInventoryGenerator { ...@@ -26,11 +26,11 @@ public class MonthendInventoryGenerator {
* @param resourcePath 代指目录/WebContent/resources * @param resourcePath 代指目录/WebContent/resources
* @return * @return
*/ */
public static File generate(String fileName,List<Ware> inventories,String resourcePath){ public static File generate(String fileName, List<Ware> inventories, String resourcePath) {
try { try {
// Open excel template // Open excel template
InputStream inp = new FileInputStream(FileUtils.getFile( resourcePath + "/document_templates/monthEndInventory.xls")); InputStream inp = new FileInputStream(FileUtils.getFile(resourcePath + "/document_templates/monthEndInventory.xls"));
Workbook wb = WorkbookFactory.create(inp); Workbook wb = WorkbookFactory.create(inp);
Sheet mainSheet = wb.getSheetAt(0); Sheet mainSheet = wb.getSheetAt(0);
...@@ -44,10 +44,10 @@ public class MonthendInventoryGenerator { ...@@ -44,10 +44,10 @@ public class MonthendInventoryGenerator {
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(inventory.getWareBrand()); row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(inventory.getWareBrand());
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(inventory.getWareModel()); row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(inventory.getWareModel());
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(inventory.getWareUnit()); row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(inventory.getWareUnit());
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(inventory.getLastMonthLeft()+""); row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(inventory.getLastMonthLeft() + "");
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(inventory.getMonthIn()+""); row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(inventory.getMonthIn() + "");
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(inventory.getMonthOut()+""); row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(inventory.getMonthOut() + "");
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(inventory.getMonthLeft()+""); row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(inventory.getMonthLeft() + "");
currentRow.increment(); currentRow.increment();
} }
......
package com.originspark.drp.web.models.projects;
import java.util.Date;
public class ProjectUI {
private Long id;
private String name;
private String code;
private String city;
private Date startDate;
private Date endDate;
private Long parentId;
private boolean leaf;
private Long projectManager;
private Long wareKeeper;
private Long materialKeeper;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public boolean isLeaf() {
return leaf;
}
public void setLeaf(boolean leaf) {
this.leaf = leaf;
}
public Long getProjectManager() {
return projectManager;
}
public void setProjectManager(Long projectManager) {
this.projectManager = projectManager;
}
public Long getWareKeeper() {
return wareKeeper;
}
public void setWareKeeper(Long wareKeeper) {
this.wareKeeper = wareKeeper;
}
public Long getMaterialKeeper() {
return materialKeeper;
}
public void setMaterialKeeper(Long materialKeeper) {
this.materialKeeper = materialKeeper;
}
}
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.jdbc.fetch_size" value="18" />
<property name="hibernate.jdbc.batch_size" value="10" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory" />
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy" />
<property name="net.sf.ehcache.configurationResourceName" value="ehcache-hibernate-local.xml" />
</properties>
</persistence-unit>
</persistence>
...@@ -19,23 +19,13 @@ ...@@ -19,23 +19,13 @@
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan> </context:component-scan>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<!-- 数据源配置, 使用DBCP数据库连接池 --> <!-- 数据源配置, 使用DBCP数据库连接池 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- Connection Info -->
<property name="driverClassName" value="${jdbc.driver}"/> <property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/> <property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/> <property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/> <property name="password" value="${jdbc.password}"/>
<!-- Connection Pooling Info -->
<property name="maxActive" value="${dbcp.maxActive}"/> <property name="maxActive" value="${dbcp.maxActive}"/>
<property name="maxIdle" value="${dbcp.maxIdle}"/> <property name="maxIdle" value="${dbcp.maxIdle}"/>
<property name="defaultAutoCommit" value="false"/> <property name="defaultAutoCommit" value="false"/>
...@@ -49,15 +39,7 @@ ...@@ -49,15 +39,7 @@
<property name="dataSource" ref="dataSource"/> <property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/> <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/>
<property name="packagesToScan" value="com.originspark.drp.models.**"/> <property name="packagesToScan" value="com.originspark.drp.models.**"/>
<property name="jpaProperties"> <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="net.sf.ehcache.configurationResourceName">ehcache-hibernate-local.xml</prop>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
</props>
</property>
</bean> </bean>
<bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/> <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ehcache> <ehcache>
<diskStore path="java.io.tmpdir/hibernate/wms" /> <diskStore path="java.io.tmpdir/hibernate/wms" />
<!-- DefaultCache setting. --> <!-- DefaultCache setting. -->
<defaultCache maxElementsInMemory="10000" memoryStoreEvictionPolicy="LRU" eternal="false" <defaultCache maxElementsInMemory="10000" memoryStoreEvictionPolicy="LRU" eternal="false"
timeToIdleSeconds="300" timeToLiveSeconds="300" overflowToDisk="false" diskPersistent="false" /> timeToIdleSeconds="300" timeToLiveSeconds="300" overflowToDisk="false" diskPersistent="false" />
</ehcache> </ehcache>
#sql.type=h2
#jdbc h2
#jdbc.driver=org.h2.Driver
#jdbc.url=jdbc:h2:file:~/wms;AUTO_SERVER=TRUE
#jdbc.username=sa
#jdbc.password=
#hibernate.dialect=org.hibernate.dialect.H2Dialect
sql.type=mysql
jdbc.driver=com.mysql.jdbc.Driver jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/drp?useUnicode=true&characterEncoding=UTF-8 jdbc.url=jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8
jdbc.username=root jdbc.username=root
jdbc.password= jdbc.password=
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
#hibernate settings
hibernate.hbm2ddl.auto=update
hibernate.show_sql=true
hibernate.format_sql=true
#dbcp settings #dbcp settings
dbcp.initialSize=5 dbcp.initialSize=5
......
-- phpMyAdmin SQL Dump
-- version 4.2.7.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: 2015-03-18 05:10:34
-- 服务器版本: 5.6.20
-- PHP Version: 5.5.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `drp`
--
-- --------------------------------------------------------
--
-- 表的结构 `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` bigint(20) NOT NULL,
`created_by` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_on` datetime NOT NULL,
`status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`updated_by` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`updated_on` datetime NOT NULL,
`address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`gender` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;
-- --
-- 转存表中的数据 `users` -- 转存表中的数据 `users`
-- --
INSERT INTO `users` (`id`, `created_by`, `created_on`, `status`, `updated_by`, `updated_on`, `address`, `code`, `email`, `gender`, `name`, `password`, `phone`, `type`, `username`) VALUES INSERT INTO `users` (`id`, `created_by`, `created_on`, `status`, `updated_by`, `updated_on`, `address`, `code`, `email`, `gender`, `name`, `password`, `phone`, `type`, `username`) VALUES
(1, NULL, '2015-03-18 11:25:34', 'ACTIVE', NULL, '2015-03-18 12:10:12', '', 'admin', '', 'MALE', 'admin', '17a73b924892695ff91e16b35ce100b7c64928e43d5a170a', '1324332345', 'MANAGER', NULL); (1, NULL, '2015-03-18 11:25:34', 'ACTIVE', NULL, '2015-03-18 12:10:12', '', 'admin', '', 'MALE', 'admin', '17a73b924892695ff91e16b35ce100b7c64928e43d5a170a', '1324332345', 'MANAGER', NULL);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>smart-nav</display-name> <display-name>smart-nav</display-name>
<context-param> <context-param>
<param-name>contextConfigLocation</param-name> <param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value> <param-value>classpath*:context.xml</param-value>
</context-param> </context-param>
<listener> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
......
/**
* @author allenjin
*/
Ext.define("drp.app.controller.projects.ProjectController", {
extend : "drp.app.controller.AbstractController",
projectTreePanel : null,
me : null,
init : function() {
me = this;
this.control({
'projectview' : {
afterrender : function(panel) {
projectTreePanel = panel.down('treepanel');
var store = projectTreePanel.getStore();
store.load({
node : store.getRootNode()
});
}
},
// 查询项目
'projectview button[action=searchProject]' : {
click : this.searchProject
},
// 增加项目
'projectview button[action=addProject]' : {
click : this.showCreateProjectForm
},
// 添加系统
'projectview button[action=addSystem]' : {
click : this.showCreateSystemForm
},
// 更新项目
'projectview > treepanel' : {
itemdblclick : this.showUpdateProjectOrSystemForm,
itemclick : function(tree, record, item, index, e, eOpts) {
tree.toggleOnDblClick = false;
}
},
// 删除项目
'projectview button[action=deleteProject]' : {
click : this.deleteProject
},
'projectviewform button[action=submitProjectForm]' : {
click : this.submitProjectForm
},
'projectviewform button[action=closeProjectForm]' : {
click : this.closeProjectForm
},
'systemviewform button[action=submitSystemForm]' : {
click : this.submitProjectForm
},
'systemviewform button[action=closeSystemForm]' : {
click : this.closeSystemForm
}
});
},
showCreateProjectForm : function(btn) {
var projectForm = Ext.widget("projectviewform");
AlertWin.alert('新增项目', null, projectForm, 450, 240);
},
showCreateSystemForm : function(btn){
var record = projectTreePanel.getSelectionModel().getSelection()[0];
if (!record || record.data.leaf) {
Ext.MessageBox.show({
title : "提示",
msg : "请先选择项目!",
icon : Ext.MessageBox.INFO,
buttons : Ext.Msg.OK
});
return;
}
var systemForm = Ext.widget("systemviewform");
//设置项目名称
var project = record;
systemForm.down('#projectId').setValue(project.data.id);
systemForm.down('#projectName').setValue(project.data.name);
AlertWin.alert('添加系统', null, systemForm, 450, 180);
},
showUpdateProjectOrSystemForm : function(grid, record, item, index, e, eopts) {
if (!record) {
me.showPromptsOnUpdate("数据");
return;
} else {
//如果是系统
if(record.isLeaf()){
var systemForm = Ext.widget("systemviewform");
if (!record) {
me.showPromptsOnUpdate("系统");
return;
} else {
systemForm.down('form').loadRecord(record);
//设置项目名称
var project = record.parentNode;
systemForm.down('#projectId').setValue(project.data.id);
systemForm.down('#projectName').setValue(project.data.name);
AlertWin.alert('修改系统', null, systemForm, 450, 180);
}
//如果是项目
}else{
var projectForm = Ext.widget("projectviewform");
if (!record) {
me.showPromptsOnUpdate("项目");
return;
} else {
//在弹出更新项目的form前,需要设置下面三部分内容
projectForm.down('form').loadRecord(record);
//1.设置项目经理
var projectManagerRecord = Ext.create("drp.app.model.users.ProjectManagerModel", {
id : record.data.projectManager.id,
name : record.data.projectManager.name
});
projectForm.down('#projectManager_cb').setValue(projectManagerRecord);
//2.设置库管员
var WareKeeperRecord = Ext.create("drp.app.model.users.WareKeeperModel", {
id : record.data.wareKeeper.id,
name : record.data.wareKeeper.name
});
projectForm.down('#wareKeeper_cb').setValue(WareKeeperRecord);
//3.设置材料员
var MaterialKeeperRecord = Ext.create("drp.app.model.users.MaterialKeeperModel", {
id : record.data.materialKeeper.id,
name : record.data.materialKeeper.name
});
projectForm.down('#materialKeeper_cb').setValue(MaterialKeeperRecord);
AlertWin.alert('修改项目', null, projectForm, 450, 240);
}
}
}
},
deleteProject : function(btn) {
var record = projectTreePanel.getSelectionModel().getSelection()[0];
if (!record) {
me.showPromptsOnDelete(name);
return;
} else {
Ext.MessageBox.confirm("标题", "你要删除这个项目吗?", function(btn) {
if (btn == 'yes') {
me.destroyTreeNode(record, {
success : function(records, operation) {
projectTreePanel.getSelectionModel().deselectAll();
projectTreePanel.getStore().load();
Ext.Msg.alert("成功!", operation.request.scope.reader.jsonData["message"]);
},
failure : function(records, operation) {
Ext.Msg.alert("失败!", operation.request.scope.reader.jsonData["message"]);
}
});
}
});
}
},
submitProjectForm : function(btn) {
var modelName = "drp.app.model.projects.ProjectModel";
var form = btn.up('form').getForm();
if (form.isValid()) {
var formBean = form.getValues();
var model = Ext.create(modelName, formBean);
model.set("projectManager",formBean['projectManager.id']);
model.set("wareKeeper",formBean['wareKeeper.id']);
model.set("materialKeeper",formBean['materialKeeper.id']);
me.saveModel(model, projectTreePanel);
}
},
closeProjectForm : function(btn) {
me.closeForm();
},
closeSystemForm : function(btn) {
me.closeForm();
},
searchProject : function(btn) {
var store = projectTreePanel.getStore();
store.filters.clear();
store.filter([ {
property : "name",
value : Ext.getCmp("projectName_filter").getValue()
}, {
property : "code",
value : Ext.getCmp("projectCode_filter").getValue()
}, {
property : "city",
value : Ext.getCmp("projectCity_filter").getValue()
}, {
property : "startDate",
value : Ext.getCmp("projectStartDate_filter").getValue()
}, {
property : "endDate",
value : Ext.getCmp("projectEndDate_filter").getValue()
} ]);
},
models : [ "drp.app.model.projects.ProjectModel","drp.app.model.users.ProjectManagerModel",
"drp.app.model.users.WareKeeperModel","drp.app.model.users.MaterialKeeperModel" ],
stores : [ "drp.app.store.projects.ProjectStore", "drp.app.store.users.ProjectManagerStore",
"drp.app.store.users.MaterialKeeperStore","drp.app.store.users.WareKeeperStore"],
views : [ "drp.app.view.projects.ProjectView",
"drp.app.view.projects.ProjectViewForm",
"drp.app.view.projects.SystemViewForm" ]
});
\ No newline at end of file
/**
* @author allenjin
*/
Ext.define("drp.app.model.projects.ProjectModel", {
extend : "drp.app.model.AbstractModel",
fields : [{
name : "name"// 项目名称
}, {
name : "code"// 项目编号
}, {
name : "city"//项目所在城市
}, {
name : "startDate"// 开工时间
}, {
name : "endDate"// 竣工时间
}, {
name : "projectName",
persist : false
}, {
name : 'projectManager',
type : 'auto'
}, {
name : 'wareKeeper',
type : 'auto'
}, {
name : 'materialKeeper',
type : 'auto'
}],
proxy : {
type : 'rest',
url : 'project',
reader : {
type : "json",
root : "data",
successProperty : 'success'
},
writer : {
type : "json"
},
listeners : {
exception : function(proxy, response, operation) {
Ext.MessageBox.show({
title : '错误',
msg : "数据加载错误,请尝试刷新页面",
icon : Ext.MessageBox.ERROR,
buttons : Ext.Msg.OK
});
}
}
}
});
\ No newline at end of file
Ext.define("drp.app.store.projects.ProjectDataStore", {
extend : 'drp.app.store.AbstractStore',
model : 'drp.app.model.projects.ProjectModel'
});
\ No newline at end of file
/**
* @author reed mi
*/
Ext.define("drp.app.store.projects.ProjectStore", {
extend : 'Ext.data.TreeStore',
model : 'drp.app.model.projects.ProjectModel',
defaultRootId : '',
root : {data : []}
});
\ No newline at end of file
/**
* @author allenjin
*/
Ext.define('drp.app.view.projects.ProjectView', {
extend : 'Ext.panel.Panel',
alias : 'widget.projectview',
margins : '0 0 0 0',
border : 0,
title : '<center height=40>项目列表</center>',
autoScroll : true,
closable : true,
layout : {
type : 'border'
},
initComponent : function() {
var me = this;
// var selModel = Ext.create('Ext.selection.CheckboxModel', {
// listeners : {
// selectionchange : function(sm, selections) {
// me.down('#deleteProject_btn').setDisabled(selections.length == 0);
// }
// }
// });
Ext.applyIf(me, {
items : [
// {
// xtype : 'panel',
// region : 'north',
// title : '查询',
// collapsible : true,
// items : [ {
// xtype : 'form',
// items : [{
// xtype : 'fieldcontainer',
// layout : 'column',
// items : [ {
// xtype : 'textfield',
// margin : '5 0 0 10',
// id: 'projectName_filter',
// fieldLabel : '项目名称'
// }, {
// xtype : 'textfield',
// margin : '5 0 0 15',
// id: 'projectCode_filter',
// fieldLabel : '项目编码'
// } ]
// }, {
// xtype : 'fieldcontainer',
// layout : 'column',
// items : [ {
// xtype : 'datefield',
// margin : '5 0 0 10',
// id: 'projectStartDate_filter',
// fieldLabel : '开工时间'
// }, {
// xtype : 'datefield',
// margin : '5 0 0 15',
// id: 'projectEndDate_filter',
// fieldLabel : '竣工时间'
// }, {
// xtype : 'textfield',
// margin : '5 0 0 10',
// id: 'projectCity_filter',
// fieldLabel : '城市'
// }, {
// xtype : 'button',
// margin : '5 0 0 20',
// action : 'searchProject',
// icon : 'resources/images/icons/search.png',
// text : '查询'
// } ]
// } ]
// } ]
// },
{
xtype : 'treepanel',
region : 'center',
rootVisible : false,
autoScroll : true,
columnLines : true,
rowLines : true,
// selModel : selModel,
viewConfig : {
// 防止在刷新节点后默认回到最top
preserveScrollOnRefresh : false
},
store : "drp.app.store.projects.ProjectStore",
columns : [{
xtype : 'treecolumn',
width : 200,
dataIndex : 'name',
text : '项目名称'
}, {
xtype : 'gridcolumn',
width : 100,
dataIndex : 'code',
text : '项目编号'
}, {
xtype : 'gridcolumn',
width : 100,
dataIndex : 'projectManager',
text : '项目经理',
renderer : function(value, metadata, record) {
if (record.isLeaf()) {
return "";
} else {
return value==null?"":(value.name);
}
}
}, {
xtype : 'gridcolumn',
width : 100,
dataIndex : 'wareKeeper',
text : '库管员',
renderer : function(value, metadata, record) {
if (record.isLeaf()) {
return "";
} else {
return value==null?"":(value.name);
}
}
}, {
xtype : 'gridcolumn',
width : 100,
dataIndex : 'materialKeeper',
text : '材料员',
renderer : function(value, metadata, record) {
if (record.isLeaf()) {
return "";
} else {
return value==null?"":(value.name);
}
}
}, {
xtype : 'gridcolumn',
width : 100,
dataIndex : 'city',
text : '城市'
}, {
xtype : 'gridcolumn',
width : 100,
dataIndex : 'startDate',
text : '开工时间'
}, {
xtype : 'gridcolumn',
width : 100,
dataIndex : 'endDate',
text : '竣工时间'
}, {
xtype : 'gridcolumn',
width : 140,
dataIndex : 'createOn',
text : '创建时间'
}, {
xtype : 'gridcolumn',
width : 140,
dataIndex : 'updateOn',
text : '更新时间'
}],
listeners : {
'selectionchange' : function(model, selected){
me.down('#deleteProject_btn').setDisabled(selected.length == 0);
}
},
dockedItems : [{
xtype : 'toolbar',
dock : 'top',
items : [{
xtype : 'button',
icon : 'resources/images/icons/add.png',
action : 'addProject',
text : '新增项目'
}, '-', {
xtype : 'button',
icon : 'resources/images/icons/add.png',
action : 'addSystem',
text : '新增系统'
}, '-', {
xtype : 'button',
icon : 'resources/images/icons/delete.png',
action : 'deleteProject',
itemId : "deleteProject_btn",
disabled : true,
text : '删除'
}]
}]
}]
});
me.callParent(arguments);
}
});
\ No newline at end of file
/**
* @author allenjin
*/
Ext.define("drp.app.view.projects.ProjectViewForm", {
extend : 'Ext.panel.Panel',
alias : 'widget.projectviewform',
author : '100%',
autoScroll : true,
items : [{
xtype : 'form',
items : [{
xtype : 'textfield',
hidden : true,
name : 'id'
}, {
xtype : 'textfield',
anchor : '95%',
margin : '5 0 0 5',
name : 'name',
allowBlank : false,
fieldLabel : '项目名称<font color="red">*</font>'
}, {
xtype : 'textfield',
anchor : '95%',
margin : '5 0 0 5',
name : 'code',
allowBlank : false,
fieldLabel : '项目编号<font color="red">*</font>'
}, {
xtype : 'combobox',
anchor : '90%',
margin : '5 0 0 5',
allowBlank : false,
editable : false,
itemId : 'projectManager_cb',
name : 'projectManager.id',
displayField :"name",
valueField :"id",
fieldLabel : '项目经理<font color="red">*</font>',
store : Ext.create("Ext.data.Store",{
model : 'drp.app.model.users.ProjectManagerModel',
autoLoad : false
}),
listeners : {
afterrender : function(cb){
var store = cb.getStore();
store.filters.clear();
store.filter([ {
property : "status",
value : "ACTIVE"
}]);
}
}
}, {
xtype : 'combobox',
anchor : '90%',
margin : '5 0 0 5',
allowBlank : false,
editable : false,
itemId : 'wareKeeper_cb',
name : 'wareKeeper.id',
displayField :"name",
valueField :"id",
fieldLabel : '库管员<font color="red">*</font>',
store : Ext.create("Ext.data.Store",{
model : 'drp.app.model.users.WareKeeperModel',
autoLoad : false
}),
listeners : {
afterrender : function(cb){
var store = cb.getStore();
store.filters.clear();
store.filter([ {
property : "status",
value : "ACTIVE"
}]);
}
}
}, {
xtype : 'combobox',
anchor : '90%',
margin : '5 0 0 5',
allowBlank : false,
editable : false,
itemId : 'materialKeeper_cb',
name : 'materialKeeper.id',
displayField :"name",
valueField :"id",
fieldLabel : '材料员<font color="red">*</font>',
store : Ext.create("Ext.data.Store",{
model : 'drp.app.model.users.MaterialKeeperModel',
autoLoad : false
}),
listeners : {
afterrender : function(cb){
var store = cb.getStore();
store.filters.clear();
store.filter([ {
property : "status",
value : "ACTIVE"
}]);
}
}
}, {
xtype : 'textfield',
anchor : '70%',
margin : '5 0 0 5',
name : 'city',
fieldLabel : '城市'
}, {
xtype : 'datefield',
anchor : '70%',
margin : '5 0 0 5',
name : 'startDate',
format:'Y-m-d',
editable : false,
fieldLabel : '开工时间'
},{
xtype : 'datefield',
anchor : '70%',
margin : '5 0 0 5',
name : 'endDate',
format:'Y-m-d',
editable : false,
fieldLabel : '竣工时间'
}, {
xtype : 'fieldcontainer',
height : 30,
anchor : '95%',
margin : '5 0 10 5',
style : 'text-align:center',
items : [{
xtype : 'button',
margin : '5 0 0 5',
action : 'submitProjectForm',
width: 80,
formBind : true,
text : '确认'
}, {
xtype : 'button',
margin : '5 0 0 5',
action : 'closeProjectForm',
width: 80,
text : '取消'
}]
}]
}]
});
/**
* @author reed mi
*/
Ext.define("drp.app.view.projects.SystemViewForm", {
extend : 'Ext.panel.Panel',
alias : 'widget.systemviewform',
author : '100%',
autoScroll : true,
items : [{
xtype : 'form',
items : [{
xtype : 'textfield',
hidden : true,
name : 'id'
}, {
xtype : 'textfield',
hidden : true,
itemId : 'projectId',
name : 'parentId'
}, {
xtype : 'displayfield',
margin : '5 0 0 5',
anchor : '100%',
itemId : 'projectName',
fieldLabel : '项目名称<font color="red">*</font>'
}, {
xtype : 'textfield',
anchor : '95%',
margin : '5 0 0 5',
name : 'name',
allowBlank : false,
fieldLabel : '系统名称<font color="red">*</font>'
}, {
xtype : 'textfield',
anchor : '95%',
margin : '5 0 0 5',
name : 'code',
allowBlank : false,
fieldLabel : '系统编号<font color="red">*</font>'
}, {
xtype : 'textfield',
anchor : '70%',
margin : '5 0 0 5',
name : 'city',
fieldLabel : '城市'
}, {
xtype : 'datefield',
anchor : '70%',
margin : '5 0 0 5',
name : 'startDate',
format:'Y-m-d',
editable : false,
fieldLabel : '开工时间'
},{
xtype : 'datefield',
anchor : '70%',
margin : '5 0 0 5',
name : 'endDate',
format:'Y-m-d',
editable : false,
fieldLabel : '竣工时间'
}, {
xtype : 'fieldcontainer',
height : 30,
anchor : '95%',
margin : '5 0 10 5',
style : 'text-align:center',
items : [{
xtype : 'button',
margin : '5 0 0 5',
action : 'submitSystemForm',
width: 80,
formBind : true,
text : '确认'
}, {
xtype : 'button',
margin : '5 0 0 5',
action : 'closeSystemForm',
width: 80,
text : '取消'
}]
}]
}]
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment