Updated pom version at 6.12

Removed unused code and servlets

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@128590 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-05-13 09:14:42 +00:00
parent ca0f8a1754
commit 8a4dfa7acf
12 changed files with 666 additions and 730 deletions

View File

@ -23,5 +23,6 @@
<attribute name="org.eclipse.jst.component.nondependency" value=""/> <attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

46
pom.xml
View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId> <artifactId>workspace-tree-widget</artifactId>
<version>6.11.2-SNAPSHOT</version> <version>6.12.0-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name> <name>gCube Workspace Tree Widget</name>
<description> <description>
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
@ -62,12 +62,13 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <!-- <dependency> -->
<groupId>com.google.web.bindery</groupId> <!-- <groupId>com.google.web.bindery</groupId> -->
<artifactId>requestfactory-server</artifactId> <!-- <artifactId>requestfactory-server</artifactId> -->
<version>${gwtVersion}</version> <!-- <version>${gwtVersion}</version> -->
<scope>runtime</scope> <!-- <scope>runtime</scope> -->
</dependency> <!-- </dependency> -->
<!-- Google Web Toolkit (GWT) --> <!-- Google Web Toolkit (GWT) -->
<dependency> <dependency>
@ -145,37 +146,15 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- <dependency> -->
<!-- <groupId>org.apache.directory.studio</groupId> -->
<!-- <artifactId>org.apache.commons.io</artifactId> -->
<!-- <version>2.1</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>commons-io</groupId> -->
<!-- <artifactId>commons-io</artifactId> -->
<!-- <version>2.4</version> -->
<!-- </dependency> -->
<!-- HOME LIBRARY --> <!-- HOME LIBRARY -->
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library-model</artifactId> <artifactId>home-library-model</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId> <artifactId>home-library</artifactId>
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -184,17 +163,22 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>commons-httpclient</groupId> <groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>
<version>3.1</version> <!-- <version>3.1</version> -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.thoughtworks.xstream</groupId> <groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId> <artifactId>xstream</artifactId>
<version>1.4.5</version> <!-- <version>1.4.5</version> -->
</dependency> </dependency>
<dependency> <dependency>

View File

@ -14,13 +14,8 @@
<inherits name="org.gcube.portlets.widgets.workspacesharingwidget.WorkspaceSharingWidget" /> <inherits name="org.gcube.portlets.widgets.workspacesharingwidget.WorkspaceSharingWidget" />
<servlet path="/WorkspaceService" class="org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl" /> <servlet path="/WorkspaceService" class="org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl" />
<inherits name="org.gcube.portlets.widgets.workspaceuploader.WorkspaceUploader"></inherits> <inherits name="org.gcube.portlets.widgets.workspaceuploader.WorkspaceUploader"></inherits>
<!--
<servlet path="/ImageService" class="org.gcube.portlets.user.workspace.server.ImageServlet" />
<servlet path="/MetadataService" class="org.gcube.portlets.user.workspace.server.MetadataServlet" />
-->
<inherits name='org.gcube.portlets.widgets.fileupload.FileUpload' />
<servlet path="/UploadService" class="org.gcube.portlets.user.workspace.server.UploadServlet" /> <servlet path="/UploadService" class="org.gcube.portlets.user.workspace.server.UploadServlet" />
<servlet path="/LocalUploadService" class="org.gcube.portlets.user.workspace.server.LocalUploadServlet" /> <servlet path="/LocalUploadService" class="org.gcube.portlets.user.workspace.server.LocalUploadServlet" />
@ -29,8 +24,7 @@
<!-- Specify the application specific style sheet. --> <!-- Specify the application specific style sheet. -->
<stylesheet src='workspacetree.css' /> <stylesheet src='workspacetree.css' />
<!-- Specify the paths for translatable code -->
<source path='client'/> <source path='client'/>
<source path='shared'/> <source path='shared'/>

View File

@ -152,7 +152,7 @@ public interface GWTWorkspaceService extends RemoteService{
* @return the smart folder results by id * @return the smart folder results by id
* @throws Exception the exception * @throws Exception the exception
*/ */
public List<FileGridModel> getSmartFolderResultsById(String folderId) throws Exception; public List<FileGridModel> getSmartFolderResultsById(String folderId) throws Exception;
/** /**
* Gets the all smart folders. * Gets the all smart folders.
@ -283,7 +283,7 @@ public interface GWTWorkspaceService extends RemoteService{
* @throws Exception the exception * @throws Exception the exception
*/ */
public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text) throws Exception; public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text) throws Exception;
/** /**
* Copy item. * Copy item.
* *
@ -372,15 +372,6 @@ public interface GWTWorkspaceService extends RemoteService{
*/ */
public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception; public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception;
/**
* Gets the list user shared by shared item.
*
* @param sharedItemId the shared item id
* @return the list user shared by shared item
* @throws Exception the exception
*/
public List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId) throws Exception;
/** /**
* Gets the item creation date by id. * Gets the item creation date by id.
* *
@ -568,7 +559,7 @@ public interface GWTWorkspaceService extends RemoteService{
*/ */
List<FileTrashedModel> getTrashContent() throws Exception; List<FileTrashedModel> getTrashContent() throws Exception;
/** /**
* Gets the AC ls description for workspace item by id. * Gets the AC ls description for workspace item by id.
* *

View File

@ -37,7 +37,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
* Jul 14, 2015 * Jul 14, 2015
*/ */
public interface GWTWorkspaceServiceAsync { public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the user workspace size. * Gets the user workspace size.
* *
@ -45,7 +45,7 @@ public interface GWTWorkspaceServiceAsync {
* @return the user workspace size * @return the user workspace size
*/ */
void getUserWorkspaceSize(AsyncCallback<String> callback); void getUserWorkspaceSize(AsyncCallback<String> callback);
/** /**
* Gets the root for tree. * Gets the root for tree.
* *
@ -53,7 +53,7 @@ public interface GWTWorkspaceServiceAsync {
* @return the root for tree * @return the root for tree
*/ */
void getRootForTree(AsyncCallback<FolderModel> callback); void getRootForTree(AsyncCallback<FolderModel> callback);
/** /**
* Gets the root for tree. * Gets the root for tree.
* *
@ -107,7 +107,7 @@ public interface GWTWorkspaceServiceAsync {
* @param callback the callback * @param callback the callback
*/ */
void renameItem(String itemId, String newName, String oldName, AsyncCallback<Boolean> callback); void renameItem(String itemId, String newName, String oldName, AsyncCallback<Boolean> callback);
/** /**
* Creates the folder. * Creates the folder.
* *
@ -172,7 +172,7 @@ public interface GWTWorkspaceServiceAsync {
* @return the smart folder results by id * @return the smart folder results by id
*/ */
void getSmartFolderResultsById(String folderId, AsyncCallback<List<FileGridModel>> callback); void getSmartFolderResultsById(String folderId, AsyncCallback<List<FileGridModel>> callback);
/** /**
* Gets the all smart folders. * Gets the all smart folders.
* *
@ -213,7 +213,7 @@ public interface GWTWorkspaceServiceAsync {
* @param callback the callback * @param callback the callback
*/ */
void createExternalUrl(FileModel parentFileModel, String name, String description, String url, AsyncCallback<FileModel> callback); void createExternalUrl(FileModel parentFileModel, String name, String description, String url, AsyncCallback<FileModel> callback);
/** /**
* Sets the value in session. * Sets the value in session.
* *
@ -239,7 +239,7 @@ public interface GWTWorkspaceServiceAsync {
* @return the all scope * @return the all scope
*/ */
void getAllScope(AsyncCallback<List<ScopeModel>> callback); void getAllScope(AsyncCallback<List<ScopeModel>> callback);
/** /**
* Gets the all contacts. * Gets the all contacts.
* *
@ -249,7 +249,7 @@ public interface GWTWorkspaceServiceAsync {
void getAllContacts(AsyncCallback<List<InfoContactModel>> callback); void getAllContacts(AsyncCallback<List<InfoContactModel>> callback);
// void sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text, AsyncCallback<Boolean> callback); // void sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text, AsyncCallback<Boolean> callback);
/** /**
* Send to by id. * Send to by id.
* *
@ -340,7 +340,7 @@ public interface GWTWorkspaceServiceAsync {
* @return the URL from application profile * @return the URL from application profile
*/ */
void getURLFromApplicationProfile(String oid, AsyncCallback<String> callback); void getURLFromApplicationProfile(String oid, AsyncCallback<String> callback);
/** /**
* Gets the owner by item id. * Gets the owner by item id.
* *
@ -361,16 +361,6 @@ public interface GWTWorkspaceServiceAsync {
void itemExistsInWorkpaceFolder(String parentId, String itemName, void itemExistsInWorkpaceFolder(String parentId, String itemName,
AsyncCallback<String> callback); AsyncCallback<String> callback);
/**
* Gets the list user shared by shared item.
*
* @param sharedItemId the shared item id
* @param callback the callback
* @return the list user shared by shared item
*/
void getListUserSharedBySharedItem(String sharedItemId,
AsyncCallback<List<InfoContactModel>> callback);
/** /**
* Gets the item creation date by id. * Gets the item creation date by id.
* *
@ -436,7 +426,7 @@ public interface GWTWorkspaceServiceAsync {
* @return the item for file grid * @return the item for file grid
*/ */
void getItemForFileGrid(String itemId, AsyncCallback<FileGridModel> callback); void getItemForFileGrid(String itemId, AsyncCallback<FileGridModel> callback);
/** /**
* @param itemId * @param itemId
* @param asyncCallback * @param asyncCallback
@ -597,7 +587,7 @@ public interface GWTWorkspaceServiceAsync {
void executeOperationOnTrash(List<String> listTrashItemIds, void executeOperationOnTrash(List<String> listTrashItemIds,
WorkspaceTrashOperation operation, WorkspaceTrashOperation operation,
AsyncCallback<TrashOperationContent> callback); AsyncCallback<TrashOperationContent> callback);
/** /**
* Adds the administrators by folder id. * Adds the administrators by folder id.
* *
@ -616,8 +606,8 @@ public interface GWTWorkspaceServiceAsync {
* @return the administrators by folder id * @return the administrators by folder id
*/ */
void getAdministratorsByFolderId(String identifier, AsyncCallback<List<InfoContactModel>> callback); void getAdministratorsByFolderId(String identifier, AsyncCallback<List<InfoContactModel>> callback);
/** /**
* Gets the ACL by shared folder id. * Gets the ACL by shared folder id.
* *

View File

@ -1782,7 +1782,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
@Override @Override
public List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception{ public List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception{
workspaceLogger.trace("getListUserSharedByFolderSharedId "+ folderSharedId); workspaceLogger.debug("getListUserSharedByFolderSharedId "+ folderSharedId);
try { try {
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
@ -1793,7 +1793,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem; WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
List<String> listPortalLogin = wsFolder.getUsers(); List<String> listPortalLogin = wsFolder.getUsers();
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user"); workspaceLogger.debug("HL return "+ listPortalLogin.size() + " user/s");
if(isTestMode()) if(isTestMode())
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin); return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
@ -1815,8 +1815,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc) /* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getListUserSharedBySharedItem(java.lang.String) * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getListUserSharedBySharedItem(java.lang.String)
*/ */
@Override
public List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId) throws Exception{ /*@Override
public List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId) throws Exception{
workspaceLogger.trace("Get ListUserSharedBySharedItem "+ sharedItemId); workspaceLogger.trace("Get ListUserSharedBySharedItem "+ sharedItemId);
try { try {
@ -1845,7 +1846,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.error("Error in getListUserSharedByItemId ", e); workspaceLogger.error("Error in getListUserSharedByItemId ", e);
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
} }
} }*/
/* (non-Javadoc) /* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#unSharedFolderByFolderSharedId(java.lang.String) * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#unSharedFolderByFolderSharedId(java.lang.String)

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.workspace.server.notifications; package org.gcube.portlets.user.workspace.server.notifications;
@ -23,10 +23,10 @@ import org.gcube.portlets.user.workspace.server.util.WsUtil;
* *
*/ */
public class NotificationsUtil { public class NotificationsUtil {
protected static Logger logger = Logger.getLogger(NotificationsUtil.class); protected static Logger logger = Logger.getLogger(NotificationsUtil.class);
/** /**
* Send a notification if an item is added or updated to sharing folder * Send a notification if an item is added or updated to sharing folder
* @param httpSession * @param httpSession
@ -35,77 +35,77 @@ public class NotificationsUtil {
* @param folderDestinationItem * @param folderDestinationItem
*/ */
public static void checkSendNotifyChangedItemToShare(HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) { public static void checkSendNotifyChangedItemToShare(HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
logger.trace("checkSendNotifyAddItemToShare"); logger.trace("checkSendNotifyAddItemToShare");
if(folderDestinationItem!=null){ if(folderDestinationItem!=null){
try{ try{
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing? if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
logger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder()); logger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder());
//share condition is true if source shared folder is not null //share condition is true if source shared folder is not null
boolean shareChangeCondition = sourceSharedId==null?false:true; boolean shareChangeCondition = sourceSharedId==null?false:true;
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition); //System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
logger.trace("shareChangeCondition add item: "+shareChangeCondition); logger.trace("shareChangeCondition add item: "+shareChangeCondition);
//if shareChangeCondition is true.. notifies added item to sharing //if shareChangeCondition is true.. notifies added item to sharing
if(shareChangeCondition){ if(shareChangeCondition){
Workspace workspace = WsUtil.getWorkspace(httpSession); Workspace workspace = WsUtil.getWorkspace(httpSession);
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder()); List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder()); WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession)); NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession));
if(destinationSharedFolder instanceof WorkspaceSharedFolder){ if(destinationSharedFolder instanceof WorkspaceSharedFolder){
//SWITCH BEETWEEN ADDED OR UPDATED //SWITCH BEETWEEN ADDED OR UPDATED
if(!isOverwrite) if(!isOverwrite)
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder);
else else
np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder);
logger.trace("The notifies was sent correctly"); logger.trace("The notifies was sent correctly");
}else }else
logger.trace("The notifies doesn't sent because "+destinationSharedFolder+ " is not instance of WorkspaceSharedFolder"); logger.trace("The notifies doesn't sent because "+destinationSharedFolder+ " is not instance of WorkspaceSharedFolder");
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); // np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
} }
} }
else else
logger.trace("folder destination is not shared"); logger.trace("folder destination is not shared");
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occurred in checkSendNotifyAddItemToShare ",e); logger.error("An error occurred in checkSendNotifyAddItemToShare ",e);
} }
}else }else
logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null"); logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null");
} }
/** /**
* *
* @param workspace * @param workspace
* @param idSharedFolder * @param idSharedFolder
* @return * @return
* @throws Exception * @throws Exception
*/ */
public static List<InfoContactModel> getListUserSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception { public static List<InfoContactModel> getListUsersSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception {
logger.trace("getListUserSharedByFolderSharedId "+ idSharedFolder); logger.trace("getListUsersSharedByFolderSharedId "+ idSharedFolder);
try { try {
WorkspaceItem wsItem = workspace.getItem(idSharedFolder); WorkspaceItem wsItem = workspace.getItem(idSharedFolder);
if(isASharedFolder(wsItem)){ if(isASharedFolder(wsItem)){
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem; WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
@ -115,16 +115,16 @@ public class NotificationsUtil {
logger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user"); logger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin); return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
} }
else{ else{
logger.trace("the item with id: "+idSharedFolder+ " is not "+WorkspaceItemType.SHARED_FOLDER); logger.trace("the item with id: "+idSharedFolder+ " is not "+WorkspaceItemType.SHARED_FOLDER);
//DEBUG //DEBUG
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER); //System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
} }
return new ArrayList<InfoContactModel>(); return new ArrayList<InfoContactModel>();
} catch (Exception e) { } catch (Exception e) {
logger.error("Error in getListUserSharedByItemId ", e); logger.error("Error in getListUserSharedByItemId ", e);
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
@ -133,9 +133,9 @@ public class NotificationsUtil {
/** /**
* *
* @param httpSession * @param httpSession
* @param sourceItemIsShared * @param sourceItemIsShared
* @param oldItemName * @param oldItemName
@ -143,51 +143,51 @@ public class NotificationsUtil {
* @param sourceFolderSharedId * @param sourceFolderSharedId
*/ */
public static void checkSendNotifyRemoveItemToShare(HttpSession httpSession, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) { public static void checkSendNotifyRemoveItemToShare(HttpSession httpSession, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) {
logger.trace("checkNotifyRemoveItemToShare:"); logger.trace("checkNotifyRemoveItemToShare:");
try{ try{
if(!sourceItemIsShared){ if(!sourceItemIsShared){
logger.trace("checkSendNotifyRemoveItemToShare returned, source item is not shared"); logger.trace("checkSendNotifyRemoveItemToShare returned, source item is not shared");
return; return;
} }
String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:""; String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:"";
// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition); // System.out.println("shareChangeCondition remove item: "+ shareChangeCondition);
boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder); boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder);
logger.trace("isRootFolderShared is: "+ isRootFolderShared); logger.trace("isRootFolderShared is: "+ isRootFolderShared);
/* /*
if(isRootFolderShared){ if(isRootFolderShared){
logger.trace("Notification doesn't sent because the event is on root shared folder"); logger.trace("Notification doesn't sent because the event is on root shared folder");
return; return;
}*/ }*/
boolean isSharedFolder = isASharedFolderForId(httpSession,idSharedFolder); boolean isSharedFolder = isASharedFolderForId(httpSession,idSharedFolder);
if(isSharedFolder){ if(isSharedFolder){
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder); logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
Workspace workspace = WsUtil.getWorkspace(httpSession); Workspace workspace = WsUtil.getWorkspace(httpSession);
//get contacts //get contacts
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, idSharedFolder); List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, idSharedFolder);
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder); WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName()); //System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession)); NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession));
//Notify Removed Item To Sharing? //Notify Removed Item To Sharing?
if(!isRootFolderShared){ if(!isRootFolderShared){
if(sourceSharedFolder instanceof WorkspaceSharedFolder){ if(sourceSharedFolder instanceof WorkspaceSharedFolder){
@ -196,21 +196,21 @@ public class NotificationsUtil {
} }
else else
logger.trace("The notifies doesn't sent because "+sourceSharedFolder+ " is not instance of WorkspaceSharedFolder"); logger.trace("The notifies doesn't sent because "+sourceSharedFolder+ " is not instance of WorkspaceSharedFolder");
}else{ }else{
//Case removed shared folder //Case removed shared folder
np.notifySharedFolderDeleted(listContacts, oldItemName); np.notifySharedFolderDeleted(listContacts, oldItemName);
} }
} }
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occurred in checkSendNotifyRemoveItemToShare ",e); logger.error("An error occurred in checkSendNotifyRemoveItemToShare ",e);
} }
} }
/** /**
* *
* @param wsItem * @param wsItem
* @return * @return
*/ */
@ -219,52 +219,52 @@ public class NotificationsUtil {
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER); return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
return false; return false;
} }
/** /**
* *
* @param wsItem * @param wsItem
* @return * @return
*/ */
public static boolean isASharedFolderForId(HttpSession httpSession, String itemId){ public static boolean isASharedFolderForId(HttpSession httpSession, String itemId){
if(itemId==null || itemId.isEmpty()) if(itemId==null || itemId.isEmpty())
return false; return false;
try { try {
Workspace workspace = WsUtil.getWorkspace(httpSession); Workspace workspace = WsUtil.getWorkspace(httpSession);
WorkspaceItem wsItem = workspace.getItem(itemId); WorkspaceItem wsItem = workspace.getItem(itemId);
if(wsItem!=null) if(wsItem!=null)
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER); return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
return false; return false;
} catch (Exception e) { } catch (Exception e) {
logger.error("An errror occurred in isASharedFolderForId", e); logger.error("An errror occurred in isASharedFolderForId", e);
return false; return false;
} }
} }
/** /**
* *
* @param itemId * @param itemId
* @param rootFolderSharedId * @param rootFolderSharedId
* @return * @return
*/ */
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) { public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]"); logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]");
if(itemId==null) if(itemId==null)
return false; return false;
if(rootFolderSharedId==null) if(rootFolderSharedId==null)
return false; return false;
if(itemId.compareTo(rootFolderSharedId)==0) if(itemId.compareTo(rootFolderSharedId)==0)
return true; return true;
return false; return false;
} }
} }

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.workspace.server.resolver; package org.gcube.portlets.user.workspace.server.resolver;
@ -29,12 +29,12 @@ import org.gcube.resources.discovery.client.queries.impl.XQuery;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 12, 2016 * Jan 12, 2016
*/ */
public class UriResolverReaderParameterForResolverIndex { public class UriResolverReaderParameterForResolverIndex {
protected static final String CONTENT_TYPE_PARAMETER = "contentType_parameter"; protected static final String CONTENT_TYPE_PARAMETER = "contentType_parameter";
protected static final String FILE_NAME_PARAMETER = "fileName_parameter"; protected static final String FILE_NAME_PARAMETER = "fileName_parameter";
protected static final String SMP_ID_PARAMETER = "SMP_ID_parameter"; protected static final String SMP_ID_PARAMETER = "SMP_ID_parameter";
//Base Address //Base Address
private String baseUri = ""; private String baseUri = "";
//Query URL parameter //Query URL parameter
@ -44,15 +44,15 @@ public class UriResolverReaderParameterForResolverIndex {
private String query = ""; private String query = "";
private boolean isAvailable = false; private boolean isAvailable = false;
public static Logger logger = Logger.getLogger(UriResolverReaderParameterForResolverIndex.class); public static Logger logger = Logger.getLogger(UriResolverReaderParameterForResolverIndex.class);
/** /**
* The Enum RESOLVER_TYPE. * The Enum RESOLVER_TYPE.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 12, 2016 * Jan 12, 2016
*/ */
public static enum RESOLVER_TYPE {SMP_URI, SMP_ID}; public static enum RESOLVER_TYPE {SMP_URI, SMP_ID};
/** /**
* Instantiates a new uri resolver reader parameter for resolver index. * Instantiates a new uri resolver reader parameter for resolver index.
* *
@ -61,43 +61,50 @@ public class UriResolverReaderParameterForResolverIndex {
* @throws Exception the exception * @throws Exception the exception
*/ */
public UriResolverReaderParameterForResolverIndex(String scope, RESOLVER_TYPE resolverType) throws Exception { public UriResolverReaderParameterForResolverIndex(String scope, RESOLVER_TYPE resolverType) throws Exception {
logger.trace("UriResolverReaderParameter is istancing with scope: "+scope); try{
ScopeUtilFilter scopeUtil = new ScopeUtilFilter(scope,true); logger.trace("UriResolverReaderParameter is istancing with scope: "+scope);
ScopeProvider.instance.set(scopeUtil.getScopeRoot()); ScopeUtilFilter scopeUtil = new ScopeUtilFilter(scope,true);
XQuery query = queryFor(ServiceEndpoint.class); ScopeProvider.instance.set(scopeUtil.getScopeRoot());
query.addCondition("$resource/Profile/Name/text() eq 'HTTP-URI-Resolver'").setResult("$resource/Profile/AccessPoint"); XQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq 'HTTP-URI-Resolver'").setResult("$resource/Profile/AccessPoint");
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
List<AccessPoint> endpoints = client.submit(query); DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
List<AccessPoint> endpoints = client.submit(query);
if (endpoints.size() == 0)
throw new Exception("No Resolver available"); if (endpoints.size() == 0)
throw new Exception("No Resolver available");
//THE FIRST ACCESS POINT (endpoints.get(0)) IS SMP-URI, THE SECOND (endpoints.get(1)) IS SMP-ID
int useResolverIndex; //THE FIRST ACCESS POINT (endpoints.get(0)) IS SMP-URI, THE SECOND (endpoints.get(1)) IS SMP-ID
int useResolverIndex;
switch(resolverType){
case SMP_ID: switch(resolverType){
useResolverIndex = 1; case SMP_ID:
break; useResolverIndex = 1;
case SMP_URI: break;
useResolverIndex = 0; case SMP_URI:
break; useResolverIndex = 0;
default: break;
useResolverIndex = 1; default:
useResolverIndex = 1;
}
AccessPoint ap2 = endpoints.get(useResolverIndex);
baseUri = ap2!=null?endpoints.get(useResolverIndex).address():"";
if(ap2!=null){
storageIDParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(SMP_ID_PARAMETER).value():"";
fileNameParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(FILE_NAME_PARAMETER).value():"";
contentTypeParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(CONTENT_TYPE_PARAMETER).value():"";
}
isAvailable = true;
}catch(Exception e){
}finally{
ScopeProvider.instance.reset();
} }
AccessPoint ap2 = endpoints.get(useResolverIndex);
baseUri = ap2!=null?endpoints.get(useResolverIndex).address():"";
if(ap2!=null){
storageIDParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(SMP_ID_PARAMETER).value():"";
fileNameParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(FILE_NAME_PARAMETER).value():"";
contentTypeParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(CONTENT_TYPE_PARAMETER).value():"";
}
isAvailable = true;
} }
/** /**
* Resolve - open stream with http get method. * Resolve - open stream with http get method.
* *
@ -111,16 +118,16 @@ public class UriResolverReaderParameterForResolverIndex {
String query = resolveAsUriRequest(smp, fileName, contentType, true); String query = resolveAsUriRequest(smp, fileName, contentType, true);
URL url = new URL(query); URL url = new URL(query);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setInstanceFollowRedirects(false); connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("charset", "utf-8");
connection.connect(); connection.connect();
return connection.getInputStream(); return connection.getInputStream();
} }
/** /**
* Resolve as uri request. * Resolve as uri request.
@ -134,16 +141,16 @@ public class UriResolverReaderParameterForResolverIndex {
* @throws Exception the exception * @throws Exception the exception
*/ */
public String resolveAsUriRequest(String storageID, String fileName, String contentType, boolean encodeParams) throws Exception{ public String resolveAsUriRequest(String storageID, String fileName, String contentType, boolean encodeParams) throws Exception{
if(storageID==null || storageID.isEmpty()) if(storageID==null || storageID.isEmpty())
throw new Exception("storage ID is null or empty"); throw new Exception("storage ID is null or empty");
if(!encodeParams){ //ENCODE URI if(!encodeParams){ //ENCODE URI
query = storageIDParameter+"="+storageID; query = storageIDParameter+"="+storageID;
if(fileName!=null && !fileName.isEmpty()) if(fileName!=null && !fileName.isEmpty())
query+="&"+fileNameParameter+"="+fileName; query+="&"+fileNameParameter+"="+fileName;
if(contentType!=null && !contentType.isEmpty()) if(contentType!=null && !contentType.isEmpty())
query+="&"+contentTypeParameter+"="+contentType; query+="&"+contentTypeParameter+"="+contentType;
} }
@ -155,8 +162,8 @@ public class UriResolverReaderParameterForResolverIndex {
logger.trace("resolve url request: "+uriRequest); logger.trace("resolve url request: "+uriRequest);
return uriRequest; return uriRequest;
} }
/** /**
* Resolve as storage id request. * Resolve as storage id request.
@ -167,7 +174,7 @@ public class UriResolverReaderParameterForResolverIndex {
* @throws Exception the exception * @throws Exception the exception
*/ */
public String resolveAsStorageIdRequest(String storageID, boolean encodeParams) throws Exception{ public String resolveAsStorageIdRequest(String storageID, boolean encodeParams) throws Exception{
if(storageID==null || storageID.isEmpty()) if(storageID==null || storageID.isEmpty())
throw new Exception("storage ID is null or empty"); throw new Exception("storage ID is null or empty");
@ -175,10 +182,10 @@ public class UriResolverReaderParameterForResolverIndex {
query = storageID; query = storageID;
else else
query = UrlEncoderUtil.encodeQueryValue(storageID); query = UrlEncoderUtil.encodeQueryValue(storageID);
if(baseUri.endsWith("/id")) if(baseUri.endsWith("/id"))
baseUri = baseUri.substring(0, baseUri.length()-3); baseUri = baseUri.substring(0, baseUri.length()-3);
String uriRequest = baseUri+"/"+query; String uriRequest = baseUri+"/"+query;
logger.trace("resolve storageID request: "+uriRequest); logger.trace("resolve storageID request: "+uriRequest);
return uriRequest; return uriRequest;
@ -195,24 +202,24 @@ public class UriResolverReaderParameterForResolverIndex {
* @throws Exception the exception * @throws Exception the exception
*/ */
public Map<String, String> getHashParameters(String storageID, String fileName, String contentType) throws Exception{ public Map<String, String> getHashParameters(String storageID, String fileName, String contentType) throws Exception{
Map<String, String> hashParameters = new HashMap<String, String>(); Map<String, String> hashParameters = new HashMap<String, String>();
if(storageID==null || storageID.isEmpty()) if(storageID==null || storageID.isEmpty())
throw new Exception("smp url is null or empty"); throw new Exception("smp url is null or empty");
hashParameters.put(storageIDParameter, storageID); hashParameters.put(storageIDParameter, storageID);
if(fileName!=null && !fileName.isEmpty()) if(fileName!=null && !fileName.isEmpty())
hashParameters.put(fileNameParameter, fileName); hashParameters.put(fileNameParameter, fileName);
if(contentType!=null && !contentType.isEmpty()) if(contentType!=null && !contentType.isEmpty())
hashParameters.put(contentTypeParameter, contentType); hashParameters.put(contentTypeParameter, contentType);
return hashParameters; return hashParameters;
} }
/** /**
* Checks if is available. * Checks if is available.
* *
@ -230,7 +237,7 @@ public class UriResolverReaderParameterForResolverIndex {
public String getBaseUri() { public String getBaseUri() {
return baseUri; return baseUri;
} }
/** /**
* Gets the storage id parameter. * Gets the storage id parameter.
* *
@ -257,7 +264,7 @@ public class UriResolverReaderParameterForResolverIndex {
public String getContentTypeParameter() { public String getContentTypeParameter() {
return contentTypeParameter; return contentTypeParameter;
} }
/** /**
* Gets the query. * Gets the query.
* *
@ -267,7 +274,7 @@ public class UriResolverReaderParameterForResolverIndex {
return query; return query;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */

View File

@ -115,6 +115,8 @@ public final class UrlShortener {
isAvailable = false; isAvailable = false;
logger.error("an error occurred in reading RR: ", e); logger.error("an error occurred in reading RR: ", e);
throw new Exception(NO_HTTP_URL_SHORTENER_AVAILABLE); throw new Exception(NO_HTTP_URL_SHORTENER_AVAILABLE);
}finally{
ScopeProvider.instance.reset();
} }
} }

View File

@ -161,7 +161,6 @@ public class WsUtil {
public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{ {
logger.trace("Get Workspace"); logger.trace("Get Workspace");
final ASLSession session = getAslSession(httpSession); final ASLSession session = getAslSession(httpSession);
logger.trace("ASLSession scope: "+session.getScope() + " username: "+session.getUsername()); logger.trace("ASLSession scope: "+session.getScope() + " username: "+session.getUsername());
@ -170,82 +169,11 @@ public class WsUtil {
logger.trace("Scope provider instancied"); logger.trace("Scope provider instancied");
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername()); Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
/*
if (session.getAttribute(METADATACONVERTER_ATTRIBUTE) == null){
logger.trace("Initializing the Metadata converter");
Thread mcLoader = new Thread(new Runnable(){
public void run() {
try {
MetadataConverter mc = new MetadataConverter(logger);
mc.setup(session);
session.setAttribute(METADATACONVERTER_ATTRIBUTE, mc);
}catch (Exception e) {
logger.error("Error initializing the Metadata Converter: "+e.getMessage());
}
}
});
mcLoader.start();
}
if (session.getAttribute(WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE) == null){
logger.trace("Initializing the event collector");
//we prepare the event collector
WorkspaceEventCollector eventCollector = new WorkspaceEventCollector();
workspace.addWorkspaceListener(eventCollector);
session.setAttribute(WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE, eventCollector);
}
*/
/*
if (session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE) == null)
{
logger.trace("Initializing the workspace area builder");
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
//ADDED 03/09/2013
builder.setUserLogged(new InfoContactModel(session.getUsername(), session.getUsername(), session.getUserFullName(), false));
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
}*/
return workspace; return workspace;
} }
// public static MetadataConverter getMetadataConverter(Logger logger, HttpSession httpSession)
// {
// MetadataConverter mc = (MetadataConverter) httpSession.getAttribute(METADATACONVERTER_ATTRIBUTE);
//
// if (mc==null)
// {
//
// mc = new MetadataConverter(logger);
// ASLSession session = getAslSession(httpSession);
// mc.setup(session);
// session.setAttribute(METADATACONVERTER_ATTRIBUTE, mc);
// }
//
// mc.isReady();
//
// return mc;
// }
// public static WorkspaceEventCollector getEventCollector(HttpSession httpSession)
// {
// ASLSession session = getAslSession(httpSession);
// return (WorkspaceEventCollector) session.getAttribute(WsUtil.WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE);
// }
public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpSession httpSession) public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpSession httpSession)
{ {
ASLSession session = getAslSession(httpSession); ASLSession session = getAslSession(httpSession);

View File

@ -0,0 +1,35 @@
/**
*
*/
package org.gcube.portlets.user.workspace;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* May 9, 2016
*/
public class DataMinerTest {
public static void main(String[] args) {
String myToken = "4620e6d0-2313-4f48-9d54-eb3efd01a810";
try {
URL url = new URL("http://dataminer1-d-d4s.d4science.org/wps/WebProcessingService?request=Execute&service=WPS&Version=1.0.0&gcube-token="+myToken+"&lang=en-US&Identifier=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.BIOCLIMATE_HCAF&DataInputs=HCAF_Table_List=http://goo.gl/LTqufC|http://goo.gl/LTqufC;HCAF_Table_Names=h1|h2");
url.openConnection();
}
catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}