in progress on #21388

This commit is contained in:
Francesco Mangiacrapa 2021-05-12 16:33:37 +02:00
parent fd6d1570e8
commit cc17be1761
3 changed files with 366 additions and 298 deletions

View File

@ -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

View File

@ -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;

View File

@ -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,13 +45,11 @@ 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.
*
@ -60,7 +58,6 @@ import org.slf4j.LoggerFactory;
*/
public class StorageHubToWorkpaceConverter implements Serializable {
/**
*
*/
@ -71,8 +68,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
private GCubeUser loggedUser;
private String workspaceRootId;
/**
* Instantiates a new storage hub to workpace converter.
*/
@ -80,68 +75,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
/**********************************************************************************************************************************************
*
*
*
*
* TESTING MODE METHODS
*
*
*
*
***********************************************************************************************************************************************/
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/**
* Used in test mode.
*
* @return the hash test users
*/
public static HashMap<String, InfoContactModel> getHashTestUsers(){
if(hashTestUser==null){
hashTestUser = new HashMap<String, InfoContactModel>();
//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<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin){
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin)
listContact.add(getHashTestUsers().get(portalLogin));
return listContact;
}
/**********************************************************************************************************************************************
*
*
*
*
* END TESTING MODE
*
*
*
*
***********************************************************************************************************************************************/
/**
* To version history.
*
@ -158,14 +91,14 @@ public class StorageHubToWorkpaceConverter implements Serializable{
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(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.
*
@ -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);
@ -200,14 +133,14 @@ public class StorageHubToWorkpaceConverter implements Serializable{
* @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.
*
@ -216,13 +149,14 @@ public class StorageHubToWorkpaceConverter implements Serializable{
* @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.
*
@ -231,33 +165,25 @@ public class StorageHubToWorkpaceConverter implements Serializable{
* @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);
logger.debug("WorkspaceNotSynchedException catched, the item with id: " + wrappedItem.getId()
+ " is not synched");
} catch (Exception e) {
logger.warn(wsSyncStatus + " is not value of "+Sync_Status.values()+", returning null");
}
}
} 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.
*
@ -301,13 +227,15 @@ public class StorageHubToWorkpaceConverter implements Serializable{
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);
} 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;
}
@ -316,7 +244,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
/**
* Builds the gxt info contact from portal login.
*
@ -345,8 +272,9 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
/**
* 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
@ -354,7 +282,10 @@ public class StorageHubToWorkpaceConverter implements Serializable{
* @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 = "";
@ -371,7 +302,8 @@ public class StorageHubToWorkpaceConverter implements Serializable{
name = shared.getName();
// MANAGEMENT SPECIAL FOLDER
}else if(wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS)==0 && parent!=null && parent.isRoot()){
} 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())
@ -384,12 +316,14 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
logger.debug("Name is: " + name);
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder).isPublicFolder(); //TODO
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder)
.isPublicFolder(); // TODO
FileModel parentModel = 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());
@ -402,7 +336,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
return folder;
}
/**
* Gets the workspace root id.
*
@ -413,7 +346,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
return workspaceRootId;
}
/**
* Sets the workspace root id.
*
@ -424,8 +356,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
this.workspaceRootId = workspaceRootId;
}
/**
* To simple map.
*
@ -459,7 +389,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
}
/**
* Builds the GXT accounting item.
*
@ -467,7 +396,8 @@ public class StorageHubToWorkpaceConverter implements Serializable{
* @param gxtEntryType the gxt entry type
* @return the list
*/
public List<GxtAccountingField> buildGXTAccountingItem(List<AccountEntry> accoutings, GxtAccountingEntryType gxtEntryType) {
public List<GxtAccountingField> buildGXTAccountingItem(List<AccountEntry> accoutings,
GxtAccountingEntryType gxtEntryType) {
List<GxtAccountingField> listAccFields = new ArrayList<GxtAccountingField>();
@ -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.getVersion() == null)
msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by "+user.getName();
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,11 +450,13 @@ 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())
@ -527,9 +464,11 @@ public class StorageHubToWorkpaceConverter implements Serializable{
else {
if (read.getVersion() == null)
msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName();
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,7 +478,9 @@ 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);
@ -552,14 +493,18 @@ public class StorageHubToWorkpaceConverter implements Serializable{
msg = GxtAccountingEntryType.CUT.getName() + " by " + user.getName();
else {
if (cut.getVersion() == null)
msg = cut.getItemName()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName();
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());
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());
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 (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()+" ";
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());
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) {
af.setOperation(GxtAccountingEntryType.RENAME);
AccountFolderEntryRenaming ren = (AccountFolderEntryRenaming) shubAccEntry;
String msg = ren.getOldItemName()==null || ren.getOldItemName().isEmpty()?"":ren.getOldItemName()+" ";
String msg = ren.getOldItemName() == null || ren.getOldItemName().isEmpty() ? ""
: ren.getOldItemName() + " ";
if (ren.getVersion() == null)
msg+= GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName();
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());
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 (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()+" ";
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());
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()+" ";
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,7 +631,9 @@ 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);
@ -669,10 +643,12 @@ public class StorageHubToWorkpaceConverter implements Serializable{
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()));
msg += " with "
+ UserUtil.separateFullNameToCommaForPortalLogin(Arrays.asList(acc.getMembers()));
af.setDescription(msg);
}
@ -680,12 +656,15 @@ 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()+"\" ";
msg += uns.getItemName() == null || uns.getItemName().isEmpty() ? ""
: "\"" + uns.getItemName() + "\" ";
// see Task #19544
if (shubAccEntry.getUser().equalsIgnoreCase("ALL")) {
// CASE ALL
@ -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();
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,12 +702,15 @@ 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 = acc.getItemName()==null ||
// acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
String msg = GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName() + " by " + user.getName();
af.setDescription(msg);
}
@ -733,12 +719,15 @@ 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 = acc.getItemName()==null ||
// acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
String msg = GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName() + " by " + user.getName();
af.setDescription(msg);
}
@ -759,7 +748,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
/**
* Gets the gcube item properties for gcube item as HTML.
*
@ -768,7 +756,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
*/
public String getGcubeItemPropertiesForGcubeItemAsHTML(WorkspaceItem wsItem) {
Map<String, String> properties = getGcubeItemProperties(wsItem);
if (properties != null) {
@ -798,7 +785,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
}
/**
* Gets the gcube item properties.
*
@ -822,4 +808,73 @@ public class StorageHubToWorkpaceConverter implements Serializable{
return null;
}
/**********************************************************************************************************************************************
*
*
*
*
* TESTING MODE METHODS
*
*
*
*
***********************************************************************************************************************************************/
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/**
* Used in test mode.
*
* @return the hash test users
*/
public static HashMap<String, InfoContactModel> getHashTestUsers() {
if (hashTestUser == null) {
hashTestUser = new HashMap<String, InfoContactModel>();
// 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<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) {
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin)
listContact.add(getHashTestUsers().get(portalLogin));
return listContact;
}
/**********************************************************************************************************************************************
*
*
*
*
* END TESTING MODE
*
*
*
*
***********************************************************************************************************************************************/
}