diff --git a/CHANGELOG.md b/CHANGELOG.md index 1042570..caab47c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements -[#21388] Integrated with new workspace to new workflow to interact with ws-thredds 1.x +[#21388] Integrated with new workflow to interact with ws-thredds 1.x ## [v6.32.0] - 2021-04-12 diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 85d7556..120bd90 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -33,6 +33,7 @@ import org.gcube.common.storagehubwrapper.shared.tohl.items.URLItem; import org.gcube.portal.wssynclibrary.shared.ItemNotSynched; import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked; import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status; +import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor; import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; @@ -77,6 +78,7 @@ import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.No import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; +import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; @@ -228,24 +230,35 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Checks if is item under sync. * - * @param itemId - * the item id + * @param itemId the item id * @return true, if is item under sync - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public Boolean isItemUnderSync(String itemId) throws Exception { + ThSyncFolderDescriptor theConfig = null; try { - GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); + try { - Sync_Status status = WorkspaceThreddsSynchronize.getInstance().getSynchedStatusFromItemProperty(itemId, - user.getUsername()); + theConfig = WorkspaceThreddsSynchronize.getInstance().getConfiguration(itemId); + } catch (WorkspaceNotSynchedException e) { + workspaceLogger + .debug("WorkspaceNotSynchedException catched, the item with id: " + itemId + " is not synched"); + return false; } catch (Exception e) { + workspaceLogger.debug("Error on getting configuration for the item id: " + itemId + + ", returning null (means not synched)"); return false; } - // HERE THE ITEM IS SYNCHED SO CHECK IF IT IS LOCKED + + if (theConfig == null) { + workspaceLogger.debug( + "No ws-thredds config found the item with id:" + itemId + ", returning item is not synched"); + return false; + } + + // HERE THE ITEM IS SYNCHED SO CHECKING IF IT IS LOCKED checkItemLocked(itemId); return false; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java index 0df5efb..79c3ace 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java @@ -3,7 +3,6 @@ */ package org.gcube.portlets.user.workspace.server.tostoragehub; - import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -34,6 +33,7 @@ import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFileVersion; import org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem; import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap; import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status; +import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor; import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.model.FileGridModel; @@ -45,21 +45,18 @@ import org.gcube.portlets.user.workspace.server.util.UserUtil; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; +import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException; import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - - - /** * The Class StorageHubToWorkpaceConverter. * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Sep 20, 2018 + * Sep 20, 2018 */ -public class StorageHubToWorkpaceConverter implements Serializable{ - +public class StorageHubToWorkpaceConverter implements Serializable { /** * @@ -71,76 +68,12 @@ public class StorageHubToWorkpaceConverter implements Serializable{ private GCubeUser loggedUser; private String workspaceRootId; - - /** * Instantiates a new storage hub to workpace converter. */ public StorageHubToWorkpaceConverter() { } - - /********************************************************************************************************************************************** - * - * - * - * - * TESTING MODE METHODS - * - * - * - * - ***********************************************************************************************************************************************/ - protected static HashMap hashTestUser = null; - /** - * Used in test mode. - * - * @return the hash test users - */ - public static HashMap getHashTestUsers(){ - - if(hashTestUser==null){ - hashTestUser = new HashMap(); - - //USERS - hashTestUser.put("federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri",null, false)); - hashTestUser.put("antonio.gioia", new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",null, false)); - hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",null, false)); - hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",null, false)); - hashTestUser.put("valentina.marioli", new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli",null, false)); - hashTestUser.put("roberto.cirillo", new InfoContactModel("roberto.cirillo", "roberto.cirillo", "Roberto Cirillo",null, false)); - hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa",null, false)); - hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante",null, false)); - - } - - return hashTestUser; - } - - - public static List buildGxtInfoContactFromPortalLoginTestMode(List listPortalLogin){ - - List listContact = new ArrayList(); - - for (String portalLogin : listPortalLogin) - listContact.add(getHashTestUsers().get(portalLogin)); - - return listContact; - } - - /********************************************************************************************************************************************** - * - * - * - * - * END TESTING MODE - * - * - * - * - ***********************************************************************************************************************************************/ - - /** * To version history. @@ -148,9 +81,9 @@ public class StorageHubToWorkpaceConverter implements Serializable{ * @param versions the versions * @return the list */ - public List toVersionHistory(List versions){ + public List toVersionHistory(List versions) { - if(versions==null || versions.isEmpty()){ + if (versions == null || versions.isEmpty()) { logger.warn("Version history is null or empty!"); return new ArrayList(); } @@ -158,18 +91,18 @@ public class StorageHubToWorkpaceConverter implements Serializable{ List listVersions = new ArrayList(versions.size()); for (WorkspaceFileVersion wsVersion : versions) { String user = UserUtil.getUserFullName(wsVersion.getOwner()); - FileVersionModel file = new FileVersionModel(wsVersion.getId(), wsVersion.getName(), wsVersion.getRemotePath(), user, FormatterUtil.toDate(wsVersion.getCreated()), wsVersion.isCurrentVersion()); + FileVersionModel file = new FileVersionModel(wsVersion.getId(), wsVersion.getName(), + wsVersion.getRemotePath(), user, FormatterUtil.toDate(wsVersion.getCreated()), + wsVersion.isCurrentVersion()); listVersions.add(file); } return listVersions; } - - /** * Instantiates a new storage hub to workpace converter. * - * @param scope the scope + * @param scope the scope * @param loggedUser the logged user */ public StorageHubToWorkpaceConverter(String scope, GCubeUser loggedUser) { @@ -177,7 +110,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{ this.loggedUser = loggedUser; } - /** * To root folder. * @@ -185,7 +117,8 @@ public class StorageHubToWorkpaceConverter implements Serializable{ * @return the folder model * @throws InternalErrorException the internal error exception */ - public FolderModel toRootFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folder) throws InternalErrorException{ + public FolderModel toRootFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folder) + throws InternalErrorException { return ObjectStorageHubToWorkpaceMapper.toRootFolder(folder); @@ -194,70 +127,63 @@ public class StorageHubToWorkpaceConverter implements Serializable{ /** * To tree file model item. * - * @param wrappedItem the wrapped item + * @param wrappedItem the wrapped item * @param parentFolderModel the parent folder model - * @param isParentShared the is parent shared + * @param isParentShared the is parent shared * @return the file model * @throws InternalErrorException the internal error exception */ - public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException{ + public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, + FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException { - FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, isParentShared); + FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, + isParentShared); return setSynchedThreddsStateFor(fileModel, wrappedItem); } - - /** * To grid file model. * - * @param wrappedItem the wrapped item + * @param wrappedItem the wrapped item * @param parentFolderModel the parent folder model * @return the file grid model * @throws InternalErrorException the internal error exception */ - public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel) throws InternalErrorException{ + public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, + FileModel parentFolderModel) throws InternalErrorException { - FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, parentFolderModel, loggedUser); + FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, + parentFolderModel, loggedUser); return (FileGridModel) setSynchedThreddsStateFor(fileGridModel, wrappedItem); } - /** * Sets the synched thredds state for. * - * @param fileModel the file model + * @param fileModel the file model * @param wrappedItem item * @return the file model */ protected FileModel setSynchedThreddsStateFor(FileModel fileModel, WorkspaceItem wrappedItem) { - + logger.debug("called setSynchedThreddsStateFor item id: " + wrappedItem.getId()); Sync_Status status = null; try { - if(wrappedItem.getPropertyMap()!=null) { - String wsSyncStatus = null; - try{ + status = WorkspaceThreddsSynchronize.getInstance().getInfo(wrappedItem.getId()); + logger.debug("item id: " + wrappedItem.getId() + " has ws-thredds sync status: " + status); + } catch (WorkspaceNotSynchedException e) { - PropertyMap map = wrappedItem.getPropertyMap(); - logger.debug("Property Map for folder: "+fileModel.getName()+" has value: "+map.getValues()); - wsSyncStatus = (String) map.getValues().get(WorkspaceThreddsSynchronize.WS_SYNCH_SYNCH_STATUS); - logger.debug("Item id: "+wrappedItem.getId()+" read from Shub has current: "+WorkspaceThreddsSynchronize.WS_SYNCH_SYNCH_STATUS +" value at: "+wsSyncStatus); - if(wsSyncStatus!=null) - status = Sync_Status.valueOf(wsSyncStatus); - }catch (Exception e) { - logger.warn(wsSyncStatus + " is not value of "+Sync_Status.values()+", returning null"); - } - } + logger.debug("WorkspaceNotSynchedException catched, the item with id: " + wrappedItem.getId() + + " is not synched"); } catch (Exception e) { - logger.warn("It is not possible to get synched status for item: "+fileModel.getIdentifier()); + logger.info( + "Error on getting configuration for the item id: " + wrappedItem.getId() + ", (means not synched)"); } fileModel.setSyncThreddsStatus(status); return fileModel; } - /** * To file trashed model. * @@ -268,21 +194,21 @@ public class StorageHubToWorkpaceConverter implements Serializable{ FileTrashedModel fileTrashModel = new FileTrashedModel(); try { - fileTrashModel.setName(trashItem.getTitle()); //ADDING THE TITLE INSTEAD OF NAME + fileTrashModel.setName(trashItem.getTitle()); // ADDING THE TITLE INSTEAD OF NAME fileTrashModel.setIdentifier(trashItem.getId()); - //SETTING PARENT + // SETTING PARENT FileModel oldParent = new FileModel(trashItem.getOriginalParentId(), "", true); fileTrashModel.setOrginalPath(trashItem.getDeletedFrom()); fileTrashModel.setParentFileModel(oldParent); - // - // //SETTING DELETED BY + // + // //SETTING DELETED BY InfoContactModel deleteUser = buildGxtInfoContactFromPortalLogin(trashItem.getDeletedBy()); fileTrashModel.setDeleteUser(deleteUser); - //SETTING MIME TYPE + // SETTING MIME TYPE // String mimeType = ""; // if(trashItem instanceof FileItem){ @@ -290,24 +216,26 @@ public class StorageHubToWorkpaceConverter implements Serializable{ // mimeType = fileItem.getMimeType(); // } - String mimeType = trashItem.getMimeType()!=null?trashItem.getMimeType():""; + String mimeType = trashItem.getMimeType() != null ? trashItem.getMimeType() : ""; fileTrashModel.setType(mimeType); - //SETTING IS DIRECTORY + // SETTING IS DIRECTORY fileTrashModel.setIsDirectory(trashItem.isFolder()); - //SETTING DELETE DATE + // SETTING DELETE DATE fileTrashModel.setDeleteDate(FormatterUtil.toDate(trashItem.getDeletedTime())); fileTrashModel.setShared(trashItem.isShared()); - logger.debug("Converting return trash item: "+fileTrashModel.getName() +" id: "+fileTrashModel.getIdentifier()); + logger.debug("Converting return trash item: " + fileTrashModel.getName() + " id: " + + fileTrashModel.getIdentifier()); - logger.trace("Returning trash item: "+fileTrashModel); + logger.trace("Returning trash item: " + fileTrashModel); - }catch (Exception e) { + } catch (Exception e) { - logger.debug("Error into toFileTrashedModel for item: "+fileTrashModel.getName() +" id: "+fileTrashModel.getIdentifier()); + logger.debug("Error into toFileTrashedModel for item: " + fileTrashModel.getName() + " id: " + + fileTrashModel.getIdentifier()); return null; } @@ -315,94 +243,99 @@ public class StorageHubToWorkpaceConverter implements Serializable{ return fileTrashModel; } - - + /** * Builds the gxt info contact from portal login. * * @param portalLogin the portal login * @return the info contact model */ - public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){ + public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) { - if(portalLogin==null){ + if (portalLogin == null) { logger.warn("portal login is null, return empty"); portalLogin = ""; } GCubeUser theUser = null; try { theUser = UserUtil.getUserByUsername(portalLogin); - }catch (Exception e) { + } catch (Exception e) { logger.warn("Error on retrieving user information, so using the portal login"); } String fullName = null; String emailDomain = null; - if(theUser!=null) { + if (theUser != null) { fullName = theUser.getFullname(); emailDomain = theUser.getEmail(); } - return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain,false); + return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain, false); } - + /** - * TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS WORKSPACESPECIALFOLDER**** - * REMOVE THIS METHOD AND ADDING INSTANCE OF AT buildGXTFolderModelItem. + * TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS + * WORKSPACESPECIALFOLDER**** REMOVE THIS METHOD AND ADDING INSTANCE OF AT + * buildGXTFolderModelItem. * - * @param wsFolder the ws folder - * @param parent the parent + * @param wsFolder the ws folder + * @param parent the parent * @param specialFolderName the special folder name * @return the folder model * @throws InternalErrorException the internal error exception */ - public FolderModel buildGXTFolderModelItemHandleSpecialFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsFolder, org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent, String specialFolderName) throws InternalErrorException { + public FolderModel buildGXTFolderModelItemHandleSpecialFolder( + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsFolder, + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent, String specialFolderName) + throws InternalErrorException { String name = ""; - logger.debug("buildGXTFolderModelItemHandleSpecialFolder to folder: "+wsFolder.getName()); - if(logger.isTraceEnabled()) { - logger.trace("buildGXTFolderModelItemHandleSpecialFolder has parent: "+parent); + logger.debug("buildGXTFolderModelItemHandleSpecialFolder to folder: " + wsFolder.getName()); + if (logger.isTraceEnabled()) { + logger.trace("buildGXTFolderModelItemHandleSpecialFolder has parent: " + parent); } - //MANAGEMENT SHARED FOLDER NAME - if(wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)){ + // MANAGEMENT SHARED FOLDER NAME + if (wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)) { logger.debug("MANAGEMENT SHARED Folder name.."); WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wsFolder; - logger.debug("shared.isVreFolder(): "+shared.isVreFolder()); - //name = shared.isVreFolder()?shared.getName():wsFolder.getName(); + logger.debug("shared.isVreFolder(): " + shared.isVreFolder()); + // name = shared.isVreFolder()?shared.getName():wsFolder.getName(); name = shared.getName(); - //MANAGEMENT SPECIAL FOLDER - }else if(wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS)==0 && parent!=null && parent.isRoot()){ - //MANAGEMENT SPECIAL FOLDER - logger.debug("MANAGEMENT SPECIAL FOLDER NAME REWRITING AS: "+specialFolderName); - if(specialFolderName!=null && !specialFolderName.isEmpty()) + // MANAGEMENT SPECIAL FOLDER + } else if (wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS) == 0 && parent != null + && parent.isRoot()) { + // MANAGEMENT SPECIAL FOLDER + logger.debug("MANAGEMENT SPECIAL FOLDER NAME REWRITING AS: " + specialFolderName); + if (specialFolderName != null && !specialFolderName.isEmpty()) name = specialFolderName; else name = wsFolder.getName(); - }else{ + } else { logger.debug("MANAGEMENT Base Folder name.."); name = wsFolder.getName(); } - logger.debug("Name is: "+name); - boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder).isPublicFolder(); //TODO + logger.debug("Name is: " + name); + boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder) + .isPublicFolder(); // TODO FileModel parentModel = null; - if(parent!=null) + if (parent != null) parentModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(parent, null, parent.isShared()); - - FolderModel folder = new FolderModel(wsFolder.getId(), name, parentModel, true, wsFolder.isShared(), false, isPublicDir); + + FolderModel folder = new FolderModel(wsFolder.getId(), name, parentModel, true, wsFolder.isShared(), false, + isPublicDir); folder.setShareable(true); folder.setIsRoot(wsFolder.isRoot()); folder.setDescription(wsFolder.getDescription()); - // folder.setOwner(wsFolder.getOwner()); + // folder.setOwner(wsFolder.getOwner()); - if(parent != null && parent.isShared()){ + if (parent != null && parent.isShared()) { folder.setShared(true); folder.setShareable(false); } return folder; } - /** * Gets the workspace root id. * @@ -413,7 +346,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{ return workspaceRootId; } - /** * Sets the workspace root id. * @@ -423,8 +355,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{ this.workspaceRootId = workspaceRootId; } - - /** * To simple map. @@ -440,7 +370,7 @@ public class StorageHubToWorkpaceConverter implements Serializable{ try { Map properties = null; Map map = propertyMap.getValues(); - + if (map != null) { properties = new HashMap(map.size()); for (String key : map.keySet()) { @@ -448,43 +378,43 @@ public class StorageHubToWorkpaceConverter implements Serializable{ properties.put(key, (String) theValue); } } - - if(properties!=null) - logger.error("Converted: "+properties.size()+" property/properties"); - + + if (properties != null) + logger.error("Converted: " + properties.size() + " property/properties"); + return properties; } catch (Exception e) { logger.error("Error on converting a PropertyMap to simple Map: ", e); return null; } } - /** * Builds the GXT accounting item. * - * @param accoutings the accoutings + * @param accoutings the accoutings * @param gxtEntryType the gxt entry type * @return the list */ - public List buildGXTAccountingItem(List accoutings, GxtAccountingEntryType gxtEntryType) { + public List buildGXTAccountingItem(List accoutings, + GxtAccountingEntryType gxtEntryType) { List listAccFields = new ArrayList(); - if(accoutings!=null){ - logger.trace("accouting entry/entrie is/are "+accoutings.size()+ ", converting it/them..."); + if (accoutings != null) { + logger.trace("accouting entry/entrie is/are " + accoutings.size() + ", converting it/them..."); for (AccountEntry shubAccEntry : accoutings) { GxtAccountingField af = new GxtAccountingField(); - + String theUser = shubAccEntry.getUser(); InfoContactModel user = null; - //Ignoring get user details from Liferay in case of user equal to 'ALL' - if(theUser!=null && !theUser.equalsIgnoreCase("ALL")){ + // Ignoring get user details from Liferay in case of user equal to 'ALL' + if (theUser != null && !theUser.equalsIgnoreCase("ALL")) { user = buildGxtInfoContactFromPortalLogin(shubAccEntry.getUser()); } - + af.setUser(user); af.setDate(FormatterUtil.toDate(shubAccEntry.getDate())); @@ -492,20 +422,25 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case CREATE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CREATE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.CREATE)) { AccountEntryCreate create = (AccountEntryCreate) shubAccEntry; af.setOperation(GxtAccountingEntryType.CREATE); - // af.setDescription(GxtAccountingEntryType.CREATE.getName() + " by "+user.getName()); + // af.setDescription(GxtAccountingEntryType.CREATE.getName() + " by + // "+user.getName()); String msg = ""; - if(create.getItemName()==null || create.getItemName().isEmpty()) - msg = GxtAccountingEntryType.CREATE.getId() + " by "+user.getName(); - else{ + if (create.getItemName() == null || create.getItemName().isEmpty()) + msg = GxtAccountingEntryType.CREATE.getId() + " by " + user.getName(); + else { - if(create.getVersion()==null) - msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by "+user.getName(); + if (create.getVersion() == null) + msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by " + + user.getName(); else - msg = create.getItemName() + " v. "+create.getVersion()+" "+ GxtAccountingEntryType.CREATE.getName() + " by "+user.getName(); + msg = create.getItemName() + " v. " + create.getVersion() + " " + + GxtAccountingEntryType.CREATE.getName() + " by " + user.getName(); } af.setDescription(msg); @@ -515,21 +450,25 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case READ: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.READ)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.READ)) { AccountEntryRead read = (AccountEntryRead) shubAccEntry; af.setOperation(GxtAccountingEntryType.READ); - af.setDescription(read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName()); + af.setDescription(read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by " + + user.getName()); String msg = ""; - if(read.getItemName()==null || read.getItemName().isEmpty()) - msg = GxtAccountingEntryType.READ.getId() + " by "+user.getName(); - else{ + if (read.getItemName() == null || read.getItemName().isEmpty()) + msg = GxtAccountingEntryType.READ.getId() + " by " + user.getName(); + else { - if(read.getVersion()==null) - msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + if (read.getVersion() == null) + msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by " + + user.getName(); else - msg = read.getItemName() + " v."+read.getVersion() +" "+ GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + msg = read.getItemName() + " v." + read.getVersion() + " " + + GxtAccountingEntryType.READ.getName() + " by " + user.getName(); } af.setDescription(msg); @@ -539,27 +478,33 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case CUT: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CUT)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.CUT)) { af.setOperation(GxtAccountingEntryType.CUT); - - if(shubAccEntry instanceof AccountFolderEntryCut) { - + + if (shubAccEntry instanceof AccountFolderEntryCut) { + AccountFolderEntryCut cut = (AccountFolderEntryCut) shubAccEntry; - + String msg = ""; - if(cut.getItemName()==null || cut.getItemName().isEmpty()) - msg = GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); - else{ - if(cut.getVersion()==null) - msg = cut.getItemName()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); + if (cut.getItemName() == null || cut.getItemName().isEmpty()) + msg = GxtAccountingEntryType.CUT.getName() + " by " + user.getName(); + else { + if (cut.getVersion() == null) + msg = cut.getItemName() + " " + GxtAccountingEntryType.CUT.getName() + " by " + + user.getName(); else - msg = cut.getItemName()+" v."+cut.getVersion()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); + msg = cut.getItemName() + " v." + cut.getVersion() + " " + + GxtAccountingEntryType.CUT.getName() + " by " + user.getName(); } - + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryCut.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryCut.class.getSimpleName()); } } @@ -567,91 +512,118 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case PASTE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.PASTE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.PASTE)) { af.setOperation(GxtAccountingEntryType.PASTE); AccountEntryPaste paste = (AccountEntryPaste) shubAccEntry; - if(paste.getVersion()==null) - af.setDescription(GxtAccountingEntryType.PASTE.getName() + " from "+paste.getFromPath()+" by "+user.getName()); + if (paste.getVersion() == null) + af.setDescription(GxtAccountingEntryType.PASTE.getName() + " from " + paste.getFromPath() + + " by " + user.getName()); else - af.setDescription(GxtAccountingEntryType.PASTE.getName() + " v. "+paste.getVersion()+" from "+paste.getFromPath()+" by "+user.getName()); + af.setDescription(GxtAccountingEntryType.PASTE.getName() + " v. " + paste.getVersion() + + " from " + paste.getFromPath() + " by " + user.getName()); } break; case REMOVAL: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)){ - - if(shubAccEntry instanceof AccountFolderEntryRemoval) { + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)) { + + if (shubAccEntry instanceof AccountFolderEntryRemoval) { af.setOperation(GxtAccountingEntryType.REMOVE); AccountFolderEntryRemoval rem = (AccountFolderEntryRemoval) shubAccEntry; - String msg = rem.getItemName()==null || rem.getItemName().isEmpty()?"":rem.getItemName()+" "; - - if(rem.getVersion()==null) - msg+= GxtAccountingEntryType.REMOVE.getName() +" by "+user.getName(); + String msg = rem.getItemName() == null || rem.getItemName().isEmpty() ? "" + : rem.getItemName() + " "; + + if (rem.getVersion() == null) + msg += GxtAccountingEntryType.REMOVE.getName() + " by " + user.getName(); else - msg+= GxtAccountingEntryType.REMOVE.getName() +" v."+rem.getVersion()+" by "+user.getName(); - + msg += GxtAccountingEntryType.REMOVE.getName() + " v." + rem.getVersion() + " by " + + user.getName(); + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryRemoval.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryRemoval.class.getSimpleName()); } } break; case RENAMING: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RENAME)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.RENAME)) { - if(shubAccEntry instanceof AccountFolderEntryRenaming) { + if (shubAccEntry instanceof AccountFolderEntryRenaming) { af.setOperation(GxtAccountingEntryType.RENAME); AccountFolderEntryRenaming ren = (AccountFolderEntryRenaming) shubAccEntry; - String msg = ren.getOldItemName()==null || ren.getOldItemName().isEmpty()?"":ren.getOldItemName()+" "; - if(ren.getVersion()==null) - msg+= GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName(); + String msg = ren.getOldItemName() == null || ren.getOldItemName().isEmpty() ? "" + : ren.getOldItemName() + " "; + if (ren.getVersion() == null) + msg += GxtAccountingEntryType.RENAME.getName() + " to " + ren.getNewItemName() + " by " + + user.getName(); else - msg+= " v."+ren.getVersion() +" "+GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName(); - + msg += " v." + ren.getVersion() + " " + GxtAccountingEntryType.RENAME.getName() + " to " + + ren.getNewItemName() + " by " + user.getName(); + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryRenaming.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryRenaming.class.getSimpleName()); } } break; case ADD: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ADD)){ - - if(shubAccEntry instanceof AccountFolderEntryAdd) { + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.ADD)) { + + if (shubAccEntry instanceof AccountFolderEntryAdd) { af.setOperation(GxtAccountingEntryType.ADD); AccountFolderEntryAdd acc = (AccountFolderEntryAdd) shubAccEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - if(acc.getVersion()==null) - msg+=GxtAccountingEntryType.ADD.getName()+ " by "+user.getName(); + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; + if (acc.getVersion() == null) + msg += GxtAccountingEntryType.ADD.getName() + " by " + user.getName(); else - msg+=" v."+acc.getVersion()+ " "+GxtAccountingEntryType.ADD.getName()+ " by "+user.getName(); - + msg += " v." + acc.getVersion() + " " + GxtAccountingEntryType.ADD.getName() + " by " + + user.getName(); + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryAdd.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryAdd.class.getSimpleName()); } } break; case UPDATE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UPDATE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.UPDATE)) { af.setOperation(GxtAccountingEntryType.UPDATE); AccountEntryUpdate upd = (AccountEntryUpdate) shubAccEntry; - String msg = upd.getItemName()==null || upd.getItemName().isEmpty()?"":upd.getItemName()+" "; - if(upd.getVersion()==null) - msg+=GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName(); + String msg = upd.getItemName() == null || upd.getItemName().isEmpty() ? "" + : upd.getItemName() + " "; + if (upd.getVersion() == null) + msg += GxtAccountingEntryType.UPDATE.getName() + " by " + user.getName(); else - msg+=" v."+upd.getVersion()+" "+GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName(); + msg += " v." + upd.getVersion() + " " + GxtAccountingEntryType.UPDATE.getName() + " by " + + user.getName(); af.setDescription(msg); } @@ -659,20 +631,24 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case SHARE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.SHARE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.SHARE)) { af.setOperation(GxtAccountingEntryType.SHARE); AccountEntryShare acc = (AccountEntryShare) shubAccEntry; String msg = ""; - if(acc.getItemName()==null || acc.getItemName().isEmpty()) - msg = "\""+user.getName() + "\" "+GxtAccountingEntryType.SHARE.getName()+ " folder"; + if (acc.getItemName() == null || acc.getItemName().isEmpty()) + msg = "\"" + user.getName() + "\" " + GxtAccountingEntryType.SHARE.getName() + " folder"; else - msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " folder "+acc.getItemName(); + msg = user.getName() + " " + GxtAccountingEntryType.SHARE.getName() + " folder " + + acc.getItemName(); - if(acc.getMembers()!=null && acc.getMembers().length>0) - msg+=" with "+UserUtil.separateFullNameToCommaForPortalLogin(Arrays.asList(acc.getMembers())); + if (acc.getMembers() != null && acc.getMembers().length > 0) + msg += " with " + + UserUtil.separateFullNameToCommaForPortalLogin(Arrays.asList(acc.getMembers())); af.setDescription(msg); } @@ -680,19 +656,22 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case UNSHARE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UNSHARE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.UNSHARE)) { af.setOperation(GxtAccountingEntryType.UNSHARE); AccountEntryUnshare uns = (AccountEntryUnshare) shubAccEntry; String msg = "Folder "; - msg+= uns.getItemName()==null || uns.getItemName().isEmpty()?"":"\""+uns.getItemName()+"\" "; - //see Task #19544 - if(shubAccEntry.getUser().equalsIgnoreCase("ALL")) { - //CASE ALL - msg= "The folder is no longer shared with others"; + msg += uns.getItemName() == null || uns.getItemName().isEmpty() ? "" + : "\"" + uns.getItemName() + "\" "; + // see Task #19544 + if (shubAccEntry.getUser().equalsIgnoreCase("ALL")) { + // CASE ALL + msg = "The folder is no longer shared with others"; user = new InfoContactModel(theUser, "n.a.", "n.a.", null, false); - }else { - msg+= "is no longer shared with "+user.getName(); + } else { + msg += "is no longer shared with " + user.getName(); user = new InfoContactModel(theUser, "Owner / Admin", "Owner / Admin", null, false); } af.setUser(user); @@ -702,16 +681,20 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case RESTORE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RESTORE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.RESTORE)) { af.setOperation(GxtAccountingEntryType.RESTORE); AccountEntryRestore acc = (AccountEntryRestore) shubAccEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; - if(acc.getVersion()==null) - msg+=GxtAccountingEntryType.RESTORE.getName()+" by "+user.getName(); + if (acc.getVersion() == null) + msg += GxtAccountingEntryType.RESTORE.getName() + " by " + user.getName(); else - msg+=" v."+acc.getVersion()+" "+GxtAccountingEntryType.RESTORE.getName() +" by "+user.getName(); + msg += " v." + acc.getVersion() + " " + GxtAccountingEntryType.RESTORE.getName() + " by " + + user.getName(); af.setDescription(msg); } @@ -719,13 +702,16 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case DISABLED_PUBLIC_ACCESS: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)) { af.setOperation(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS); AccountEntryDisabledPublicAccess acc = (AccountEntryDisabledPublicAccess) shubAccEntry; - //TODO acc.getItemName() is missing in SHUB - //String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - String msg=GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName()+" by "+user.getName(); + // TODO acc.getItemName() is missing in SHUB + // String msg = acc.getItemName()==null || + // acc.getItemName().isEmpty()?"":acc.getItemName()+" "; + String msg = GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName() + " by " + user.getName(); af.setDescription(msg); } @@ -733,13 +719,16 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case ENABLED_PUBLIC_ACCESS: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)) { af.setOperation(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS); AccountEntryEnabledPublicAccess acc = (AccountEntryEnabledPublicAccess) shubAccEntry; - //TODO acc.getItemName() is missing in SHUB - //String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - String msg=GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName()+" by "+user.getName(); + // TODO acc.getItemName() is missing in SHUB + // String msg = acc.getItemName()==null || + // acc.getItemName().isEmpty()?"":acc.getItemName()+" "; + String msg = GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName() + " by " + user.getName(); af.setDescription(msg); } @@ -753,13 +742,12 @@ public class StorageHubToWorkpaceConverter implements Serializable{ listAccFields.add(af); } } - logger.debug("get accounting readers converting completed - returning size "+listAccFields.size()); + logger.debug("get accounting readers converting completed - returning size " + listAccFields.size()); return listAccFields; } - /** * Gets the gcube item properties for gcube item as HTML. * @@ -768,37 +756,35 @@ public class StorageHubToWorkpaceConverter implements Serializable{ */ public String getGcubeItemPropertiesForGcubeItemAsHTML(WorkspaceItem wsItem) { - Map properties = getGcubeItemProperties(wsItem); - - if(properties!=null){ - - if(properties.size()==0){ - logger.warn("Map of Gcube Item Properties is empty for item: "+wsItem.getId()); + + if (properties != null) { + + if (properties.size() == 0) { + logger.warn("Map of Gcube Item Properties is empty for item: " + wsItem.getId()); return null; } - + String html = "
"; - + for (String key : properties.keySet()) { String value = properties.get(key); - logger.trace("Getting property: ["+key+","+properties.get(key)+"]"); - html+=""+key+": "; - html+=""; - html+=value; - html+="
"; + logger.trace("Getting property: [" + key + "," + properties.get(key) + "]"); + html += "" + key + ": "; + html += ""; + html += value; + html += "
"; } - - html+="
"; - + + html += ""; + return html; - }else { - logger.warn("Gcube Item Properties not found for item: "+wsItem.getId()); + } else { + logger.warn("Gcube Item Properties not found for item: " + wsItem.getId()); return null; } } - /** * Gets the gcube item properties. * @@ -807,10 +793,10 @@ public class StorageHubToWorkpaceConverter implements Serializable{ */ public Map getGcubeItemProperties(WorkspaceItem wsItem) { - if(wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem){ + if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem) { GCubeItem gItem = (GCubeItem) wsItem; try { - if(gItem.getProperties()!=null){ + if (gItem.getProperties() != null) { PropertyMap map = gItem.getProperty(); return toSimpleMap(map); } @@ -820,6 +806,75 @@ public class StorageHubToWorkpaceConverter implements Serializable{ } } return null; - + } + + /********************************************************************************************************************************************** + * + * + * + * + * TESTING MODE METHODS + * + * + * + * + ***********************************************************************************************************************************************/ + protected static HashMap hashTestUser = null; + + /** + * Used in test mode. + * + * @return the hash test users + */ + public static HashMap getHashTestUsers() { + + if (hashTestUser == null) { + hashTestUser = new HashMap(); + + // USERS + hashTestUser.put("federico.defaveri", + new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri", null, false)); + hashTestUser.put("antonio.gioia", + new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", null, false)); + hashTestUser.put("fabio.sinibaldi", + new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi", null, false)); + hashTestUser.put("pasquale.pagano", + new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano", null, false)); + hashTestUser.put("valentina.marioli", + new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli", null, false)); + hashTestUser.put("roberto.cirillo", + new InfoContactModel("roberto.cirillo", "roberto.cirillo", "Roberto Cirillo", null, false)); + hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", + "francesco.mangiacrapa", "Francesco Mangiacrapa", null, false)); + hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", + "massimiliano.assante", "Massimiliano Assante", null, false)); + + } + + return hashTestUser; + } + + public static List buildGxtInfoContactFromPortalLoginTestMode(List listPortalLogin) { + + List listContact = new ArrayList(); + + for (String portalLogin : listPortalLogin) + listContact.add(getHashTestUsers().get(portalLogin)); + + return listContact; + } + + /********************************************************************************************************************************************** + * + * + * + * + * END TESTING MODE + * + * + * + * + ***********************************************************************************************************************************************/ + }