added updateDescription for groups

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@128597 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-05-13 12:19:48 +00:00
parent bd8ded00e9
commit 92cb11ad2d
2 changed files with 38 additions and 3 deletions

View File

@ -199,4 +199,11 @@ public interface GroupManager {
* @throws GroupRetrievalFault
*/
void saveCustomAttr(long groupId, String attributeKey, Serializable value) throws GroupRetrievalFault;
/**
*
* @param groupId
* @param description text to update
* @return the updated description
*/
String updateGroupDescription(long groupId, String description) throws GroupRetrievalFault;
}

View File

@ -45,6 +45,7 @@ import com.liferay.portal.service.LayoutSetLocalServiceUtil;
import com.liferay.portal.service.RoleServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
@ -95,8 +96,7 @@ public class LiferayGroupManager implements GroupManager {
parentGroupId = GroupConstants.DEFAULT_PARENT_GROUP_ID;
try {
//get the userId for the default user
Company company = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
long companyId = company.getCompanyId();
final long companyId = PortalUtil.getDefaultCompanyId();
long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);
group = GroupLocalServiceUtil.addGroup(defaultUserId,
parentGroupId,
@ -516,7 +516,8 @@ public class LiferayGroupManager implements GroupManager {
e.printStackTrace();
}
return null;
}/**
}
/**
* {@inheritDoc}
*/
@Override
@ -531,6 +532,32 @@ public class LiferayGroupManager implements GroupManager {
e.printStackTrace();
}
}
/**
* {@inheritDoc}
*/
@Override
public String updateGroupDescription(long groupId, String description) throws GroupRetrievalFault {
try {
Group g = GroupLocalServiceUtil.getGroup(groupId);
Group modifiedGroup = GroupLocalServiceUtil.updateGroup(
groupId,
g.getParentGroupId(),
g.getName(),
description,
g.getType(),
g.getManualMembership(),
g.getMembershipRestriction(),
g.getFriendlyURL(),
g.isActive(),
new ServiceContext());
return modifiedGroup.getDescription();
} catch (PortalException e1) {
throw new GroupRetrievalFault("Group not existing (I think you better check)", e1);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* this method sets the Admin privileges in the local thread, needed to perform such operations.
*/
@ -574,4 +601,5 @@ public class LiferayGroupManager implements GroupManager {
private static String getCatalinaHome() {
return (System.getenv("CATALINA_HOME").endsWith("/") ? System.getenv("CATALINA_HOME") : System.getenv("CATALINA_HOME")+"/");
}
}