Updated pom version at 6.14.0
Added "Get Folder Link" facility git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@131334 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d24597bab4
commit
594638a0dd
23
pom.xml
23
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>workspace-tree-widget</artifactId>
|
||||
<version>6.13.2-SNAPSHOT</version>
|
||||
<version>6.14.0-SNAPSHOT</version>
|
||||
<name>gCube Workspace Tree Widget</name>
|
||||
<description>
|
||||
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
||||
|
@ -147,11 +147,25 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<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>[2.5.0-SNAPSHOT,3.5.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>asm-debug-all</artifactId>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<version>[2.5.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -160,12 +174,7 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
|
|
|
@ -42,6 +42,8 @@ import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.FileUploadEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.FilterScopeEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.FilterScopeEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetFolderLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetFolderLinkEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
||||
|
@ -116,7 +118,8 @@ import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndS
|
|||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart.AddType;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddUrl;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogPublicLink;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink.Link_Type;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogShareLink;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogText;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogWebDavUrl;
|
||||
|
@ -296,6 +299,20 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(GetFolderLinkEvent.TYPE, new GetFolderLinkEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onGetFolderLink(GetFolderLinkEvent getFolderLinkEvent) {
|
||||
GWT.log("getFolderLinkEvent.getSourceFile() "+getFolderLinkEvent.getSourceFile());
|
||||
// TODO Auto-generated method stub
|
||||
if(getFolderLinkEvent.getSourceFile()!=null){
|
||||
GWT.log("getFolderLinkEvent.getSourceFile() "+getFolderLinkEvent.getSourceFile());
|
||||
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Folder Link: Ctrl+C", getFolderLinkEvent.getSourceFile().getIdentifier(), Link_Type.FOLDER_LINK);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(SendMessageEvent.TYPE, new SendMessageEventHandler() {
|
||||
|
||||
|
@ -677,7 +694,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
public void onGetPublicLink(GetPublicLinkEvent getPublicLinkEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
if(getPublicLinkEvent.getSourceFile()!=null){
|
||||
DialogPublicLink dialog = new DialogPublicLink("Copy to clipboard Public Link: Ctrl+C", getPublicLinkEvent.getSourceFile().getIdentifier());
|
||||
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Public Link: Ctrl+C", getPublicLinkEvent.getSourceFile().getIdentifier(), Link_Type.PUBLIC_LINK);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public class ConstantsExplorer {
|
|||
public static final String MESSAGE_REFRESH_FOLDER = "Refresh Folder";
|
||||
public static final String MESSAGE_GET_INFO = "Get Info";
|
||||
public static final String MESSAGE_PUBLIC_LINK = "Get Public Link";
|
||||
public static final String MESSAGE_FOLDER_LINK = "Get Folder Link";
|
||||
public static final String LISTATTACHMENTSNAMES = "Attachments Names";
|
||||
public static final String LISTCONTACTSTOSTRING = "ListContactToString";
|
||||
public static final String STATUS = "Status";
|
||||
|
@ -81,6 +82,7 @@ public class ConstantsExplorer {
|
|||
public static final String REGEX_FOLDER_NAME = "Field name must not begin with one of the following characters";
|
||||
public static final String MESSAGE_SEARCH_FORCE_APHANUMERIC = "Field search must be alphanumeric and not contain special chars!";
|
||||
public static final String MESSAGE_CREATE_NEW_MESSAGE = "Create New Message";
|
||||
|
||||
public static final String FORWARDTO = "Forward to";
|
||||
public static final String MESSAGETYPE = "Message Type";
|
||||
public static final String WEBDAVURLLINKREADMORE = "https://gcube.wiki.gcube-system.org/gcube/index.php/Acces_workspace_from_Desktop_(via_WebDAV)";
|
||||
|
@ -229,6 +231,7 @@ public class ConstantsExplorer {
|
|||
public static final int HEIGHT_DIALOG_SHARE_FOLDER = 445;
|
||||
|
||||
|
||||
|
||||
public static native void log(String txt) /*-{
|
||||
console.log(txt)
|
||||
}-*/;
|
||||
|
|
|
@ -4,17 +4,17 @@ public enum WorkspaceOperation {
|
|||
|
||||
INSERT_FOLDER("INS", "INS"), // Insert Folder
|
||||
ADD_ITEM("ADD", "ADD"), // Add Folder
|
||||
REMOVE("REM", "REM"),
|
||||
UPLOAD_FILE("UPL", "UPL"),
|
||||
DOWNLOAD("DWL", "DWL"),
|
||||
PREVIEW("PRW", "PRW"),
|
||||
RENAME("RNM", "RNM"),
|
||||
REMOVE("REM", "REM"),
|
||||
UPLOAD_FILE("UPL", "UPL"),
|
||||
DOWNLOAD("DWL", "DWL"),
|
||||
PREVIEW("PRW", "PRW"),
|
||||
RENAME("RNM", "RNM"),
|
||||
INSERT_SHARED_FOLDER("ISHF", "ASHF"), // Insert shared Folder
|
||||
PUBLISH_ON_DATA_CATALOGUE("PODC", "PODC"),
|
||||
SHARE("SHR", "SHR"), // SHARE
|
||||
UNSHARE("USHR", "USHR"), // UNSHARE
|
||||
UPLOAD_ARCHIVE("UPA", "UPA"), // Upload Archive
|
||||
LINK("LNK", "LNK"),
|
||||
LINK("LNK", "LNK"),
|
||||
SHOW("SHW", "SHW"), // SHOW
|
||||
ADD_URL("CLK", "CLK"), // Add Url
|
||||
OPEN_REPORT_TEMPLATE("ORT", "ORT"), // Open report template
|
||||
|
@ -36,10 +36,11 @@ public enum WorkspaceOperation {
|
|||
SHARE_LINK("SLK", "SLK"), //SHARE URL LINK
|
||||
PUBLIC_LINK("PLK", "PLK"), //PUBLIC LINK
|
||||
// ADD_ADMINISTRATOR("AAD", "AAD"), // ADD_ADMINISTRATOR
|
||||
VRE_CHANGE_PERIMISSIONS("CHP", "CHP"),
|
||||
EDIT_PERMISSIONS("EDP", "EDP"); //EDIT PERMISSIONS
|
||||
VRE_CHANGE_PERIMISSIONS("CHP", "CHP"),
|
||||
EDIT_PERMISSIONS("EDP", "EDP"), //EDIT PERMISSIONS
|
||||
FOLDER_LINK("FRL", "FRL"); //FOLDER LINK
|
||||
|
||||
|
||||
|
||||
private String id; // ID CONTEXT MENU
|
||||
private String name;
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GetFolderLinkEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 13, 2016
|
||||
*/
|
||||
public class GetFolderLinkEvent extends GwtEvent<GetFolderLinkEventHandler> {
|
||||
public static Type<GetFolderLinkEventHandler> TYPE = new Type<GetFolderLinkEventHandler>();
|
||||
|
||||
private FileModel targetFile = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new gets the folder link event.
|
||||
*
|
||||
* @param target the target
|
||||
*/
|
||||
public GetFolderLinkEvent(FileModel target) {
|
||||
this.targetFile = target;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<GetFolderLinkEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(GetFolderLinkEventHandler handler) {
|
||||
handler.onGetFolderLink(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source file.
|
||||
*
|
||||
* @return the source file
|
||||
*/
|
||||
public FileModel getSourceFile() {
|
||||
return targetFile;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface GetFolderLinkEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 13, 2016
|
||||
*/
|
||||
public interface GetFolderLinkEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On get folder link.
|
||||
*
|
||||
* @param getFolderLinkEvent the get folder link event
|
||||
*/
|
||||
void onGetFolderLink(GetFolderLinkEvent getFolderLinkEvent);
|
||||
}
|
|
@ -711,4 +711,6 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
* @return
|
||||
*/
|
||||
String getMyFirstName();
|
||||
|
||||
PublicLink getFolderLinkForFolderItemId(String itemId, boolean b) throws SessionExpiredException, Exception;
|
||||
}
|
||||
|
|
|
@ -698,4 +698,12 @@ public interface GWTWorkspaceServiceAsync {
|
|||
|
||||
void getMyFirstName(AsyncCallback<String> callback);
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* @param b
|
||||
* @param asyncCallback
|
||||
*/
|
||||
void getFolderLinkForFolderItemId(
|
||||
String itemId, boolean b, AsyncCallback<PublicLink> asyncCallback);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.gcube.portlets.user.workspace.client.event.EditUserPermissionEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetFolderLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||
|
@ -217,6 +218,25 @@ public class ContextMenuTree {
|
|||
|
||||
contextMenu.add(mnPublicLink);
|
||||
|
||||
|
||||
//FOLDER LINK
|
||||
MenuItem mnFolderLink = new MenuItem();
|
||||
mnFolderLink.setId(WorkspaceOperation.FOLDER_LINK.getId());
|
||||
mnFolderLink.setText(ConstantsExplorer.MESSAGE_FOLDER_LINK);
|
||||
mnFolderLink.setIcon(Resources.getIconFolderLink());
|
||||
|
||||
mnFolderLink.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
for (FileModel sel : listSelectedItems) {
|
||||
if(sel.isDirectory())
|
||||
eventBus.fireEvent(new GetFolderLinkEvent(sel));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contextMenu.add(mnFolderLink);
|
||||
|
||||
contextMenu.add(new SeparatorMenuItem());
|
||||
|
||||
MenuItem mnHistory = new MenuItem();
|
||||
|
@ -787,6 +807,7 @@ public class ContextMenuTree {
|
|||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false); //paste
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(false); //folder link
|
||||
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(false); //public link
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(false);
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||
|
@ -843,6 +864,7 @@ public class ContextMenuTree {
|
|||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //refresh
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SENDTO.getId()).setVisible(false); //send to
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(true); //folder link
|
||||
if(selectedItem.isShared()){//IS SHARED
|
||||
|
||||
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(true); //add administrator
|
||||
|
|
|
@ -0,0 +1,232 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
||||
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
import com.extjs.gxt.ui.client.widget.Label;
|
||||
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
|
||||
/**
|
||||
* The Class DialogGetLink.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 13, 2016
|
||||
*/
|
||||
public class DialogGetLink extends Dialog {
|
||||
|
||||
private TextField<String> txtCompleteURL;
|
||||
private TextField<String> txtShortURL;
|
||||
private int widht = 450;
|
||||
private int height = 210;
|
||||
private VerticalPanel vp = new VerticalPanel();
|
||||
|
||||
/**
|
||||
* The Enum Link_Type.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 13, 2016
|
||||
*/
|
||||
public enum Link_Type {PUBLIC_LINK, FOLDER_LINK};
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog get link.
|
||||
*
|
||||
* @param headingTxt the heading txt
|
||||
* @param itemId the item id
|
||||
* @param type the type
|
||||
*/
|
||||
public DialogGetLink(String headingTxt, final String itemId, Link_Type type) {
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setIcon(Resources.getIconPublicLink());
|
||||
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||
vp.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
vp.getElement().getStyle().setPadding(1, Unit.PX);
|
||||
setHeading(headingTxt);
|
||||
setModal(true);
|
||||
setBodyStyle("padding: 3px; background: none");
|
||||
setWidth(widht);
|
||||
setHeight(height);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.CLOSE);
|
||||
setScrollMode(Scroll.AUTOY);
|
||||
|
||||
// label.setText(msgTitle);
|
||||
// label.setStyleName("myWebDavStyle");
|
||||
VerticalPanel vp1 = new VerticalPanel();
|
||||
vp1.setStyleAttribute("margin-top", "8px");
|
||||
txtCompleteURL = new TextField<String>();
|
||||
txtCompleteURL.setStyleAttribute("margin-top", "1px");
|
||||
txtCompleteURL.setWidth(widht-20);
|
||||
txtCompleteURL.setReadOnly(true);
|
||||
// txtCompleteURL.mask("Getting Link...");
|
||||
vp1.add(new Label("Link"));
|
||||
vp1.add(txtCompleteURL);
|
||||
|
||||
VerticalPanel vp2 = new VerticalPanel();
|
||||
vp2.setStyleAttribute("margin-top", "8px");
|
||||
txtShortURL = new TextField<String>();
|
||||
txtShortURL.setStyleAttribute("margin-top", "1px");
|
||||
txtShortURL.setWidth(widht-20);
|
||||
// txtShortURL.mask("Getting Link...");
|
||||
vp2.add(new Label("Short Link"));
|
||||
vp2.add(txtShortURL);
|
||||
|
||||
|
||||
switch (type) {
|
||||
case PUBLIC_LINK:
|
||||
|
||||
vp.mask("Getting Public Link...");
|
||||
|
||||
if(itemId!=null && !itemId.isEmpty()){
|
||||
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(itemId, true, new AsyncCallback<PublicLink>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(PublicLink publicLink) {
|
||||
vp.unmask();
|
||||
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
||||
txtShortURL.setValue(publicLink.getShortURL());
|
||||
selectTxt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
vp.unmask();
|
||||
if(caught instanceof SessionExpiredException){
|
||||
GWT.log("Session expired");
|
||||
AppControllerExplorer.getEventBus().fireEvent(new SessionExpiredEvent());
|
||||
return;
|
||||
}
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
txtCompleteURL.unmask();
|
||||
new MessageBoxAlert("Error", "The item identifier is null", null);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FOLDER_LINK:
|
||||
|
||||
vp.mask("Getting Folder Link... checking permissions");
|
||||
if(itemId!=null && !itemId.isEmpty()){
|
||||
AppControllerExplorer.rpcWorkspaceService.getOwnerByItemId(itemId, new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
vp.unmask();
|
||||
if(caught instanceof SessionExpiredException){
|
||||
GWT.log("Session expired");
|
||||
AppControllerExplorer.getEventBus().fireEvent(new SessionExpiredEvent());
|
||||
return;
|
||||
}
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(InfoContactModel result) {
|
||||
|
||||
if(result.getLogin().compareToIgnoreCase(AppControllerExplorer.myLogin)==0){
|
||||
vp.mask("Getting Folder Link... permissions granted");
|
||||
allowAccessToFolderLink(itemId);
|
||||
}else
|
||||
new MessageBoxAlert("Permission Denied", "You have not permission to get Folder Link, you must be owner or administrator to the folder", null);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
this.getButtonById(Dialog.CLOSE).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
// vp.add(label);
|
||||
vp.add(vp1);
|
||||
vp.add(vp2);
|
||||
|
||||
setFocusWidget(txtCompleteURL);
|
||||
|
||||
add(vp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow access to folder link.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
*/
|
||||
private void allowAccessToFolderLink(String folderId){
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getFolderLinkForFolderItemId(folderId, true, new AsyncCallback<PublicLink>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(PublicLink publicLink) {
|
||||
vp.unmask();
|
||||
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
||||
txtShortURL.setValue(publicLink.getShortURL());
|
||||
selectTxt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
vp.unmask();
|
||||
if(caught instanceof SessionExpiredException){
|
||||
GWT.log("Session expired");
|
||||
AppControllerExplorer.getEventBus().fireEvent(new SessionExpiredEvent());
|
||||
return;
|
||||
}
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the txt value.
|
||||
*
|
||||
* @return the txt value
|
||||
*/
|
||||
public String getTxtValue() {
|
||||
|
||||
return txtCompleteURL.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select txt.
|
||||
*/
|
||||
public void selectTxt(){
|
||||
|
||||
if(txtCompleteURL.getValue()!=null)
|
||||
txtCompleteURL.select(0, txtCompleteURL.getValue().length());
|
||||
}
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
||||
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
import com.extjs.gxt.ui.client.widget.Label;
|
||||
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class DialogPublicLink extends Dialog {
|
||||
|
||||
private TextField<String> txtCompleteURL;
|
||||
private TextField<String> txtShortURL;
|
||||
private int widht = 450;
|
||||
private int height = 210;
|
||||
private VerticalPanel vp = new VerticalPanel();
|
||||
// private Label label = new Label();
|
||||
|
||||
public DialogPublicLink(String headingTxt, final String itemId) {
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setIcon(Resources.getIconPublicLink());
|
||||
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||
vp.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
vp.getElement().getStyle().setPadding(1, Unit.PX);
|
||||
setHeading(headingTxt);
|
||||
setModal(true);
|
||||
setBodyStyle("padding: 3px; background: none");
|
||||
setWidth(widht);
|
||||
setHeight(height);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.CLOSE);
|
||||
setScrollMode(Scroll.AUTOY);
|
||||
|
||||
// label.setText(msgTitle);
|
||||
// label.setStyleName("myWebDavStyle");
|
||||
VerticalPanel vp1 = new VerticalPanel();
|
||||
vp1.setStyleAttribute("margin-top", "8px");
|
||||
txtCompleteURL = new TextField<String>();
|
||||
txtCompleteURL.setStyleAttribute("margin-top", "1px");
|
||||
txtCompleteURL.setWidth(widht-20);
|
||||
txtCompleteURL.setReadOnly(true);
|
||||
// txtCompleteURL.mask("Getting Link...");
|
||||
vp1.add(new Label("Link"));
|
||||
vp1.add(txtCompleteURL);
|
||||
|
||||
VerticalPanel vp2 = new VerticalPanel();
|
||||
vp2.setStyleAttribute("margin-top", "8px");
|
||||
txtShortURL = new TextField<String>();
|
||||
txtShortURL.setStyleAttribute("margin-top", "1px");
|
||||
txtShortURL.setWidth(widht-20);
|
||||
// txtShortURL.mask("Getting Link...");
|
||||
vp2.add(new Label("Short Link"));
|
||||
vp2.add(txtShortURL);
|
||||
|
||||
vp.mask("Getting Link...");
|
||||
|
||||
if(itemId!=null && !itemId.isEmpty()){
|
||||
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(itemId, true, new AsyncCallback<PublicLink>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(PublicLink publicLink) {
|
||||
vp.unmask();
|
||||
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
||||
txtShortURL.setValue(publicLink.getShortURL());
|
||||
selectTxt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
vp.unmask();
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
txtCompleteURL.unmask();
|
||||
new MessageBoxAlert("Error", "The item identifier is null", null);
|
||||
}
|
||||
|
||||
this.getButtonById(Dialog.CLOSE).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
// vp.add(label);
|
||||
vp.add(vp1);
|
||||
vp.add(vp2);
|
||||
|
||||
setFocusWidget(txtCompleteURL);
|
||||
|
||||
add(vp);
|
||||
}
|
||||
|
||||
public String getTxtValue() {
|
||||
|
||||
return txtCompleteURL.getValue();
|
||||
}
|
||||
|
||||
public void selectTxt(){
|
||||
|
||||
if(txtCompleteURL.getValue()!=null)
|
||||
txtCompleteURL.select(0, txtCompleteURL.getValue().length());
|
||||
}
|
||||
}
|
|
@ -59,6 +59,8 @@ import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
|||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.WorkspaceHandledException;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfile;
|
||||
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader;
|
||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
||||
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
|
||||
import org.gcube.portlets.user.workspace.server.util.AclTypeComparator;
|
||||
|
@ -1937,6 +1939,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
workspaceLogger.debug("get List Parents By Item Identifier "+ itemIdentifier +", include Item As (Last) Parent: "+includeItemAsParent);
|
||||
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
if(itemIdentifier==null)
|
||||
return new ArrayList<FileModel>(); //empty list
|
||||
|
||||
|
@ -3523,4 +3528,37 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
public static String concatenateSessionKeyScope(String key, String scope){
|
||||
return key.concat(scope);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getFolderLinkForFolderItemId(java.lang.String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public PublicLink getFolderLinkForFolderItemId(String itemId, boolean b) throws SessionExpiredException, Exception {
|
||||
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
Workspace workspace = getWorkspace();
|
||||
WorkspaceItem item = workspace.getItem(itemId);
|
||||
if(item instanceof WorkspaceFolder){
|
||||
WorkspaceFolder folder = (WorkspaceFolder) item;
|
||||
String folderId = folder.getPublicLink(false);
|
||||
workspaceLogger.info("HL returning folder link id: "+folderId);
|
||||
ApplicationProfileReader apReader = new ApplicationProfileReader("Workspace-Explorer-App", "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl");
|
||||
ApplicationProfile ap = apReader.readProfileFromInfrastrucure();
|
||||
workspaceLogger.info("Application profile returning url: "+ap.getUrl());
|
||||
return new PublicLink(ap.getUrl()+"?folderId="+folderId, "not available");
|
||||
}else
|
||||
throw new NoGcubeItemTypeException("The item is not a Gcube Item");
|
||||
|
||||
} catch (NoGcubeItemTypeException e){
|
||||
workspaceLogger.error("Error in server FormattedGcubeItemProperties: ", e);
|
||||
throw new Exception(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
workspaceLogger.error("Error in server FormattedGcubeItemProperties: ", e);
|
||||
String error = ConstantsExplorer.SERVER_ERROR +" reading Folder Link for id: "+itemId;
|
||||
throw new Exception(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
package org.gcube.portlets.user.workspace.server.reader;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class ApplicationProfile.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jan 14, 2016
|
||||
*/
|
||||
public class ApplicationProfile implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8627579981996968828L;
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private String imageUrl;
|
||||
private String scope;
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Instantiates a new application profile.
|
||||
*/
|
||||
public ApplicationProfile() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new application profile.
|
||||
*
|
||||
* @param key the key
|
||||
* @param name the name
|
||||
* @param description the description
|
||||
* @param imageUrl the image url
|
||||
* @param scope the scope
|
||||
* @param url the url
|
||||
*/
|
||||
public ApplicationProfile(String key, String name, String description, String imageUrl, String scope, String url) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.imageUrl = imageUrl;
|
||||
this.scope = scope;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key.
|
||||
*
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key.
|
||||
*
|
||||
* @param key the new key
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description.
|
||||
*
|
||||
* @param description the new description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image url.
|
||||
*
|
||||
* @return the image url
|
||||
*/
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image url.
|
||||
*
|
||||
* @param imageUrl the new image url
|
||||
*/
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scope.
|
||||
*
|
||||
* @return the scope
|
||||
*/
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scope.
|
||||
*
|
||||
* @param scope the new scope
|
||||
*/
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the url.
|
||||
*
|
||||
* @param url the new url
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApplicationProfile [key=" + key + ", name=" + name + ", description="
|
||||
+ description + ", imageUrl=" + imageUrl + ", scope=" + scope
|
||||
+ ", url=" + url + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portlets.user.workspace.server.reader;
|
||||
|
||||
/**
|
||||
* The Class ApplicationProfileException.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 6, 2016
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ApplicationProfileNotFoundException extends Exception {
|
||||
|
||||
/**
|
||||
* Instantiates a new application profile exception.
|
||||
*
|
||||
* @param message the message
|
||||
*/
|
||||
public ApplicationProfileNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
package org.gcube.portlets.user.workspace.server.reader;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.client;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.Query;
|
||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
|
||||
/**
|
||||
* The Class UriResolverMapReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* May 4, 2015
|
||||
*/
|
||||
public class ApplicationProfileReader {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
||||
public static final String WORKSPACE_EXPLORER_APP_NAME = "Workspace-Explorer-App";
|
||||
|
||||
protected static final String RESOURCE_PROFILE_BODY_END_POINT_URL_TEXT = "/Resource/Profile/Body/EndPoint/URL/text()";
|
||||
protected static final String RESOURCE_PROFILE_BODY_END_POINT_SCOPE_TEXT = "/Resource/Profile/Body/EndPoint/Scope/text()";
|
||||
protected static final String RESOURCE_PROFILE_BODY_TEXT = "/Resource/Profile/Body/text()";
|
||||
protected static final String RESOURCE_PROFILE_BODY_THUMBNAIL_URL_TEXT = "/Resource/Profile/Body/ThumbnailURL/text()";
|
||||
protected static final String RESOURCE_PROFILE_BODY_APP_ID_TEXT = "/Resource/Profile/Body/AppId/text()";
|
||||
protected static final String RESOURCE_PROFILE_DESCRIPTION_TEXT = "/Resource/Profile/Description/text()";
|
||||
protected static final String RESOURCE_PROFILE_NAME_TEXT = "/Resource/Profile/Name/text()";
|
||||
|
||||
// private Logger logger = LoggerFactory.getLogger(UriResolverMapReader.class);
|
||||
//TODO TEMP SOLUTION IN ORDER TO PRINT USING ALSO LOG4J INTO GEOEXPLORER PORTLET
|
||||
private Logger logger = LoggerFactory.getLogger(ApplicationProfileReader.class);
|
||||
private String secondaryType;
|
||||
private String scope;
|
||||
private String resourceName;
|
||||
private String appID;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new application profile reader.
|
||||
*
|
||||
* @param resourceName the resource name
|
||||
* @param appID the app id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ApplicationProfileReader(String resourceName, String appID) throws Exception {
|
||||
|
||||
this.resourceName = resourceName;
|
||||
this.appID = appID;
|
||||
this.secondaryType = SECONDARY_TYPE;
|
||||
this.scope = ScopeProvider.instance.get();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this method looks up the generic resource among the ones available in the infrastructure using scope provider {@link ScopeProvider.instance.get()}
|
||||
* resource name {@value #WORKSPACE_EXPLORER_APP_NAME} and secondaryType {@value #SECONDARY_TYPE}
|
||||
*
|
||||
* @return the applicationProfile profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
/**
|
||||
* this method looks up the applicationProfile profile among the ones available in the infrastructure.
|
||||
*
|
||||
* @return the applicationProfile profile
|
||||
*/
|
||||
public ApplicationProfile readProfileFromInfrastrucure() {
|
||||
|
||||
ApplicationProfile appProf = new ApplicationProfile();
|
||||
String queryString = getGcubeGenericQueryString(secondaryType, appID);
|
||||
String originalScope = null;
|
||||
|
||||
try {
|
||||
|
||||
if(scope==null)
|
||||
throw new Exception("Scope is null, set scope into ScopeProvider");
|
||||
|
||||
logger.info("Trying to fetch ApplicationProfile in the scope: "+scope+", SecondaryType: " + secondaryType + ", AppId: " + appID);
|
||||
Query q = new QueryBox(queryString);
|
||||
DiscoveryClient<String> client = client();
|
||||
List<String> appProfile = client.submit(q);
|
||||
|
||||
if (appProfile == null || appProfile.size() == 0)
|
||||
throw new ApplicationProfileNotFoundException("ApplicationProfile with SecondaryType: " + secondaryType + ", AppId: " + appID +" is not registered in the scope: "+scope);
|
||||
else {
|
||||
String elem = appProfile.get(0);
|
||||
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
|
||||
XPathHelper helper = new XPathHelper(node);
|
||||
|
||||
List<String> currValue = null;
|
||||
currValue = helper.evaluate(RESOURCE_PROFILE_NAME_TEXT);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
appProf.setName(currValue.get(0));
|
||||
}
|
||||
else throw new ApplicationProfileNotFoundException("Your applicationProfile NAME was not found in the profile");
|
||||
|
||||
currValue = helper.evaluate(RESOURCE_PROFILE_DESCRIPTION_TEXT);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
appProf.setDescription(currValue.get(0));
|
||||
}
|
||||
else logger.warn("No Description exists for " + appProf.getName());
|
||||
|
||||
currValue = helper.evaluate(RESOURCE_PROFILE_BODY_APP_ID_TEXT);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
appProf.setKey(currValue.get(0));
|
||||
}
|
||||
else throw new ApplicationProfileNotFoundException("Your applicationProfile ID n was not found in the profile, consider adding <AppId> element in <Body>");
|
||||
|
||||
currValue = helper.evaluate(RESOURCE_PROFILE_BODY_THUMBNAIL_URL_TEXT);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
appProf.setImageUrl(currValue.get(0));
|
||||
}
|
||||
else{
|
||||
logger.warn("Null or empty <ThumbnailURL> element in <Body>" + appProf.getName());
|
||||
}
|
||||
|
||||
currValue = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/Scope/text()");
|
||||
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
List<String> scopes = currValue;
|
||||
String currentScope = scopes.get(0);
|
||||
|
||||
int slashCount = StringUtils.countMatches(currentScope, "/");
|
||||
|
||||
if(slashCount < 3){//CASE not VRE - set session scope
|
||||
logger.info("Scope "+ scope.toString() + " is not a VRE");
|
||||
|
||||
List<String> listSessionScope = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/Sessionscope/text()"); //get session scope of i+1-mo scope
|
||||
|
||||
if(listSessionScope!=null && listSessionScope.size()>0){ //If sessions scope exists
|
||||
|
||||
logger.trace("setting session scope "+ listSessionScope.get(0));
|
||||
appProf.setScope(listSessionScope.get(0));
|
||||
}
|
||||
else{
|
||||
logger.trace("session scope not exists setting scope "+ scope.toString());
|
||||
appProf.setScope(scope.toString());
|
||||
}
|
||||
}
|
||||
else{ //CASE IS A VRE
|
||||
logger.info("Scope "+ scope.toString() + " is a VRE");
|
||||
appProf.setScope(scope.toString());
|
||||
|
||||
}
|
||||
|
||||
//RETRIEVE URL
|
||||
currValue = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/URL/text()");
|
||||
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
String url = currValue.get(0);
|
||||
// System.out.println("URL "+url);
|
||||
if(url!=null)
|
||||
appProf.setUrl(url);
|
||||
else
|
||||
throw new ApplicationProfileNotFoundException("Your applicationProfile URL was not found in the profile for Scope: " + scope.toString());
|
||||
}
|
||||
else throw new ApplicationProfileNotFoundException("Your applicationProfile URL was not found in the profile for Scope: " + scope.toString());
|
||||
|
||||
}
|
||||
else throw new ApplicationProfileNotFoundException("Your applicationProfile with scope "+scope.toString()+" was not found in the profile, consider adding <EndPoint><Scope> element in <Body>");
|
||||
|
||||
return appProf;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while trying to fetch applicationProfile profile from the infrastructure", e);
|
||||
return null;
|
||||
}finally{
|
||||
if(originalScope!=null && !originalScope.isEmpty()){
|
||||
ScopeProvider.instance.set(originalScope);
|
||||
logger.info("scope provider setted to orginal scope: "+originalScope);
|
||||
}else{
|
||||
ScopeProvider.instance.reset();
|
||||
logger.info("scope provider reset");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getGcubeGenericQueryString(String secondaryType, String appId){
|
||||
|
||||
return "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
|
||||
"where $profile/Profile/SecondaryType/string() eq '"+secondaryType+"' and $profile/Profile/Body/AppId/string() " +
|
||||
" eq '" + appId + "'" +
|
||||
"return $profile";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the secondary type.
|
||||
*
|
||||
* @return the secondary type
|
||||
*/
|
||||
public String getSecondaryType() {
|
||||
return secondaryType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the scope.
|
||||
*
|
||||
* @return the scope
|
||||
*/
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resource name.
|
||||
*
|
||||
* @return the resource name
|
||||
*/
|
||||
public String getResourceName() {
|
||||
return resourceName;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ApplicationProfileReader [secondaryType=");
|
||||
builder.append(secondaryType);
|
||||
builder.append(", scope=");
|
||||
builder.append(scope);
|
||||
builder.append(", resourceName=");
|
||||
builder.append(resourceName);
|
||||
builder.append(", appID=");
|
||||
builder.append(appID);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
// try {
|
||||
// ScopeProvider.instance.set("/gcube");
|
||||
// ApplicationProfileReader ap = new ApplicationProfileReader("Workspace-Explorer-App", "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl");
|
||||
// System.out.println(ap.readProfileFromInfrastrucure());
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
|
@ -55,7 +55,7 @@ public class WsUtil {
|
|||
public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
|
||||
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV
|
||||
|
||||
public static final String TEST_SCOPE = "/gcube/devsec";
|
||||
public static final String TEST_SCOPE = "/gcube";
|
||||
|
||||
// public static final String TEST_USER = "pasquale.pagano";
|
||||
// public static final String TEST_USER = "federico.defaveri";
|
||||
|
|
|
@ -1,31 +1,39 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 3, 2015
|
||||
* The Class PublicLink.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 13, 2016
|
||||
*/
|
||||
public class PublicLink implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8157172818802297440L;
|
||||
|
||||
private String completeURL;
|
||||
private String shortURL;
|
||||
|
||||
/**
|
||||
* Instantiates a new public link.
|
||||
*/
|
||||
public PublicLink() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param completeURL
|
||||
* @param shortURL
|
||||
* Instantiates a new public link.
|
||||
*
|
||||
* @param completeURL the complete url
|
||||
* @param shortURL the short url
|
||||
*/
|
||||
public PublicLink(String completeURL, String shortURL) {
|
||||
super();
|
||||
|
@ -34,6 +42,8 @@ public class PublicLink implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the complete url.
|
||||
*
|
||||
* @return the completeURL
|
||||
*/
|
||||
public String getCompleteURL() {
|
||||
|
@ -41,6 +51,8 @@ public class PublicLink implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the short url.
|
||||
*
|
||||
* @return the shortURL
|
||||
*/
|
||||
public String getShortURL() {
|
||||
|
@ -48,16 +60,18 @@ public class PublicLink implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param completeURL
|
||||
* the completeURL to set
|
||||
* Sets the complete url.
|
||||
*
|
||||
* @param completeURL the completeURL to set
|
||||
*/
|
||||
public void setCompleteURL(String completeURL) {
|
||||
this.completeURL = completeURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shortURL
|
||||
* the shortURL to set
|
||||
* Sets the short url.
|
||||
*
|
||||
* @param shortURL the shortURL to set
|
||||
*/
|
||||
public void setShortURL(String shortURL) {
|
||||
this.shortURL = shortURL;
|
||||
|
@ -65,7 +79,7 @@ public class PublicLink implements Serializable {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue