merged with brach release 2.13

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@71675 82a268e6-3cf1-43bd-a215-b396298e98cf
task/19600
Francesco Mangiacrapa 11 years ago
parent ff8bf34e70
commit bc643e20c2

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>

@ -151,23 +151,7 @@
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- REMOVE THIS -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.portlets.user</groupId> -->
<!-- <artifactId>opengcubeapplication</artifactId> -->
<!-- <version>1.0.0-SNAPSHOT</version> -->
<!-- <scope>system</scope> -->
<!-- <systemPath>/home/backup-old-home/francesco-mangiacrapa/workspace/opengcubeapplication/target/opengcubeapplication-1.0.0-SNAPSHOT.jar</systemPath> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <artifactId>opengcubeapplication</artifactId> -->
<!-- <groupId>org.gcube.portlets.user</groupId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
</dependencies>
<build>
<resources>

@ -119,6 +119,7 @@ import com.extjs.gxt.ui.client.widget.Info;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasWidgets;
@ -242,7 +243,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
final DialogShareFolder finalDialog = dialogSharedFolder;
final FileModel parentModel = parent;
finalDialog.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@ -288,9 +288,17 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onSuccess(Boolean result) {
if(result)
eventBus.fireEvent(new RefreshFolderEvent(parentFileModel));
if(result){
FileModel parentToRefresh=null;
if(isNewFolder)
parentToRefresh = parentModel;
else
parentToRefresh = parentFileModel;
eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh));
GWT.log("share completed refresh folder : "+parentModel.getName());
}
explorerPanel.unmask();
}
});
@ -383,8 +391,12 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onRefreshItem(RefreshFolderEvent refreshtemEvent) {
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshtemEvent.getFolderTarget().getIdentifier());
notifySubscriber(refreshtemEvent);
if(refreshtemEvent.getFolderTarget()!=null){
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshtemEvent.getFolderTarget().getIdentifier());
notifySubscriber(refreshtemEvent);
}
else
GWT.log("warn: escape refresh because item is null");
}
});
@ -824,7 +836,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(dgt.isValidForm()){
rpcWorkspaceService.renameItem(target.getIdentifier(), newName, new AsyncCallback<Boolean>(){
rpcWorkspaceService.renameItem(target.getIdentifier(), newName, target.getName(), new AsyncCallback<Boolean>(){
@Override
public void onFailure(Throwable caught) {
@ -859,8 +871,24 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private void doDeleteItem(final DeleteItemEvent event){
MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsExplorer.MESSAGE_DELETE, ConstantsExplorer.MESSAGE_CONFIRM_DELETE_ITEM + " "+ event.getFileTarget().getName() +"?");
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
String title = "";
String msg = "";
if(event.getFileTarget().isShared()){
title = ConstantsExplorer.MESSAGE_DELETE;
msg = "This item is shared. Deleting this item will affect other users. Continue?";
}
else{
title = ConstantsExplorer.MESSAGE_DELETE;
msg = ConstantsExplorer.MESSAGE_CONFIRM_DELETE_ITEM + " "+ event.getFileTarget().getName() +"?";
}
MessageBoxConfirm mbc = new MessageBoxConfirm(title, msg);
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
@ -882,12 +910,23 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onSuccess(Boolean result) {
FileModel fileModel = event.getFileTarget();
if(explorerPanel.getAsycTreePanel().deleteItem(fileModel.getIdentifier())){
explorerPanel.getAsycTreePanel().selectItem(fileModel.getParentFileModel().getIdentifier()); //Select parent of item deleted
notifySubscriber(event);
}
//Timer is used for chrome
Timer t = new Timer() {
public void run() {
FileModel fileModel = event.getFileTarget();
if(explorerPanel.getAsycTreePanel().deleteItem(fileModel.getIdentifier())){
explorerPanel.getAsycTreePanel().selectItem(fileModel.getParentFileModel().getIdentifier()); //Select parent of item deleted
notifySubscriber(event);
}
}
};
// Schedule the timer to run once every second, 1000 ms.
t.schedule(250);
}
});
@ -1204,13 +1243,21 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onSuccess(String url) {
String reportUrl = url;
// int last = currentUrl.lastIndexOf("/");
// String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
// Log.trace("Url: "+reportUrl);
// System.out.println("currentUrl " +currentUrl);
System.out.println("reportUrl " +reportUrl);
new WindowOpenUrl(reportUrl, "_self", "");
if(url==null || url.isEmpty()){
String currentUrl = portalURL();
int last = currentUrl.lastIndexOf("/");
String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
// Log.trace("Url: "+reportUrl);
System.out.println("currentUrl " +currentUrl);
System.out.println("reportUrl " +reportUrl);
new WindowOpenUrl(reportUrl, "_self", "");
}
else{
String reportUrl = url;
System.out.println("reportUrl " +reportUrl);
new WindowOpenUrl(reportUrl, "_self", "");
}
}
});
@ -1234,13 +1281,23 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onSuccess(String url) {
String templateUrl = url;
// int last = currentUrl.lastIndexOf("/");
// String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION;
// Log.trace("Url: "+templateUrl);
// System.out.println("currentUrl " +currentUrl);
// System.out.println("reportUrl " +templateUrl);
new WindowOpenUrl(templateUrl, "_self", "");
if(url==null || url.isEmpty()){
String currentUrl = portalURL();
int last = currentUrl.lastIndexOf("/");
String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION;
// Log.trace("Url: "+templateUrl);
System.out.println("currentUrl " +currentUrl);
System.out.println("reportUrl " +templateUrl);
new WindowOpenUrl(templateUrl, "_self", "");
}else{
String templateUrl = url;
new WindowOpenUrl(templateUrl, "_self", "");
}
}
});
@ -1471,12 +1528,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
this.explorerPanel = getPanel();
this.explorerPanel.getAsycTreePanel().setSizeTreePanel(width, height);
this.explorerPanel.getAsycTreePanel().setHeaderTreeVisible(false);
this.explorerPanel.getAsycTreePanel().setHeaderTreeVisible(false);
return explorerPanel.getAsycTreePanel();
}
public void hideSharingFacilities() {
explorerPanel.getAsycTreePanel().getContextMenuTree().setHideSharing();
}
public void refreshRoot(){
if(explorerPanel.getAsycTreePanel()!=null)

@ -256,5 +256,11 @@ public interface Icons extends ClientBundle {
@Source("icons/mime/csv.gif")
ImageResource csv();
@Source("icons/excel.gif")
ImageResource excel();
@Source("icons/ppt.gif")
ImageResource ppt();
}

@ -26,20 +26,34 @@ public class Resources {
private static final String TIFF = "tiff";
private static final String SVG = "svg";
private static final String MSWORD = "msword";
// private static final String DOCX = "msword";
private static final String EXCEL = "excel";
private static final String DOC = "doc";
private static final String DOCX = "vnd.openxmlformats-officedocument.wordprocessingml.document";
private static final String EXCEL = "vnd.ms-excel";
private static final String TXT = "plain";
private static final String MPEG = "mpeg";
private static final String SWF = "swf";
private static final String FLV = "flv";
private static final String AVI = "avi";
private static final Object CSV = "csv";
private static final String CSV = "csv";
private static final String PPT = "vnd.ms-powerpoint";
private static final String PPTX = "vnd.openxmlformats-officedocument.presentationml.presentation";
private static final String XSLX = "vnd.openxmlformats-officedocument.spreadsheetml.sheet";
public static AbstractImagePrototype getIconTable(){
return AbstractImagePrototype.create(ICONS.table());
}
public static AbstractImagePrototype getIconPpt(){
return AbstractImagePrototype.create(ICONS.ppt());
}
public static AbstractImagePrototype getIconExcel(){
return AbstractImagePrototype.create(ICONS.excel());
}
public static AbstractImagePrototype getIconUsers(){
return AbstractImagePrototype.create(ICONS.users());
@ -441,7 +455,7 @@ public class Resources {
return Resources.getIconJpeg();
} else if (XHTLXML.equals(fileExtension)) {
return Resources.getIconXml();
} else if (MSWORD.equals(fileExtension) || MSWORD.equals(fileExtension)) {
} else if (fileExtension.contains(MSWORD) || DOC.equals(fileExtension) || fileExtension.contains(DOCX)) {
return Resources.getIconDoc();
} else if (XML.equals(fileExtension)) {
return Resources.getIconXml();
@ -463,6 +477,10 @@ public class Resources {
return Resources.getIconGif();
} else if (TXT.equals(fileExtension)) {
return Resources.getIconTxt();
}else if (fileExtension.contains(PPT) || fileExtension.equals(PPTX)) {
return Resources.getIconPpt();
}else if (fileExtension.contains(EXCEL) || fileExtension.contains(XSLX)) {
return Resources.getIconExcel();
}
// default case
@ -532,6 +550,8 @@ public class Resources {
int sl = type.indexOf("/");
String extension = type.substring(sl+1, type.length());
// System.out.println("extensions - "+extension);
return Resources.getIconByExtension(extension);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

@ -61,7 +61,7 @@ public interface GWTWorkspaceService extends RemoteService{
public Boolean removeItem(String itemId) throws Exception;
public Boolean renameItem(String itemId, String newName) throws Exception;
public Boolean renameItem(String itemId, String newName, String oldName) throws Exception;
public Boolean removeSmartFolder(String itemId, String name) throws Exception;
@ -116,27 +116,9 @@ public interface GWTWorkspaceService extends RemoteService{
public InfoContactModel getOwnerByItemId(String itemId) throws Exception;
// public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception;
// public List<GWTUser> getUsers() throws Exception;
//
// public List<PortalUser> getPortalUsers() throws Exception;
//
// public void importDocumentAlternatives(List<String> alternativesOIDs, String destinationFolderId) throws Exception;
//
// public void importDocumentParts(List<String> partsOIDs, String destinationFolderId) throws Exception;
//
// public WorkspaceSelectionState loadSelectionState() throws Exception;
// public void saveSelectionState(WorkspaceSelectionState selectionState) throws Exception;
//
// public void sendRequest(String itemId, List<AddresseeUser> addresses) throws Exception;
//
// public Boolean setItemDescription(String itemId, String newDescription) throws Exception;
//
public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception;
List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId)
throws Exception;
}

@ -31,7 +31,7 @@ public interface GWTWorkspaceServiceAsync {
void removeItem(String itemId, AsyncCallback<Boolean> callback);
void renameItem(String itemId, String newName, AsyncCallback<Boolean> callback);
void renameItem(String itemId, String newName, String oldName, AsyncCallback<Boolean> callback);
void createFolder(String nameFolder, String description, FileModel parent, AsyncCallback<FolderModel> callback);
@ -121,30 +121,12 @@ public interface GWTWorkspaceServiceAsync {
void getOwnerByItemId(String itemId,
AsyncCallback<InfoContactModel> callback);
// void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback);
// void getChildrenListsByParentsIdentifier(String itemIdentifier,AsyncCallback<ArrayList<List<FileModel>>> callback);
// public void getUsers(AsyncCallback<List<GWTUser>> callback);
//
// void getPortalUsers(AsyncCallback<List<PortalUser>> callback);
//
// public void importDocumentAlternatives(List<String> alternativesOIDs, String destinationFolderId, AsyncCallback<Void> callback);
//
// public void importDocumentParts(List<String> partsOIDs, String destinationFolderId, AsyncCallback<Void> callback);
//
// public void loadSelectionState(AsyncCallback<WorkspaceSelectionState> callback);
//
// public void saveSelectionState(WorkspaceSelectionState selectionState, AsyncCallback<Void> callback);
//
// public void sendRequest(String itemId, List<AddresseeUser> addressees, AsyncCallback<Void> callback);
//
// public void setItemDescription(String itemId, String newDescription, AsyncCallback<Boolean> callback);
void itemExistsInWorkpaceFolder(String parentId, String itemName,
AsyncCallback<String> callback);
void getListUserSharedBySharedItem(String sharedItemId,
AsyncCallback<List<InfoContactModel>> callback);
}

@ -15,6 +15,7 @@ import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
@ -35,7 +36,6 @@ public class DialogAddFolderAndSmart extends Dialog {
layout.setDefaultWidth(300);
setLayout(layout);
setButtonAlign(HorizontalAlignment.CENTER);
// setHideOnButtonClick(true);
// setIcon(IconHelper.createStyle("user"));

@ -1,6 +1,6 @@
package org.gcube.portlets.user.workspace.client.view.windows;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEvent;
@ -11,7 +11,10 @@ import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.FormEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FileUploadField;
@ -19,14 +22,17 @@ import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.FormPanel.Encoding;
import com.extjs.gxt.ui.client.widget.form.FormPanel.Method;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Hidden;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class DialogUpload extends Window {
private final FormPanel formPanel = new FormPanel();
private FileUploadField fileUploadField = new FileUploadField();
@ -34,214 +40,249 @@ public class DialogUpload extends Window {
private boolean isStatusCompleted = false;
private Button btnSubmit = new Button("Submit");
private Button btnCancel = new Button("Cancel");
// private Text txtParentPath = new Text();
// private int widthSize = 300;
// private final Dialog simple = new Dialog();
private String parentIdentifier = "";
private String parentName = "";
public DialogUpload(String headerTitle, String parentName, final FileModel parent, String fieldLabel){
this.setHeaderVisible(true);
// this.setHeading("File Upload in: " + parentPath);
this.setHeading(headerTitle + parentName);
// this.setHeading(ConstantsExplorer.FILEUPLOADHEADER + parentPath);
// this.txtParentPath.setText("Parent Folder : " + parentPath);
this.setStyleAttribute("margin", "10px");
// Create a FormPanel and point it at a service.
this.parentIdentifier = parent.getIdentifier();
this.parentName = parentName;
this.setStyleAttribute("margin", "10px");
// Create a FormPanel and point it at a service.
// Create a FormPanel and point it at a service.
formPanel.setHeaderVisible(false);
formPanel.setFrame(true);
formPanel.setAction(ConstantsExplorer.UPLOAD_WORKSPACE_SERVICE);
formPanel.setEncoding(Encoding.MULTIPART);
formPanel.setMethod(Method.POST);
formPanel.setButtonAlign(HorizontalAlignment.CENTER);
formPanel.setWidth(400);
// TextField<String> name = new TextField<String>();
// name.setFieldLabel("Name");
// formPanel.add(name);
fileUploadField.setAllowBlank(false);
fileUploadField.setName("uploadFormElement");
// fileUploadField.setRegex("^[a-zA-Z0-9_-]+[ a-zA-Z0-9_().-]+$");
// fileUploadField.setAutoValidate(true);
// fileUploadField.getMessages().setRegexText(ConstantsExplorer.MESSAGE_NAME_FORCE_APHANUMERIC);
formPanel.setHeaderVisible(false);
formPanel.setFrame(true);
formPanel.setAction(ConstantsExplorer.UPLOAD_WORKSPACE_SERVICE);
formPanel.setEncoding(Encoding.MULTIPART);
formPanel.setMethod(Method.POST);
formPanel.setButtonAlign(HorizontalAlignment.CENTER);
formPanel.setWidth(400);
// TextField<String> name = new TextField<String>();
// name.setFieldLabel("Name");
// formPanel.add(name);
fileUploadField.setAllowBlank(false);
fileUploadField.setName("uploadFormElement");
// Add a label
formPanel.add(new Hidden("idFolder",parent.getIdentifier()));
formPanel.add(new Hidden("uploadType",fieldLabel));
// fileUploadField.setFieldLabel(ConstantsExplorer.FILE);
fileUploadField.setFieldLabel(fieldLabel);
// fileUploadField.setWidth(widthSize);
// fileUploadField.setStyleAttribute("width", "350px");
// fileUploadField.setSize(400, 50);
formPanel.add(fileUploadField);
// formPanel.add(this.txtParentPath);
// formPanel.add(btn);
formPanel.addButton(btnSubmit);
formPanel.addButton(btnCancel);
// handle the post
formPanel.addListener(Events.Submit, new Listener<FormEvent>() {
public void handleEvent(FormEvent event) {
formPanel.add(new Hidden("idFolder",parent.getIdentifier()));
formPanel.add(new Hidden("uploadType",fieldLabel));
// fileUploadField.setFieldLabel(ConstantsExplorer.FILE);
fileUploadField.setFieldLabel(fieldLabel);
formPanel.add(fileUploadField);
formPanel.addButton(btnSubmit);
formPanel.addButton(btnCancel);
// handle the post
formPanel.addListener(Events.Submit, new Listener<FormEvent>() {
public void handleEvent(FormEvent event) {
// When the form submission is successfully completed, this
// event is
// fired. Assuming the service returned a response of type
// text/html,
isStatusCompleted = true;
// Log.trace("onSubmitComplete");
isStatusCompleted = true;
// Log.trace("onSubmitComplete");
String result = event.getResultHtml();
// Log.trace("Result "+result);
// Log.trace("Result "+result);
hide();
messageBoxWait.getMessageBoxWait().close();
if (result == null) {
// MessageUtil.showErrorMessage("Error during upload", "An error occurred during file upload.");
// MessageUtil.showErrorMessage("Error during upload", "An error occurred during file upload.");
new MessageBoxAlert("Error during upload", "An error occurred during file upload.", null);
return;
}
//expected <pre>200:Upload complete</pre>
//we strip tags added by webserver
String strippedResult = result.replace("<pre>", "").replace("</pre>", "");
System.out.println(result);
UploadResultMessage resultMessage = UploadResultMessage.parseResult(strippedResult);
// Log.trace("status: "+resultMessage.getStatus());
/*we strip tags added by webserver,
*
* Massi fix because webkit returns
* <pre style="word-wrap: break-word; white-space: pre-wrap;">OK:File france_flag.png(0) imported correctly in /Workspace</pre>
*
* TODO: recall it next time
*/
//String strippedResult = result.replace("<pre>", "").replace("</pre>", ""); //this won't work for webkit
//replaced by new HTML(result).getText()
String strippedResult = new HTML(result).getText();
// com.google.gwt.user.client.Window.alert(result);
// com.google.gwt.user.client.Window.alert("Stripped: " + strippedResult);
final UploadResultMessage resultMessage = UploadResultMessage.parseResult(strippedResult);
switch (resultMessage.getStatus()) {
case ERROR:
new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
break;
case UNKNOWN:
new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
break;
case WARN: {
// workspace.refreshRoot();
// MessageUtil.showWarnMessage("Upload completed with warnings", resultMessage.getMessage());
new MessageBoxAlert("Upload completed with warnings", resultMessage.getMessage(), null);
break;
}
case OK: {
// workspace.refreshRoot();
new MessageBoxInfo("Upload completed successfully", resultMessage.getMessage(), null);
AppControllerExplorer.getEventBus().fireEvent(new CompletedFileUploadEvent(parent,null));
}
case ERROR:
new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
break;
case UNKNOWN:
new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
break;
case WARN: {
new MessageBoxAlert("Upload completed with warnings", resultMessage.getMessage(), null);
break;
}
case OK: {
Timer t = new Timer() {
public void run() {
AppControllerExplorer.getEventBus().fireEvent(new CompletedFileUploadEvent(parent, null));
new MessageBoxInfo("Upload completed successfully", resultMessage.getMessage(), null);
}
};
t.schedule(250);
}
}
}
});
add(formPanel);
add(formPanel);
this.addListeners();
this.setAutoWidth(true);
this.setAutoHeight(true);
this.show();
}
private void addListeners() {
// fileUploadField.addListener(Events.OnChange, new Listener<BaseEvent>() {
//
// @Override
// public void handleEvent(BaseEvent be) {
//// Window.alert("qui");
// }
// });
// fileUploadField.addKeyListener(new KeyListener() { // KEY ENTER
//
// public void componentKeyPress(ComponentEvent event) {
// if (event.getKeyCode() == KeyboardEvents.Enter.getEventCode())
// btnSubmit.fireEvent(Events.OnClick);
//
// }
// });
btnSubmit.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if (fileUploadField.getValue()==null || !(fileUploadField.getValue().length()>2)) {
new MessageBoxAlert(ConstantsExplorer.ERROR, ConstantsExplorer.NOFILESPECIFIED, null);
return;
}
messageBoxWait = new MessageBoxWait(ConstantsExplorer.PROGRESS, ConstantsExplorer.SAVINGYOURFILE, fileUploadField.getValue());
//Progress bar for upload
final Timer t = new Timer()
{
public void run()
{
if (isStatusCompleted)
{
cancel();
messageBoxWait.getMessageBoxWait().close();
}
}
};
t.scheduleRepeating(500);
formPanel.submit();
}
});
btnCancel.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
hide();
}
});
//
// // Add an event handler to the form.
// formPanel.addHandler(Events., Type<new FormHandler() {
//
// @Override
// public void onSubmitComplete(FormSubmitCompleteEvent event) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void onSubmit(FormSubmitEvent event) {
// // TODO Auto-generated method stub
//
// }
// });
}
btnSubmit.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if (fileUploadField.getValue()==null || !(fileUploadField.getValue().length()>2)) {
new MessageBoxAlert(ConstantsExplorer.ERROR, ConstantsExplorer.NOFILESPECIFIED, null);
return;
}
// com.google.gwt.user.client.Window.alert("parentIdentifier "+parentIdentifier);
// com.google.gwt.user.client.Window.alert("fileUploadField.getValue() "+fileUploadField.getValue());
// com.google.gwt.user.client.Window.alert("parentName "+parentName);
/*
* TODO: recall: Some browser would write in fileUploadField.getValue() C:\fakepath\$fileName
*/
String normalizedFileName = fileUploadField.getValue();
// com.google.gwt.user.client.Window.alert("fileUploadField.getValue() "+fileUploadField.getValue());
if (normalizedFileName.contains("\\")) {
normalizedFileName = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\")+1); //remove C:\fakepath\ if exists
// com.google.gwt.user.client.Window.alert("normalizedFileName= "+normalizedFileName);
}
final String label = normalizedFileName;
AppControllerExplorer.rpcWorkspaceService.itemExistsInWorkpaceFolder(parentIdentifier, normalizedFileName, new AsyncCallback<String>() {
@Override
public void onSuccess(final String itemId) {
if(itemId!=null){
MessageBoxConfirm msg = new MessageBoxConfirm("Replace "+label+"?", label + " exists in folder "+parentName + ". Overwrite?");
msg.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
//IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES)){
removeItemAndSubmitForm(itemId);
}
}
});
}else
submitForm(); //ITEM does NOT EXIST SO SUBMIT FORM;
}
@Override
public void onFailure(Throwable caught) {
Info.display("Error", "Sorry an error occurred on the server "+caught.getLocalizedMessage() + ". Please try again later");
}
});
}
});
btnCancel.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
hide();
}
});
}
public void submitForm(){
messageBoxWait = new MessageBoxWait(ConstantsExplorer.PROGRESS, ConstantsExplorer.SAVINGYOURFILE, fileUploadField.getValue());
//Progress bar for upload
final Timer t = new Timer()
{
public void run()
{
if (isStatusCompleted)
{
cancel();
messageBoxWait.getMessageBoxWait().close();
}
}
};
t.scheduleRepeating(500);
formPanel.submit();
}
private void removeItemAndSubmitForm(String itemId){
AppControllerExplorer.rpcWorkspaceService.removeItem(itemId, new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Info.display("Error", "Sorry an error occurred on the server "+caught.getMessage() + ". Please try again later");
}
@Override
public void onSuccess(Boolean result) {
if(result)
submitForm();
}
});
}
}

@ -9,11 +9,11 @@ public class MessageBoxInfo {
private MessageBox box = null;
public MessageBoxInfo(String title, String msg) {
box = MessageBox.info(title, msg, null);
InfoDisplay.display(title, msg);
}
public MessageBoxInfo(String title, String msg, Listener<MessageBoxEvent> listener){
box = MessageBox.info(title, msg, listener);
InfoDisplay.display(title, msg);
}
public MessageBox getMessageBoxConfirm(){

@ -82,7 +82,6 @@ import org.gcube.portlets.user.workspace.server.util.AllScope;
import org.gcube.portlets.user.workspace.server.util.UserUtil;
import org.gcube.portlets.user.workspace.server.util.Util;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*

@ -9,6 +9,7 @@ import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
@ -23,6 +24,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoun
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WrongDestinationException;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderBulkCreator;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalUrl;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries;
@ -460,6 +462,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
logger.trace("removeItem item: "+itemId);
workspace.removeItem(itemId);
return Boolean.TRUE;
} catch (InsufficientPrivilegesException e) {
@ -476,7 +479,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
@Override
public Boolean renameItem(String itemId, String newName) throws Exception {
public Boolean renameItem(String itemId, String newName, String oldName) throws Exception {
workspaceLogger.trace("renameItem itemId: "+itemId+" newName: "+newName);
@ -485,16 +488,37 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
logger.trace("renameItem itemId: "+itemId+" newName: "+newName);
logger.trace("rename item itemId: "+itemId+" old name "+ oldName +", new name: "+newName);
workspace.renameItem(itemId, newName);
//NOTIFIER
WorkspaceItem wsItem = workspace.getItem(itemId);
if(wsItem.isShared()){
try{
List<InfoContactModel> listSharedContact = new ArrayList<InfoContactModel>();
NotificationsProducer notification = getNotificationProducer();
listSharedContact = getListUserSharedByFolderSharedId(wsItem.getIdSharedFolder());
if(Util.isASharedFolder(wsItem)){
notification.notifyFolderRenamed(listSharedContact, oldName, newName, wsItem.getIdSharedFolder());
}else{
WorkspaceFolder sharedFolder = (WorkspaceFolder) workspace.getItem(wsItem.getIdSharedFolder());
notification.notifyItemUpdated(listSharedContact, wsItem, sharedFolder);
}
}catch (Exception e) {
workspaceLogger.error("An error occurred in checkNotify ", e);
return true;
}
}
return true;
} catch (Exception e) {
workspaceLogger.error("Error in server Item rename", e);
throw new Exception(e.getMessage());
}
}
@Override
@ -922,8 +946,34 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
ApplicationReaderFromGenericResource app = new ApplicationReaderFromGenericResource();
try{
ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession());
urlPortlet = app.getURLFromApplicationProfile(oid, Util.getAslSession(this.getThreadLocalRequest().getSession()),this.getThreadLocalRequest().getSession());
if(Util.isVRE(session)){
// GET WORKSPACE
Workspace workspace = HomeLibrary.getUserWorkspace(session);
// GET ITEM FROM WORKSPACE
WorkspaceItem item = workspace.getItem(oid);
// ITEM IS A WorkspaceItemType.FOLDER_ITEM?
if (item.getType().equals(WorkspaceItemType.FOLDER_ITEM)) {
FolderItem folderItem = (FolderItem) item;
if(folderItem.getFolderItemType().equals(FolderItemType.REPORT)){
setValueInSession("idreport", oid);
}else if(folderItem.getFolderItemType().equals(FolderItemType.REPORT_TEMPLATE)){
setValueInSession("idtemplate", oid);
}
return "";
}
}
else
urlPortlet = app.getURLFromApplicationProfile(oid, Util.getAslSession(this.getThreadLocalRequest().getSession()),this.getThreadLocalRequest().getSession());
} catch (Exception e) {
workspaceLogger.error("getURLFromApplicationProfile", e);
@ -1580,7 +1630,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
if(Util.isASharedFolder(wsItem)){
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
@ -1610,6 +1660,45 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
@Override
public List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId) throws Exception{
workspaceLogger.trace("getListUserSharedBySharedItem "+ sharedItemId);
try {
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(sharedItemId);
if(wsItem!=null && wsItem.isShared()){
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
if(wsFolder!=null){
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
List<String> listPortalLogin = wsFolder.getUsers();
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
if(isTestMode())
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
return builder.buildGxtInfoContactFromPortalLogin(listPortalLogin);
}
}
return new ArrayList<InfoContactModel>();
} catch (Exception e) {
workspaceLogger.error("Error in getListUserSharedByItemId ", e);
throw new Exception(e.getMessage());
}
}
@Override
public boolean unSharedFolderByFolderSharedId(String folderSharedId) throws Exception{
@ -1641,7 +1730,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
// contacts = new ArrayList<InfoContactModel>();
// contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
// }
workspaceLogger.trace("UNSHARE WITH: ");
printContacts(contacts);
np.notifyFolderUnSharing(contacts, unSharedFolder);
@ -1725,4 +1814,43 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new Exception(e.getMessage());
}
}
@Override
public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception {
workspaceLogger.trace("get itemExistsInWorkpace by parentId: "+parentId);
System.out.println("get itemExistsInWorkpace by parentId: "+parentId);
try {
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
WorkspaceItem itemFound = workspace.find(itemName, parentId);
if(itemFound==null)
return null;
return itemFound.getId();
}
else
throw new Exception("Invalid Folder parent");
} catch (InternalErrorException e) {
return null;
} catch (ItemNotFoundException e) {
return null;
} catch (Exception e) {
String error = "an error occurred on search item in folder ";
workspaceLogger.error(error, e);
throw new Exception(e.getMessage());
}
}
}

@ -168,7 +168,7 @@ public class UploadServlet extends HttpServlet {
return;
}
if (item.getType() != WorkspaceItemType.FOLDER) {
if (item.getType() != WorkspaceItemType.FOLDER && item.getType() != WorkspaceItemType.SHARED_FOLDER) {
logger.error("Error processing request in upload servlet: Wrong destination item");
sendError(response, "Internal error: Wrong destination item");
return;

@ -3,13 +3,14 @@
*/
package org.gcube.portlets.user.workspace.server.notifications;
import java.util.HashMap;
import java.util.List;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder;
@ -23,7 +24,7 @@ import org.gcube.portlets.user.workspace.server.util.Util;
*/
public class NotificationsProducer {
protected GCUBELog gcubeLogger = new GCUBELog(NotificationsProducer.class);
protected GCUBEClientLog gcubeLogger = new GCUBEClientLog(NotificationsProducer.class);
protected GCUBEScope scope;
protected NotificationsManager notificationsMng;
@ -70,17 +71,18 @@ public class NotificationsProducer {
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getId().compareTo(userId)!=0){
if(infoContactModel.getLogin().compareTo(userId)!=0){
gcubeLogger.trace("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
gcubeLogger.trace("Send notifies new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getId());
//DEBUG
System.out.println("Send notifies new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getId());
System.out.println("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getId(), sharedFolder);
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getLogin(), sharedFolder);
if(!notify)
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId());
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
gcubeLogger.error("An error occured in notifyFolderSharing ", e);
@ -95,6 +97,92 @@ public class NotificationsProducer {
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param sharedFolder
*/
public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final String itemOldName, final String itemNewName, final String idsharedFolder) {
new Thread(){
@Override
public void run() {
gcubeLogger.trace("Send notifies shared folder was renamed is running...");
for (InfoContactModel infoContactModel : listSharedContact) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
gcubeLogger.trace("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
//DEBUG
System.out.println("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
boolean notify = notificationsMng.notifyFolderRenaming(infoContactModel.getLogin(), itemOldName, itemNewName, idsharedFolder);
if(!notify)
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
gcubeLogger.error("An error occured in notifyFolderRenamed ", e);
e.printStackTrace();
}
}
gcubeLogger.trace("notifies share folder was renamed is completed");
}
}.start();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param sharedFolder
*/
public void notifyItemUpdated(final List<InfoContactModel> listSharedContact, final WorkspaceItem item, final WorkspaceFolder sharedFolder) {
new Thread(){
@Override
public void run() {
gcubeLogger.trace("Send notifies shared item was updated is running...");
for (InfoContactModel infoContactModel : listSharedContact) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
gcubeLogger.trace("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), item, sharedFolder);
if(!notify)
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
gcubeLogger.error("An error occured in notifyItemUpdated ", e);
e.printStackTrace();
}
}
gcubeLogger.trace("notifies shared item was updated is completed");
}
}.start();
}
/**
* Runs a new thread to notify the new contacts passed in input
@ -109,30 +197,37 @@ public class NotificationsProducer {
public void run() {
try{
//CREATE TEMPORARY HASH
HashMap<String, InfoContactModel> hashLoginAlreadyShared = new HashMap<String, InfoContactModel>();
for (InfoContactModel infoContactModel : listSharedContact) {
hashLoginAlreadyShared.put(infoContactModel.getLogin(),infoContactModel);
}
if(listSharedContact==null)
return;
for (InfoContactModel infoContactModel : listSharingContact) {
if(!listSharedContact.contains(infoContactModel)){ //if is new contact.. notifies share
if(hashLoginAlreadyShared.get(infoContactModel.getLogin())==null){ //if is new contact.. notifies share
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getId().compareTo(userId)!=0){
if(infoContactModel.getLogin().compareTo(userId)!=0){
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS
try{
gcubeLogger.trace("Send notifies added user "+ infoContactModel.getId() +" to share folder "+sharedFolder.getName() + " for user "+contact.getId());
gcubeLogger.trace("Sending notification to user "+contact.getLogin()+", added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName());
//DEBUG
System.out.println("Send notifies added user "+ infoContactModel.getId() +" to share folder "+sharedFolder.getName() + " for user "+contact.getId());
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin());
boolean notify = notificationsMng.notifyFolderAddedUser(contact.getId(), sharedFolder, infoContactModel.getId());
boolean notify = notificationsMng.notifyFolderAddedUser(contact.getLogin(), sharedFolder, infoContactModel.getLogin());
if(!notify)
gcubeLogger.error("An error occured when notifies user: "+infoContactModel.getId());
gcubeLogger.error("An error occured when notifies user: "+infoContactModel.getLogin());
}catch (Exception e) {
gcubeLogger.error("An error occured in notifyFolderAddedUser ", e);
@ -171,17 +266,17 @@ public class NotificationsProducer {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getId().compareTo(userId)!=0){
if(infoContactModel.getLogin().compareTo(userId)!=0){
gcubeLogger.trace("User id: " +userId + " send notifies un shared folder "+unSharedFolder.getName()+" for user "+infoContactModel.getId());
gcubeLogger.trace("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
//DEBUG
System.out.println("User id: " +userId + " send notifies un shared folder "+unSharedFolder.getName()+" for user "+infoContactModel.getId());
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getId(), unSharedFolder);
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), unSharedFolder);
if(!notify)
gcubeLogger.error("An error occured when notifies user: "+infoContactModel.getId());
gcubeLogger.error("An error occured when notifies user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
gcubeLogger.error("An error occured in notifyFolderUnSharing ", e);
@ -219,23 +314,22 @@ public class NotificationsProducer {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getId().compareTo(userId)!=0){
if(infoContactModel.getLogin().compareTo(userId)!=0){
gcubeLogger.trace("Send notifies added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()+" for user "+infoContactModel.getId());
gcubeLogger.trace("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
System.out.println("Send notifies added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()+" for user "+infoContactModel.getId());
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
// System.out.println("Send notify folder un share user "+infoContactModel.getId());
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getId(), workspaceItem, sharedFolder);
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin());
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
if(!notify){
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId());
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getLogin());
//DEBUG
System.out.println("An error occured when notify user: "+infoContactModel.getId());
System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
}
}
}catch (Exception e) {
@ -271,28 +365,28 @@ public class NotificationsProducer {
public void run() {
// printContacts(listContacts);
gcubeLogger.trace("Send notifies remove item in shared folder is running...");
gcubeLogger.trace("Sending notificationremove item in shared folder is running...");
System.out.println("Send notifies remove item in shared folder is running...");
System.out.println("Sending notification remove item in shared folder is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getId().compareTo(userId)!=0){
if(infoContactModel.getLogin().compareTo(userId)!=0){
gcubeLogger.trace("Send notifies remove item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()+" for user "+infoContactModel.getId());
gcubeLogger.trace("Sending notification to user "+infoContactModel.getLogin() +" removed item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
System.out.println("Send notifies remove item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()+" for user "+infoContactModel.getId());
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getId(), workspaceItem, sharedFolder);
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
if(!notify){
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId());
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getLogin());
//DEBUG
System.out.println("An error occured when notify user: "+infoContactModel.getId());
System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
}
}
}catch (Exception e) {

@ -5,6 +5,7 @@ package org.gcube.portlets.user.workspace.server.util;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
@ -16,6 +17,8 @@ import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType;
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
@ -41,12 +44,13 @@ public class Util {
// public static final String TEST_SCOPE = "/gcube/devsec";
// public static final String TEST_USER = "pasquale.pagano";
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
public static final String TEST_SCOPE = "/gcube";
// public static final String TEST_USER = "federico.defaveri";
// public static final String TEST_USER = "massimiliano.assante";
// public static final String TEST_USER = "pasquale.pagano";
// public static final String TEST_USER = "francesco.mangiacrapa";
// public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
// public static final String TEST_USER = "aureliano.gentile";
public static final String TEST_USER = "test.user";
public static final String TEST_USER_FULL_NAME = "Test User";
@ -65,12 +69,13 @@ public class Util {
//for test only
// httpSession.setAttribute(USERNAME_ATTRIBUTE, TEST_USER);
session = SessionManager.getInstance().getASLSession(sessionID, TEST_USER);
session.setScope(TEST_SCOPE);
if(!withoutPortal){ //TEMPORARY SOLUTION
defaultLogger.error("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND");
session.setScope(TEST_SCOPE);
session.setUserAvatarId(TEST_USER + "Avatar");
session.setUserFullName(TEST_USER_FULL_NAME);
session.setUserEmailAddress(TEST_USER + "@mail.test");
// httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
}
withoutPortal = true;
@ -214,5 +219,27 @@ public class Util {
return session.getUsername();
}
public static boolean isVRE(ASLSession session){
String currentScope = session.getScopeName();
int slashCount = StringUtils.countMatches(currentScope, "/");
if(slashCount < 3){
defaultLogger.trace("currentScope is not VRE");
return false;
}
defaultLogger.trace("currentScope is VRE");
return true;
}
public static boolean isASharedFolder(WorkspaceItem wsItem){
if(wsItem!=null)
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
return false;
}
}

Loading…
Cancel
Save