moved vgroup managment in usersmanagement library

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/custom-portal-handler@125712 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-03-18 11:19:40 +00:00
parent 2038dd40e2
commit 3b978891cf
1 changed files with 0 additions and 119 deletions

View File

@ -59,17 +59,6 @@ public class GCubeSiteManagerImpl extends SiteManagerUtil {
public static final String SITE_DEFAULT_LOGO = "/org/gcube/portal/custom/communitymanager/resources/default_logo.png";
public static List<String> getVirtualGroups() throws PortalException, SystemException {
try {
ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(SiteManagerUtil.getCompany().getCompanyId(), Group.class.getName());
String[] groups = (String[]) expandoBridge.getAttributeDefault(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName());
return Arrays.asList(groups);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
*
* @param rootVoName the voName
@ -231,113 +220,5 @@ public class GCubeSiteManagerImpl extends SiteManagerUtil {
siteLayout.addTab(new GCUBELayoutTab("Calendar", GCUBELayoutType.ONE_COL,
new GCUBEPortlet("Calendar", PortletsIdManager.getLRPortletId(PortletsIdManager.LR_CALENDAR)), true));
return siteLayout;
}
/***
* simple helper method
* @param inputStream
* @return
*/
private static File writeTempLogo(InputStream inputStream) {
try {
File temp = File.createTempFile("logoimage", ".png");
// write the inputStream to a FileOutputStream
FileOutputStream out = new FileOutputStream(temp);
int read = 0;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1)
out.write(bytes, 0, read);
inputStream.close();
out.flush();
out.close();
return temp;
} catch (IOException e) {
return null;
}
}
/**
* {@inheritDoc}
*/
public static Boolean readOrganizationCustomAttribute(String username, Organization currOrg, String attrToCheck) {
Boolean isEnabled = false;
if (username.compareTo("test.user") == 0) {
_log.warn("Found test.user maybe you are in dev mode, returning ... ");
return true;
}
try {
long companyId = SiteManagerUtil.getCompany().getCompanyId();
_log.trace("Setting Thread Permission");
User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
_log.trace("Setting Permission ok!");
User currentUser = SiteManagerUtil.validateUser(username);
if (currOrg.getExpandoBridge().getAttribute(attrToCheck) == null || currOrg.getExpandoBridge().getAttribute(attrToCheck).equals("")) {
_log.trace("Attribute " + attrToCheck + " must be initialized");
setOrgCustomAttribute(username, currOrg, attrToCheck);
isEnabled = true;
}
else {
String currVal = (String) currOrg.getExpandoBridge().getAttribute(attrToCheck);
isEnabled = (currVal.compareTo("true") == 0);
}
_log.trace("Setting Thread Permission back to regular");
permissionChecker = PermissionCheckerFactoryUtil.create(currentUser, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
_log.trace("Setting Permission ok! returning ...");
System.out.println(" returning *********** isEnabled=" + isEnabled);
return isEnabled;
} catch (BeanLocatorException ex) {
ex.printStackTrace();
_log.warn("Could not read the property " + attrToCheck + " from LR DB, maybe you are in dev mode, returning true");
return true;
}
catch (Exception e) {
e.printStackTrace();
return false;
}
}
/**
*
* @param username
* @param attribute2Set
*/
private static void setOrgCustomAttribute(String username, Organization currOrg, String attribute2Set) {
User currUser = null;
if (username.compareTo("test.user") == 0) {
_log.warn("Found Test User, returning ... ");
return;
}
try {
long companyId = SiteManagerUtil.getCompany().getCompanyId();
_log.trace("Setting Thread Permission");
User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
_log.trace("Setting Permission ok!");
_log.debug("Creating and Setting custom attribute for colName " + attribute2Set + " to " +true);
//add the custom attrs
currUser = UserLocalServiceUtil.getUserByScreenName(companyId, username);
if (! currOrg.getExpandoBridge().hasAttribute(attribute2Set))
currOrg.getExpandoBridge().addAttribute(attribute2Set);
currOrg.getExpandoBridge().setAttribute(attribute2Set, "true");
_log.trace("setAttribute true");
_log.trace("Setting Thread Permission back to regular");
permissionChecker = PermissionCheckerFactoryUtil.create(currUser, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
}
catch (Exception e) {
e.printStackTrace();
}
}
}