|
|
|
@ -20,10 +20,23 @@ import com.liferay.portal.kernel.log.Log;
|
|
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The Class StorageHubServiceUtil.
|
|
|
|
|
*
|
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
|
*
|
|
|
|
|
* Apr 9, 2019
|
|
|
|
|
*/
|
|
|
|
|
public class StorageHubServiceUtil {
|
|
|
|
|
private static Log _log = LogFactoryUtil.getLog(StorageHubServiceUtil.class);
|
|
|
|
|
public static final String ACCOUNTING_HL_NODE_NAME = "hl:accounting";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the root.
|
|
|
|
|
*
|
|
|
|
|
* @param request the request
|
|
|
|
|
* @return the root
|
|
|
|
|
*/
|
|
|
|
|
public static Item getRoot(HttpServletRequest request) {
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(request).getUsername();
|
|
|
|
@ -35,8 +48,44 @@ public class StorageHubServiceUtil {
|
|
|
|
|
Item itemRoot = client.getWorkspace(ACCOUNTING_HL_NODE_NAME);
|
|
|
|
|
return itemRoot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * Gets the notification manager to storage hub.
|
|
|
|
|
// *
|
|
|
|
|
// * @param httpServletRequest the http servlet request
|
|
|
|
|
// * @return the notification manager to storage hub
|
|
|
|
|
// */
|
|
|
|
|
// public static NotificationsManager getNotificationManagerToStorageHub(HttpServletRequest httpServletRequest)
|
|
|
|
|
// {
|
|
|
|
|
// PortalContextInfo info = getPortalContext(httpServletRequest);
|
|
|
|
|
// HttpSession session = httpServletRequest.getSession();
|
|
|
|
|
// NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB);
|
|
|
|
|
//
|
|
|
|
|
// if (notifMng == null) {
|
|
|
|
|
// try{
|
|
|
|
|
// logger.trace("Create new NotificationsManager for user: "+info.getUsername());
|
|
|
|
|
// logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
|
|
|
|
// SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
|
|
|
|
|
// SocialNetworkingUser curser = new SocialNetworkingUser(info.getUsername(), info.getUserEmail(), info.getUserFullName(), info.getUserAvatarID());
|
|
|
|
|
// notifMng = new ApplicationNotificationsManager(site, info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
|
|
|
|
// session.setAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB, notifMng);
|
|
|
|
|
// }catch (Exception e) {
|
|
|
|
|
// logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+info.getUsername(),e);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return notifMng;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public static Item getItem(HttpServletRequest request, String itemId) {
|
|
|
|
|
/**
|
|
|
|
|
* Gets the item.
|
|
|
|
|
*
|
|
|
|
|
* @param request the request
|
|
|
|
|
* @param itemId the item id
|
|
|
|
|
* @return the item
|
|
|
|
|
* @throws Exception the exception
|
|
|
|
|
*/
|
|
|
|
|
public static Item getItem(HttpServletRequest request, String itemId) throws Exception {
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(request).getUsername();
|
|
|
|
|
String scope = pContext.getCurrentScope(request);
|
|
|
|
@ -48,7 +97,15 @@ public class StorageHubServiceUtil {
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<? extends Item> getParents(HttpServletRequest request, String itemId) {
|
|
|
|
|
/**
|
|
|
|
|
* Gets the parents.
|
|
|
|
|
*
|
|
|
|
|
* @param request the request
|
|
|
|
|
* @param itemId the item id
|
|
|
|
|
* @return the parents
|
|
|
|
|
* @throws Exception the exception
|
|
|
|
|
*/
|
|
|
|
|
public static List<? extends Item> getParents(HttpServletRequest request, String itemId) throws Exception {
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(request).getUsername();
|
|
|
|
|
String scope = pContext.getCurrentScope(request);
|
|
|
|
@ -60,7 +117,17 @@ public class StorageHubServiceUtil {
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FolderItem createFolder(HttpServletRequest request, String parentId, String name, String description) {
|
|
|
|
|
/**
|
|
|
|
|
* Creates the folder.
|
|
|
|
|
*
|
|
|
|
|
* @param request the request
|
|
|
|
|
* @param parentId the parent id
|
|
|
|
|
* @param name the name
|
|
|
|
|
* @param description the description
|
|
|
|
|
* @return the folder item
|
|
|
|
|
* @throws Exception the exception
|
|
|
|
|
*/
|
|
|
|
|
public static FolderItem createFolder(HttpServletRequest request, String parentId, String name, String description) throws Exception {
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(request).getUsername();
|
|
|
|
|
String scope = pContext.getCurrentScope(request);
|
|
|
|
@ -73,8 +140,9 @@ public class StorageHubServiceUtil {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the VRE folders id.
|
|
|
|
|
*
|
|
|
|
|
* @param request
|
|
|
|
|
* @param request the request
|
|
|
|
|
* @return the VRE Folders Id
|
|
|
|
|
*/
|
|
|
|
|
public static String getVREFoldersId(HttpServletRequest request) {
|
|
|
|
@ -101,7 +169,15 @@ public class StorageHubServiceUtil {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getUserACLForFolderId(HttpServletRequest request, String folderId) {
|
|
|
|
|
/**
|
|
|
|
|
* Gets the user ACL for folder id.
|
|
|
|
|
*
|
|
|
|
|
* @param request the request
|
|
|
|
|
* @param folderId the folder id
|
|
|
|
|
* @return the user ACL for folder id
|
|
|
|
|
* @throws Exception the exception
|
|
|
|
|
*/
|
|
|
|
|
public static String getUserACLForFolderId(HttpServletRequest request, String folderId) throws Exception {
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(request).getUsername();
|
|
|
|
|
String scope = pContext.getCurrentScope(request);
|
|
|
|
@ -151,11 +227,15 @@ public class StorageHubServiceUtil {
|
|
|
|
|
return "UNDEFINED";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the item children count.
|
|
|
|
|
*
|
|
|
|
|
* @param request the request
|
|
|
|
|
* @param itemId the item id
|
|
|
|
|
* @return the item children count
|
|
|
|
|
* @throws Exception the exception
|
|
|
|
|
*/
|
|
|
|
|
public static int getItemChildrenCount(HttpServletRequest request, String itemId) {
|
|
|
|
|
public static int getItemChildrenCount(HttpServletRequest request, String itemId) throws Exception {
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(request).getUsername();
|
|
|
|
|
String scope = pContext.getCurrentScope(request);
|
|
|
|
|