Starting work on versioning #7006

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@142752 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-02-20 10:41:54 +00:00
parent 443bc5bb22
commit 59e8f4e86e
7 changed files with 812 additions and 52 deletions

View File

@ -0,0 +1,92 @@
package org.gcube.portlets.user.workspace.client.event;
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class FileVersioningEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 20, 2017
*/
public class FileVersioningEvent extends GwtEvent<FileVersioningEventHandler> implements GuiEventInterface{
public static Type<FileVersioningEventHandler> TYPE = new Type<FileVersioningEventHandler>();
private FileModel targetFileModel;
private WorkspaceVersioningOperation workspaceVersioningOperation;
/**
* Instantiates a new file versioning event.
*
* @param workspaceVersioningOperation the workspace versioning operation
* @param target the target
*/
public FileVersioningEvent(WorkspaceVersioningOperation workspaceVersioningOperation, FileModel target) {
this.workspaceVersioningOperation = workspaceVersioningOperation;
this.targetFileModel = target;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<FileVersioningEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(FileVersioningEventHandler handler) {
handler.onFileVersioning(this);
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
*/
@Override
public EventsTypeEnum getKey() {
return EventsTypeEnum.FILE_VERSIONING_EVENT;
}
/**
* Sets the trash operation.
*
* @param workspaceVersioningOperation the new trash operation
*/
public void setTrashOperation(WorkspaceVersioningOperation workspaceVersioningOperation) {
this.workspaceVersioningOperation = workspaceVersioningOperation;
}
/**
* Gets the target file model.
*
* @return the targetFileModel
*/
public FileModel getTargetFileModel() {
return targetFileModel;
}
/**
* Gets the workspace versioning operation.
*
* @return the workspaceVersioningOperation
*/
public WorkspaceVersioningOperation getWorkspaceVersioningOperation() {
return workspaceVersioningOperation;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.workspace.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface FileVersioningEventHandler.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 20, 2017
*/
public interface FileVersioningEventHandler extends EventHandler {
/**
* On file versioning.
*
* @param fileVersioningEvent the file versioning event
*/
void onFileVersioning(FileVersioningEvent fileVersioningEvent);
}

View File

@ -4,7 +4,7 @@ package org.gcube.portlets.user.workspace.client.interfaces;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public enum EventsTypeEnum
public enum EventsTypeEnum
{
RENAME_ITEM_EVENT,
DELETE_ITEM_EVENT,
@ -17,21 +17,22 @@ public enum EventsTypeEnum
MOVED_ITEM_EVENT,
SMART_FOLDER_EVENT, //NOT IMPLEMENTED
FILE_UPLOAD_EVENT, //NOT IMPLEMENTED
COMPLETED_FILE_UPLOAD_EVENT,
LOAD_MESSAGES_EVENT,
COMPLETED_FILE_UPLOAD_EVENT,
LOAD_MESSAGES_EVENT,
SWITCH_VIEW_EVENT,
DELETED_MESSAGE,
DELETED_MESSAGE,
MARK_MESSAGE_AS_READ,
REFRESH_FOLDER,
SELECTED_MESSAGE,
CREATE_NEW_MESSAGE,
CREATE_NEW_MESSAGE,
REPLY_FORWARD_MESSAGE,
FILE_DOWNLAD_EVENT,
SESSION_EXPIRED,
PASTED_EVENT,
PASTED_EVENT,
COPY_EVENT,
TRASH_EVENT,
TRASH_EVENT,
UPDATED_VRE_PERMISSION,
UPDATE_WORKSPACE_SIZE,
ADD_ADMINISTRATOR_EVENT;
ADD_ADMINISTRATOR_EVENT,
FILE_VERSIONING_EVENT;
}

View File

@ -0,0 +1,30 @@
/**
*
*/
package org.gcube.portlets.user.workspace.server;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 20, 2017
*/
public class FileNotVersionedException extends Exception {
/**
*
*/
private static final long serialVersionUID = -954314398414781437L;
FileNotVersionedException(){}
/**
* @param string
*
*/
public FileNotVersionedException(String string) {
super(string);
}
}

View File

@ -1573,8 +1573,6 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt list message model for grid.
*
@ -1605,10 +1603,6 @@ public class GWTWorkspaceBuilder {
listMessageModel.add(new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), toDate(mess.getSendTime()), listAttachsNames, typeMessages, mess.isRead()));
}
// listMessageModel.add(new MessageModel("1", "subject", new InfoContactModel("1", "Federico"), "2001.07.04 at 12:08:56", 5));
// listMessageModel.add(new MessageModel("2", "subject 2", new InfoContactModel("1", "Federico"), "2005.07.04 at 12:08:56", 2));
// listMessageModel.add(new MessageModel("3", "subject 3", new InfoContactModel("3", "Francesco"), "2001.07.04 at 15:08:56", 3));
return listMessageModel;
}
@ -1624,9 +1618,6 @@ public class GWTWorkspaceBuilder {
public MessageModel buildGXTMessageModel(WorkspaceMessage mess, List<WorkspaceItem> listWorkspaceItems, String messageType) throws InternalErrorException {
List<FileModel> listAttachs = buildGXTListFileModelItemForAttachs(listWorkspaceItems);
// List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>();
// mess.getAddresses();
// listContacts.add(new InfoContactModel("1", "Empty"));
return new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), toDate(mess.getSendTime()), mess.getBody(), listAttachs, mess.getAddresses(), messageType, mess.isRead());
}
@ -1646,41 +1637,6 @@ public class GWTWorkspaceBuilder {
return new InfoContactModel();
}
// /**
// * Builds the gxt list bulk creator model.
// *
// * @param listFBC the list fbc
// * @return the list
// * @throws InternalErrorException the internal error exception
// */
// public List<BulkCreatorModel> buildGXTListBulkCreatorModel(List<FolderBulkCreator> listFBC) throws InternalErrorException {
//
// List<BulkCreatorModel> listBulkCreatorModel = new ArrayList<BulkCreatorModel>();
//
// for (FolderBulkCreator item : listFBC){
//
// BulkCreatorModel bulk;
//
// if(item.getStatus()<1)
// bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.ONGOING, item.getNumberOfRequests(), item.getFailures());
// else{//status = 1
//
// int failures = item.getFailures();
//
// if(failures==0)
// bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.COMPLETED, item.getNumberOfRequests(), item.getFailures());
// else
// if(failures<item.getNumberOfRequests())
// bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.FAILED, item.getNumberOfRequests(), item.getFailures());
// else
// bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.FAILED, item.getNumberOfRequests(), item.getFailures());
// }
// listBulkCreatorModel.add(bulk);
// }
// return listBulkCreatorModel;
// }
/**
* Builds the gxt accounting item.
*
@ -2269,4 +2225,26 @@ public class GWTWorkspaceBuilder {
}
return null;
}
/**
* To version history.
*
* @param versions the versions
* @return the list
*/
public List<FileModel> toVersionHistory(List<String> versions){
if(versions==null){
logger.error("Version history is null!!!");
return new ArrayList<FileModel>();
}
List<FileModel> listVersions = new ArrayList<FileModel>(versions.size());
for (String id : versions) {
listVersions.add(new FileModel(id, id, false));
}
return listVersions;
}
}

View File

@ -35,6 +35,7 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundExcept
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
@ -81,6 +82,7 @@ import org.gcube.portlets.user.workspace.shared.UserBean;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import org.gcube.portlets.user.workspace.shared.WorkspaceUserQuote;
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import org.gcube.vomanagement.usermanagement.GroupManager;
@ -205,6 +207,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getRootForTree()
*/
/**
* Gets the root for tree.
*
* @return the root for tree
* @throws Exception the exception
*/
@Override
public FolderModel getRootForTree() throws Exception {
@ -239,6 +247,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getRootForTree(java.lang.String)
*/
/**
* Gets the root for tree.
*
* @param scopeId the scope id
* @return the root for tree
* @throws Exception the exception
*/
@Override
public FolderModel getRootForTree(String scopeId) throws Exception {
@ -279,6 +294,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemsBySearchName(java.lang.String)
*/
/**
* Gets the items by search name.
*
* @param text the text
* @param folderId the folder id
* @return the items by search name
* @throws Exception the exception
*/
@Override
public List<FileGridModel> getItemsBySearchName(String text, String folderId) throws Exception {
@ -313,6 +336,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getFolderChildren(org.gcube.portlets.user.workspace.client.model.FolderModel)
*/
/**
* Gets the folder children.
*
* @param folder the folder
* @return the folder children
* @throws Exception the exception
* @throws SessionExpiredException the session expired exception
*/
@Override
public List<FileModel> getFolderChildren(FolderModel folder) throws Exception, SessionExpiredException{
@ -388,6 +419,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getFolderChildrenForFileGrid(org.gcube.portlets.user.workspace.client.model.FileModel)
*/
/**
* Gets the folder children for file grid.
*
* @param folder the folder
* @return the folder children for file grid
* @throws Exception the exception
* @throws SessionExpiredException the session expired exception
*/
@Override
public List<FileGridModel> getFolderChildrenForFileGrid(FileModel folder) throws Exception, SessionExpiredException {
@ -443,6 +482,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getFolderChildrenForFileGridById(java.lang.String)
*/
/**
* Gets the folder children for file grid by id.
*
* @param folderId the folder id
* @return the folder children for file grid by id
* @throws Exception the exception
* @throws SessionExpiredException the session expired exception
*/
@Override
public List<FileGridModel> getFolderChildrenForFileGridById(String folderId) throws Exception, SessionExpiredException {
@ -512,6 +559,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemForFileGrid(java.lang.String)
*/
/**
* Gets the item for file grid.
*
* @param itemId the item id
* @return the item for file grid
* @throws Exception the exception
*/
@Override
public FileGridModel getItemForFileGrid(String itemId) throws Exception {
@ -544,6 +598,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemForFileTree(java.lang.String)
*/
/**
* Gets the item for file tree.
*
* @param itemId the item id
* @return the item for file tree
* @throws Exception the exception
*/
@Override
public FileModel getItemForFileTree(String itemId) throws Exception {
try {
@ -570,6 +631,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#moveItem(java.lang.String, java.lang.String)
*/
/**
* Move item.
*
* @param itemId the item id
* @param destinationId the destination id
* @return the boolean
* @throws Exception the exception
*/
@Override
public Boolean moveItem(String itemId, String destinationId) throws Exception {
workspaceLogger.trace("moveItem itemId: "+itemId+" destination: "+destinationId);
@ -632,6 +701,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#moveItems(java.util.List, java.lang.String)
*/
/**
* Move items.
*
* @param ids the ids
* @param destinationId the destination id
* @return the boolean
* @throws Exception the exception
*/
@Override
public Boolean moveItems(List<String> ids, String destinationId) throws Exception {
workspaceLogger.trace("moveItems "+ids.size()+ ", destination: "+destinationId);
@ -844,6 +921,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#removeItem(java.lang.String)
*/
/**
* Removes the item.
*
* @param itemId the item id
* @return the boolean
* @throws Exception the exception
*/
@Override
public Boolean removeItem(String itemId) throws Exception {
@ -892,6 +976,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#renameItem(java.lang.String, java.lang.String, java.lang.String)
*/
/**
* Rename item.
*
* @param itemId the item id
* @param newName the new name
* @param previousName the previous name
* @return the boolean
* @throws Exception the exception
*/
@Override
public Boolean renameItem(String itemId, String newName, String previousName) throws Exception {
@ -956,6 +1049,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#createFolder(java.lang.String, java.lang.String, org.gcube.portlets.user.workspace.client.model.FileModel)
*/
/**
* Creates the folder.
*
* @param nameFolder the name folder
* @param description the description
* @param parent the parent
* @return the folder model
* @throws Exception the exception
*/
@Override
public FolderModel createFolder(String nameFolder, String description, FileModel parent) throws Exception {
@ -995,6 +1097,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getDetailsFile(org.gcube.portlets.user.workspace.client.model.FileModel)
*/
/**
* Gets the details file.
*
* @param folder the folder
* @return the details file
* @throws Exception the exception
*/
@Override
public FileDetailsModel getDetailsFile(FileModel folder) throws Exception {
@ -1020,6 +1129,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getChildrenSubTreeToRootByIdentifier(java.lang.String)
*/
/**
* Gets the children sub tree to root by identifier.
*
* @param itemIdentifier the item identifier
* @return the children sub tree to root by identifier
* @throws Exception the exception
*/
@Override
public ArrayList<SubTree> getChildrenSubTreeToRootByIdentifier(String itemIdentifier) throws Exception {
@ -1067,6 +1183,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getSmartFolderResultsByCategory(java.lang.String)
*/
/**
* Gets the smart folder results by category.
*
* @param category the category
* @return the smart folder results by category
* @throws Exception the exception
*/
@Override
public List<FileGridModel> getSmartFolderResultsByCategory(GXTCategorySmartFolder category) throws Exception {
@ -1153,6 +1276,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#createSmartFolder(java.lang.String, java.lang.String, java.lang.String)
*/
/**
* Creates the smart folder.
*
* @param name the name
* @param description the description
* @param query the query
* @param parentId the parent id
* @return the smart folder model
* @throws Exception the exception
*/
@Override
public SmartFolderModel createSmartFolder(String name, String description, String query, String parentId) throws Exception {
@ -1189,6 +1322,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#removeSmartFolder(java.lang.String, java.lang.String)
*/
/**
* Removes the smart folder.
*
* @param itemId the item id
* @param name the name
* @return the boolean
* @throws Exception the exception
*/
@Override
public Boolean removeSmartFolder(String itemId, String name) throws Exception {
@ -1211,6 +1352,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getAllSmartFolders()
*/
/**
* Gets the all smart folders.
*
* @return the all smart folders
* @throws Exception the exception
*/
@Override
public List<SmartFolderModel> getAllSmartFolders() throws Exception{
@ -1233,6 +1380,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getSmartFolderResultsById(java.lang.String)
*/
/**
* Gets the smart folder results by id.
*
* @param folderId the folder id
* @return the smart folder results by id
* @throws Exception the exception
*/
@Override
public List<FileGridModel> getSmartFolderResultsById(String folderId) throws Exception {
@ -1264,6 +1418,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getImageById(java.lang.String, boolean, boolean)
*/
/**
* Gets the image by id.
*
* @param identifier the identifier
* @param isInteralImage the is interal image
* @param fullDetails the full details
* @return the image by id
* @throws Exception the exception
*/
@Override
public GWTWorkspaceItem getImageById(String identifier, boolean isInteralImage, boolean fullDetails) throws Exception {
@ -1290,6 +1453,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getTimeSeriesById(java.lang.String)
*/
/**
* Gets the time series by id.
*
* @param identifier the identifier
* @return the time series by id
* @throws Exception the exception
*/
@Override
@Deprecated
/**
@ -1317,6 +1487,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getUrlById(java.lang.String, boolean, boolean)
*/
/**
* Gets the url by id.
*
* @param identifier the identifier
* @param isInternalUrl the is internal url
* @param fullDetails the full details
* @return the url by id
* @throws Exception the exception
*/
@Override
public GWTWorkspaceItem getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails) throws Exception {
@ -1343,6 +1522,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#createExternalUrl(org.gcube.portlets.user.workspace.client.model.FileModel, java.lang.String, java.lang.String, java.lang.String)
*/
/**
* Creates the external url.
*
* @param parentFileModel the parent file model
* @param name the name
* @param description the description
* @param url the url
* @return the file model
* @throws Exception the exception
*/
@Override
public FileModel createExternalUrl(FileModel parentFileModel, String name, String description, String url) throws Exception {
@ -1370,6 +1559,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getURLFromApplicationProfile(java.lang.String)
*/
/**
* Gets the URL from application profile.
*
* @param oid the oid
* @return the URL from application profile
* @throws Exception the exception
*/
@Override
public String getURLFromApplicationProfile(String oid) throws Exception {
@ -1379,6 +1575,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#setValueInSession(java.lang.String, java.lang.String)
*/
/**
* Sets the value in session.
*
* @param name the name
* @param value the value
* @throws Exception the exception
*/
@Override
public void setValueInSession(String name, String value) throws Exception {
@ -1394,6 +1597,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getAllScope()
*/
/**
* Gets the all scope.
*
* @return the all scope
* @throws Exception the exception
*/
@Override
public List<ScopeModel> getAllScope() throws Exception {
@ -1425,6 +1634,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getAllContacts()
*/
/**
* Gets the all contacts.
*
* @return the all contacts
* @throws Exception the exception
*/
@Override
public List<InfoContactModel> getAllContacts() throws Exception {
@ -1473,6 +1688,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#sendToById(java.util.List, java.util.List, java.lang.String, java.lang.String)
*/
/**
* Send to by id.
*
* @param listContactsId the list contacts id
* @param listAttachmentsId the list attachments id
* @param subject the subject
* @param body the body
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String body) throws Exception {
@ -1529,6 +1754,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#copyItem(java.lang.String, java.lang.String)
*/
/**
* Copy item.
*
* @param itemId the item id
* @param destinationFolderId the destination folder id
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean copyItem(String itemId, String destinationFolderId) throws Exception {
@ -1567,6 +1800,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#copyItems(java.util.List, java.lang.String)
*/
/**
* Copy items.
*
* @param idsItem the ids item
* @param destinationFolderId the destination folder id
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean copyItems(List<String> idsItem, String destinationFolderId) throws Exception {
@ -1615,6 +1856,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getUrlWebDav(java.lang.String)
*/
/**
* Gets the url web dav.
*
* @param itemId the item id
* @return the url web dav
* @throws Exception the exception
*/
@Override
public String getUrlWebDav(String itemId) throws Exception {
@ -1633,6 +1881,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#shareFolder(org.gcube.portlets.user.workspace.client.model.FileModel, java.util.List, boolean, org.gcube.portlets.user.workspace.shared.WorkspaceACL)
*/
/**
* Share folder.
*
* @param folder the folder
* @param listContacts the list contacts
* @param isNewFolder the is new folder
* @param acl the acl
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts, boolean isNewFolder, WorkspaceACL acl) throws Exception {
@ -1734,6 +1992,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getListUserSharedByFolderSharedId(java.lang.String)
*/
/**
* Gets the list user shared by folder shared id.
*
* @param folderSharedId the folder shared id
* @return the list user shared by folder shared id
* @throws Exception the exception
*/
@Override
public List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception{
@ -1806,6 +2071,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#unSharedFolderByFolderSharedId(java.lang.String)
*/
/**
* Un shared folder by folder shared id.
*
* @param folderSharedId the folder shared id
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean unSharedFolderByFolderSharedId(String folderSharedId) throws Exception{
@ -1982,6 +2254,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getOwnerByItemId(java.lang.String)
*/
/**
* Gets the owner by item id.
*
* @param itemId the item id
* @return the owner by item id
* @throws Exception the exception
*/
@Override
public InfoContactModel getOwnerByItemId(String itemId) throws Exception {
@ -2008,6 +2287,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getUsersManagerToSharedFolder(java.lang.String)
*/
/**
* Gets the users manager to shared folder.
*
* @param folderId the folder id
* @return the users manager to shared folder
* @throws Exception the exception
*/
@Override
public List<InfoContactModel> getUsersManagerToSharedFolder(String folderId) throws Exception{
@ -2061,6 +2347,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#itemExistsInWorkpaceFolder(java.lang.String, java.lang.String)
*/
/**
* Item exists in workpace folder.
*
* @param parentId the parent id
* @param itemName the item name
* @return the string
* @throws Exception the exception
*/
@Override
public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception {
@ -2098,6 +2392,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemCreationDateById(java.lang.String)
*/
/**
* Gets the item creation date by id.
*
* @param itemId the item id
* @return the item creation date by id
* @throws Exception the exception
*/
@Override
public Date getItemCreationDateById(String itemId) throws Exception {
workspaceLogger.trace("get Item Creation Date By ItemId "+ itemId);
@ -2121,6 +2422,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#loadSizeByItemId(java.lang.String)
*/
/**
* Load size by item id.
*
* @param itemId the item id
* @return the long
* @throws Exception the exception
*/
@Override
public Long loadSizeByItemId(String itemId) throws Exception {
@ -2154,6 +2462,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#loadLastModificationDateById(java.lang.String)
*/
/**
* Load last modification date by id.
*
* @param itemId the item id
* @return the date
* @throws Exception the exception
*/
@Override
public Date loadLastModificationDateById(String itemId) throws Exception {
@ -2180,6 +2495,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getParentByItemId(java.lang.String)
*/
/**
* Gets the parent by item id.
*
* @param identifier the identifier
* @return the parent by item id
* @throws Exception the exception
*/
@Override
public FileModel getParentByItemId(String identifier) throws Exception {
@ -2210,6 +2532,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getAccountingReaders(java.lang.String)
*/
/**
* Gets the accounting readers.
*
* @param identifier the identifier
* @return the accounting readers
* @throws Exception the exception
*/
@Override
public List<GxtAccountingField> getAccountingReaders(String identifier) throws Exception {
@ -2233,6 +2562,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getAccountingHistory(java.lang.String)
*/
/**
* Gets the accounting history.
*
* @param identifier the identifier
* @return the accounting history
* @throws Exception the exception
*/
@Override
public List<GxtAccountingField> getAccountingHistory(String identifier) throws Exception {
@ -2257,6 +2593,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getShortUrl(java.lang.String)
*/
/**
* Gets the short url.
*
* @param longUrl the long url
* @return the short url
* @throws Exception the exception
*/
@Override
public String getShortUrl(String longUrl) throws Exception {
@ -2330,6 +2673,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#isSessionExpired()
*/
/**
* Checks if is session expired.
*
* @return true, if is session expired
* @throws Exception the exception
*/
@Override
public boolean isSessionExpired() throws Exception {
return WsUtil.isSessionExpired(this.getThreadLocalRequest());
@ -2338,6 +2687,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#deleteListItemsForIds(java.util.List)
*/
/**
* Delete list items for ids.
*
* @param ids the ids
* @return the list
* @throws Exception the exception
*/
@Override
public List<GarbageItem> deleteListItemsForIds(List<String> ids) throws Exception {
@ -2421,6 +2777,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#setACLs(java.lang.String, java.util.List, java.lang.String)
*/
/**
* Sets the ac ls.
*
* @param folderId the folder id
* @param listLogins the list logins
* @param aclType the acl type
* @throws Exception the exception
*/
@Override
public void setACLs(String folderId, List<String> listLogins, String aclType) throws Exception{
try {
@ -2611,6 +2975,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getMyLogin()
*/
/**
* Gets the my login.
*
* @param currentPortletUrl the current portlet url
* @return the my login
*/
@Override
public UserBean getMyLogin(String currentPortletUrl){
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
@ -2647,6 +3017,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getMyLogin()
*/
/**
* Gets the my first name.
*
* @return the my first name
*/
@Override
public String getMyFirstName(){
if(!isWithinPortal())
@ -2957,10 +3332,132 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
/**
* Gets the version history.
*
* @param fileIdentifier the file identifier
* @return the version history
* @throws Exception the exception
*/
public List<FileModel> getVersionHistory(String fileIdentifier) throws Exception{
workspaceLogger.info("Get Version History "+fileIdentifier);
if(fileIdentifier==null)
throw new Exception("File identifier is null");
try {
Workspace workspace = getWorkspace();
WorkspaceItem fileHL = workspace.getItem(fileIdentifier);
if(fileHL instanceof ExternalFile){
ExternalFile extFile = (ExternalFile) fileHL;
List<String> versions = extFile.getVersionHistory();
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
return builder.toVersionHistory(versions);
}else
throw new FileNotVersionedException("Selected file is not versioned");
}catch (Exception e) {
if (e instanceof FileNotVersionedException)
throw new Exception(e.getMessage());
String error = "An error occurred when getting version history of: "+fileIdentifier+ ", try again";
workspaceLogger.error(error);
throw new Exception(error);
}
}
/**
* Perform operation on file versioned.
*
* @param currentVersion the current version
* @param selectedVersion the selected version
* @param operation the operation
* @return the list
* @throws Exception the exception
*/
public List<FileModel> performOperationOnFileVersioned(FileModel currentVersion, FileModel selectedVersion, WorkspaceVersioningOperation operation) throws Exception{
if(currentVersion == null || selectedVersion==null)
throw new Exception("File Versioned is null");
workspaceLogger.info("Cuurent Version: "+currentVersion.getName()+", File Versioned "+selectedVersion.getName()+ " perform operation: "+operation);
try {
Workspace workspace = getWorkspace();
WorkspaceItem fileHL = workspace.getItem(currentVersion.getIdentifier());
if(fileHL instanceof ExternalFile){
ExternalFile extFile = (ExternalFile) fileHL;
switch (operation) {
case DOWNLOAD: {
//IMPLEMENTED CLIENT-SIDE
break;
}
case EMPTY_OLDER_VERSIONS:{
//TODO
//extFile.(selectedVersion.getIdentifier());;
}
case RESTORE: {
extFile.restoreVersion(selectedVersion.getIdentifier());
return getVersionHistory(currentVersion.getIdentifier());
}
case REFRESH: {
return getVersionHistory(currentVersion.getIdentifier());
}
case DELETE_PERMANENTLY: {
extFile.removeVersion(selectedVersion.getIdentifier());
workspaceLogger.info("Version "+selectedVersion.getIdentifier() +" of "+currentVersion.getName()+" removed");
return getVersionHistory(currentVersion.getIdentifier());
}
default:{
break;
}
}
return getVersionHistory(currentVersion.getIdentifier());
}else
throw new FileNotVersionedException("Selected file is not versioned");
}catch (Exception e) {
if (e instanceof FileNotVersionedException)
throw new Exception(e.getMessage());
workspaceLogger.error("Error in server during perform operation on versioning of: "+currentVersion.getName(), e);
String error = ConstantsExplorer.SERVER_ERROR +" updating versioning of "+currentVersion.getName();
throw new Exception(error);
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#executeOperationOnTrash(java.util.List, org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation)
*/
/**
* Execute operation on trash.
*
* @param listTrashItemIds the list trash item ids
* @param operation the operation
* @return the trash operation content
* @throws Exception the exception
*/
@Override
public TrashOperationContent executeOperationOnTrash(List<String> listTrashItemIds, WorkspaceTrashOperation operation) throws Exception{
@ -3063,6 +3560,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
*
* true if administrators have been added, false otherwise
*/
/**
* Adds the administrators by folder id.
*
* @param folderId the folder id
* @param listContactLogins the list contact logins
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean addAdministratorsByFolderId(String folderId, List<String> listContactLogins) throws Exception {
if(folderId==null || listContactLogins==null || listContactLogins.size()==0)
@ -3122,6 +3627,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getAdministratorsByFolderId(java.lang.String)
*/
/**
* Gets the administrators by folder id.
*
* @param folderId the folder id
* @return the administrators by folder id
* @throws Exception the exception
*/
@Override
public List<InfoContactModel> getAdministratorsByFolderId(String folderId) throws Exception {
List<InfoContactModel> admins = new ArrayList<InfoContactModel>();
@ -3154,6 +3666,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemDescriptionById(java.lang.String)
*/
/**
* Gets the item description by id.
*
* @param identifier the identifier
* @return the item description by id
* @throws Exception the exception
*/
@Override
public String getItemDescriptionById(String identifier) throws Exception {
@ -3180,6 +3699,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getACLBySharedFolderId(java.lang.String)
*/
/**
* Gets the ACL by shared folder id.
*
* @param identifier the identifier
* @return the ACL by shared folder id
* @throws Exception the exception
*/
@Override
public WorkspaceACL getACLBySharedFolderId(String identifier) throws Exception {
workspaceLogger.info("Getting ACLBySharedFolderId: "+identifier);
@ -3223,6 +3749,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getUserWorkspaceQuote()
*/
/**
* Gets the user workspace quote.
*
* @return the user workspace quote
* @throws Exception the exception
*/
@Override
public WorkspaceUserQuote getUserWorkspaceQuote() throws Exception {
try{
@ -3248,6 +3780,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getUserWorkspaceSize()
*/
/**
* Gets the user workspace size.
*
* @return the user workspace size
* @throws Exception the exception
*/
@Override
public String getUserWorkspaceSize() throws Exception {
try{
@ -3269,6 +3807,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getUserWorkspaceTotalItems()
*/
/**
* Gets the user workspace total items.
*
* @return the user workspace total items
* @throws Exception the exception
*/
@Override
public long getUserWorkspaceTotalItems() throws Exception {
try{
@ -3287,6 +3831,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#loadGcubeItemProperties(java.lang.String)
*/
/**
* Load gcube item properties.
*
* @param itemId the item id
* @return the map
* @throws Exception the exception
*/
@Override
public Map<String, String> loadGcubeItemProperties(String itemId) throws Exception {
workspaceLogger.info("Getting GcubeItemProperties for itemId: "+itemId);
@ -3387,6 +3938,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#markFolderAsPublicForFolderItemId(java.lang.String, boolean)
*/
/**
* Mark folder as public for folder item id.
*
* @param itemId the item id
* @param setPublic the set public
* @return the public link
* @throws SessionExpiredException the session expired exception
* @throws Exception the exception
*/
@Override
public PublicLink markFolderAsPublicForFolderItemId(String itemId, boolean setPublic) throws SessionExpiredException, Exception {
@ -3437,6 +3997,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
/**
* Gets the servlet context path.
*
* @param protocol the protocol
* @return the servlet context path
*/
@Override
public String getServletContextPath(String protocol) {
HttpServletRequest req = getThreadLocalRequest();
@ -3468,6 +4034,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#accessToFolderLink(java.lang.String)
*/
/**
* Access to folder link.
*
* @param itemId the item id
* @return the allow access
* @throws SessionExpiredException the session expired exception
* @throws Exception the exception
*/
@Override
public AllowAccess accessToFolderLink(String itemId) throws SessionExpiredException, Exception {
workspaceLogger.info("Access to Folder Link "+itemId+" working... ");

View File

@ -0,0 +1,65 @@
/**
*
*/
package org.gcube.portlets.user.workspace.shared;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 17, 2014
*
*/
public enum WorkspaceVersioningOperation {
//SHOW TRASH WINDOW
SHOW("Show", "Show"),
//CALLING OPERATION SERVER
REFRESH("Refresh", "Refresh history of versioning"),
RESTORE("Restore", "Restore the file to the selected version"),
DOWNLOAD("Download", "Download the version of the selected file"),
DELETE_PERMANENTLY("Delete Permanently", "Delete Permanently the version for the selected file"),
EMPTY_OLDER_VERSIONS("Empty Old Versions", "Empty definitively all older versions of the file");
public String label;
public String operationDescription;
WorkspaceVersioningOperation(String label, String description)
{
this.label = label;
this.operationDescription = description;
}
/**
* @return the label
*/
public String getLabel() {
return label;
}
public static List<String> getListLabels(){
List<String> listLabels = new ArrayList<String>();
for (WorkspaceVersioningOperation item : WorkspaceVersioningOperation.values())
listLabels.add(item.getLabel());
return listLabels;
}
public static WorkspaceVersioningOperation valueOfLabel(String label)
{
for (WorkspaceVersioningOperation value:values()) if (value.getLabel().equals(label)) return value;
return null;
}
public String getOperationDescription() {
return operationDescription;
}
}