@ -3,7 +3,6 @@
* /
package org.gcube.portlets.user.workspace.server.tostoragehub ;
import java.io.Serializable ;
import java.util.ArrayList ;
import java.util.Arrays ;
@ -33,7 +32,6 @@ import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorEx
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.thredds.WorkspaceThreddsSynchronize ;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer ;
import org.gcube.portlets.user.workspace.client.model.FileGridModel ;
@ -45,13 +43,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.model.ContainerType ;
import org.gcube.vomanagement.usermanagement.model.GCubeUser ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
/ * *
* The Class StorageHubToWorkpaceConverter .
*
@ -60,7 +56,6 @@ import org.slf4j.LoggerFactory;
* /
public class StorageHubToWorkpaceConverter implements Serializable {
/ * *
*
* /
@ -71,8 +66,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
private GCubeUser loggedUser ;
private String workspaceRootId ;
/ * *
* Instantiates a new storage hub to workpace converter .
* /
@ -80,68 +73,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 +89,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 +108,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
this . loggedUser = loggedUser ;
}
/ * *
* To root folder .
*
@ -185,7 +115,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 +131,13 @@ 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 ) ;
return setSynched ThreddsStateFor ( fileModel , wrappedItem ) ;
return setSynched WithWs Thredds( fileModel , wrappedItem ) ;
}
/ * *
* To grid file model .
*
@ -216,48 +146,70 @@ 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 ) ;
return ( FileGridModel ) setSynched ThreddsStateFor ( fileGridModel , wrappedItem ) ;
return ( FileGridModel ) setSynched WithWs Thredds( fileGridModel , wrappedItem ) ;
}
/ * *
* Sets the synched thredds state for .
*
* @param fileModel the file model
* @param wrappedItem item
* @return the file model
* /
protected FileModel setSynchedThreddsStateFor ( FileModel fileModel , WorkspaceItem wrappedItem ) {
Sync_Status status = null ;
protected FileModel setSynchedWithWsThredds ( FileModel fileModel , WorkspaceItem wrappedItem ) {
logger . debug ( "called setSynchedThreddsStateFor item id: " + wrappedItem . getId ( ) ) ;
try {
if ( wrappedItem . getPropertyMap ( ) ! = null ) {
String wsSyncStatus = null ;
boolean isItemSynched = false ;
try {
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" ) ;
Map < String , Object > mapProperties = wrappedItem . getPropertyMap ( ) . getValues ( ) ;
ContainerType containerItemType = null ;
// is it a directory?
if ( fileModel . isDirectory ( ) ) {
containerItemType = ContainerType . FOLDER ;
}
// checking other cases
if ( containerItemType = = null ) {
switch ( wrappedItem . getType ( ) ) {
case FOLDER :
case VRE_FOLDER :
case SHARED_FOLDER :
case SMART_FOLDER :
containerItemType = ContainerType . FOLDER ;
break ;
case FILE_ITEM :
containerItemType = ContainerType . FILE ;
break ;
case URL_ITEM :
containerItemType = ContainerType . URL ;
break ;
default :
containerItemType = ContainerType . GENERIC_ITEM ;
break ;
}
}
logger . debug (
"calling isItemSynched for id: " + wrappedItem . getId ( ) + ", with name: " + wrappedItem . getName ( )
+ ", with map: " + mapProperties + ", containerItemType: " + containerItemType ) ;
isItemSynched = WorkspaceThreddsSynchronize . getInstance ( ) . isItemSynched ( wrappedItem . getId ( ) , mapProperties ,
containerItemType ) ;
} catch ( Exception e ) {
logger . warn ( "It is not possible to get synched status for item: " + fileModel . getIdentifier ( ) ) ;
logger . info ( "Error on calling isItemSynched for the item id: " + wrappedItem . getId ( )
+ ", (means not synched)" ) ;
}
fileModel . setSyncThreddsStatus ( status ) ;
logger . debug ( "the item id: " + wrappedItem . getId ( ) + " with name: " + wrappedItem . getName ( ) + " is synched: "
+ isItemSynched ) ;
fileModel . setSynchedWithWsThredds ( isItemSynched ) ;
return fileModel ;
}
/ * *
* To file trashed model .
*
@ -301,13 +253,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 +270,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
/ * *
* Builds the gxt info contact from portal login .
*
@ -345,8 +298,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 +308,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 +328,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 +342,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 +362,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
return folder ;
}
/ * *
* Gets the workspace root id .
*
@ -413,7 +372,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
return workspaceRootId ;
}
/ * *
* Sets the workspace root id .
*
@ -424,8 +382,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
this . workspaceRootId = workspaceRootId ;
}
/ * *
* To simple map .
*
@ -459,7 +415,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
}
/ * *
* Builds the GXT accounting item .
*
@ -467,7 +422,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 +448,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 +476,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 +490,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 +504,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 +519,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 +538,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 +657,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 +669,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 +682,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 +707,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 +728,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 +745,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 +774,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
/ * *
* Gets the gcube item properties for gcube item as HTML .
*
@ -768,7 +782,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
* /
public String getGcubeItemPropertiesForGcubeItemAsHTML ( WorkspaceItem wsItem ) {
Map < String , String > properties = getGcubeItemProperties ( wsItem ) ;
if ( properties ! = null ) {
@ -798,7 +811,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
}
}
/ * *
* Gets the gcube item properties .
*
@ -822,4 +834,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
*
*
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
}