JsonMappingException, IOException {
try {
// log.debug(" "+folderName);
final Map<String, Object> sucess = new HashMap<String, Object>();
if ("create".equals(type)) {
final UnitGroupBean unitGroupBean = new UnitGroupBean();
unitGroupBean.setGroupDescription(groupDesc == null ? ""
: groupDesc);
unitGroupBean.setGroupName(groupName);
unitGroupBean.setStateId(stateId); // TODO: remove
sucess.put(
"groupBean",
getSecurityService().createGroup(unitGroupBean,
getUserPrincipalUsername()));
setItemResponse(sucess);
} else if ("update".equals(type)) {
final Group groupDomain = getSecurityService()
.getGroupbyIdandUser(groupId,
getUserPrincipalUsername());// find by group Id
// and principal
// User.
if (groupDomain != null) {
final UnitGroupBean groupBean = ConvertDomainBean
.convertGroupDomainToBean(groupDomain);
groupBean.setGroupDescription(groupDesc);
// TODO: Set state
if (!groupName.isEmpty()) {
groupBean.setGroupName(groupName);
}
getSecurityService().updateGroup(groupBean);
sucess.put("g", groupBean);
setItemResponse(sucess);
}