moved getVirtualGroups method in this library

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/custom-portal-handler@119975 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-10-22 16:27:04 +00:00
parent 6e65c3a837
commit b968e59e5a
1 changed files with 40 additions and 7 deletions

View File

@ -6,6 +6,8 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.communitymanager.PortletsIdManager; import org.gcube.portal.custom.communitymanager.PortletsIdManager;
@ -39,6 +41,8 @@ import com.liferay.portal.service.LayoutSetLocalServiceUtil;
import com.liferay.portal.service.OrganizationLocalServiceUtil; import com.liferay.portal.service.OrganizationLocalServiceUtil;
import com.liferay.portal.service.ThemeLocalServiceUtil; import com.liferay.portal.service.ThemeLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
/** /**
* *
* @author Massimiliano Assante, massimiliano.assante@isti.cnr.it * @author Massimiliano Assante, massimiliano.assante@isti.cnr.it
@ -52,10 +56,42 @@ public class OrganizationManagerImpl extends OrganizationsUtil {
* FIXME public as generic resource * FIXME public as generic resource
*/ */
protected static final String ORGANIZATION_DEFAULT_LOGO = "/org/gcube/portal/custom/communitymanager/resources/default_logo.png"; protected static final String ORGANIZATION_DEFAULT_LOGO = "/org/gcube/portal/custom/communitymanager/resources/default_logo.png";
/** private static final String CATEGORY = "Virtualgroup";
*
*/ public static List<String> getVirtualGroups() throws PortalException, SystemException {
private static OrganizationManagerImpl singleton; try {
ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(OrganizationsUtil.getCompany().getCompanyId(), Organization.class.getName());
String[] groups = (String[]) expandoBridge.getAttributeDefault("Virtualgroup");
return Arrays.asList(groups);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String getVirtualGroupName(Organization organization){
try {
long companyId = OrganizationsUtil.getCompany().getCompanyId();
_log.debug("Setting Thread Permission");
User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
_log.debug("Setting Permission ok!");
if (organization.getExpandoBridge().getAttribute(CATEGORY) == null || organization.getExpandoBridge().getAttribute(CATEGORY).equals("")) {
_log.warn(String.format("Attribute %s not initialized.", CATEGORY));
return null;
} else {
String[] values = (String[]) organization.getExpandoBridge().getAttribute(CATEGORY);
return values[0];
}
} catch (Exception e) {
e.printStackTrace();
return "Exception ";
}
}
/** /**
* *
* @param rootVoName the voName * @param rootVoName the voName
@ -63,11 +99,8 @@ public class OrganizationManagerImpl extends OrganizationsUtil {
* @return the organizationid of the created VO * @return the organizationid of the created VO
*/ */
public static long createVO(String username, String voName, String voDesc, long parentid, GCUBESiteLayout siteLayout, String themeid) { public static long createVO(String username, String voName, String voDesc, long parentid, GCUBESiteLayout siteLayout, String themeid) {
String email = "";
Group voToCreate = null; Group voToCreate = null;
try { try {
email = validateUser(username).getEmailAddress();
//create the Group //create the Group
User creator = validateUser(username); User creator = validateUser(username);
GroupManager gm = new LiferayGroupManager(); GroupManager gm = new LiferayGroupManager();