51,397
社区成员




public boolean addPsn(AddrPsn addrPsn) throws WpxServiceException {
if (addrPsn.getOwner() == null)
addrPsn.setOwner(user.toEmail());
try {
// Get Pinyin of Psn
if (addrPsn.getSpell() == null) {
String spell = Charset.utf8ToPinyin(addrPsn.getDisplayName());
addrPsn.setSpell(spell);
}
// addDao(addrPsn);
DaoAttrSet das = new DaoAttrSet();
das.put("displayName", addrPsn.getDisplayName().toLowerCase());
das.put("mail", addrPsn.getMail());
das.put("owner", addrPsn.getOwner());
addrPsn.setDisplayName(addrPsn.getDisplayName().toLowerCase());
addrPsn.setMail(addrPsn.getMail());
addrPsn.setOwner(addrPsn.getOwner());
if (getDaosList(AddrPsn.class, das).size() == 0) {
addDao(addrPsn);
return true;
} else
return false;
} catch (Exception e) {
throw new WpxServiceException(e);
}
}
这是jsp页面
<%
boolean isJson = true;
String str = request.getParameter("isJson");
String item = request.getParameter("item");
if(str!=null&&!str.equals("null")&&!str.equals("true")) isJson = false;
try {
String str2 = request.getParameter("comeGo");
AddrPsn ap = (AddrPsn) HttpRequestTools.getDao(AddrPsn.class, request, "UTF-8");
ap.setDisplayName(new String(request.getParameter("displayname").getBytes("ISO-8859-1"),"UTF-8"));
ap.setGivenName(request.getParameter("givenName"));
ap.setPhysicalDeliveryOfficeName(request.getParameter("physicaldeliveryofficename"));
ap.setFacsimiletelephonenumber(request.getParameter("facsimiletelephonenumber"));
if(null!=str2 && !str2.equals(""))
ap.setComeGo("1");
else
ap.setComeGo("0");
if(addrService.addPsn(ap)==false){
out.println(DNAJson.getResFalseJSONString("联系人已经存在!"));
//a组里有的联系人在b组里添加不了,因为报已经存在
}else{
if(isJson)
out.println(DNAJson.getResJSONString(ap));
else{
if(item==null)
out.println("<script>parent.alert('添加成功!');if(parent.g && parent.g.addToCPopWin) parent.g.addToCPopWin.closeWin(); else if(parent.addToCPopWin) parent.addToCPopWin.closeWin(); </script>");
else
out.println("<script>parent.alert('添加成功!');if(parent.g && parent.g.addToCPopWin" + item.toString() +") parent.g.addToCPopWin" + item.toString() +".closeWin(); else if(parent.addToCPopWin" + item.toString() +") parent.addToCPopWin" + item.toString() +".closeWin(); </script>");
}
}
} catch (Exception e) {
if(isJson)
out.println(DNAJson.getResJSONString(e));
else
out.println("<script>document.write(\"<span style='font-size:12px;margin-top:20px;'>" + e + "</span>\");</script>");
}
%>