|
|
|
@ -15,8 +15,13 @@ import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
|
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
|
|
|
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
|
|
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
|
|
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
|
|
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
|
|
|
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
|
|
|
|
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
|
|
|
import org.gcube.common.portal.PortalContext;
|
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
|
import org.gcube.portal.notifications.bean.GenericItemBean;
|
|
|
|
@ -72,9 +77,9 @@ public class UploadDataset extends MVCPortlet {
|
|
|
|
|
boolean result = sendNotificationToUser(
|
|
|
|
|
request, groupId, currentUser, theManagers, method_name, people_institutions, demo_tutorial, attachmentIds, experiment_tags);
|
|
|
|
|
if (result)
|
|
|
|
|
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-method-inserted.jsp");
|
|
|
|
|
actionResponse.setRenderParameter("mvcPath", "/html/uploaddataset/view-experiment-inserted.jsp");
|
|
|
|
|
else
|
|
|
|
|
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-method-error.jsp");
|
|
|
|
|
actionResponse.setRenderParameter("mvcPath", "/html/uploaddataset/view-experiment-error.jsp");
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
SessionErrors.add(actionRequest.getPortletSession(),"view-method-error");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -107,6 +112,12 @@ public class UploadDataset extends MVCPortlet {
|
|
|
|
|
|
|
|
|
|
List<String> attachmentsList = Arrays.asList(attachmentIds);
|
|
|
|
|
String body = sb.toString();
|
|
|
|
|
try {
|
|
|
|
|
body += getPublicLinksForAttachs(workspace, attachmentsList);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
_log.error("Ops, could not generate publick link for some of the attachments");
|
|
|
|
|
}
|
|
|
|
|
String messageId =
|
|
|
|
|
workspace.getWorkspaceMessageManager().
|
|
|
|
|
sendMessageToPortalLogins(subject, body, attachmentsList, recipientIds);
|
|
|
|
@ -120,4 +131,52 @@ public class UploadDataset extends MVCPortlet {
|
|
|
|
|
return (messageId != null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param workspace
|
|
|
|
|
* @param listAttachmentsId
|
|
|
|
|
* @return
|
|
|
|
|
* @throws ItemNotFoundException
|
|
|
|
|
* @throws InternalErrorException
|
|
|
|
|
*/
|
|
|
|
|
private String getPublicLinksForAttachs(Workspace workspace, List<String> listAttachmentsId) throws ItemNotFoundException, InternalErrorException{
|
|
|
|
|
|
|
|
|
|
if (listAttachmentsId != null && (!listAttachmentsId.isEmpty()) ) {
|
|
|
|
|
List<WorkspaceItem> attachments = new ArrayList<WorkspaceItem>();
|
|
|
|
|
for (String itemId : listAttachmentsId) {
|
|
|
|
|
attachments.add(workspace.getItem(itemId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
if(attachments!=null && attachments.size() > 0){
|
|
|
|
|
builder.append("\n\n\nThe following ");
|
|
|
|
|
String msg = attachments.size()>1?"files were attached to this message:":"file was attached to this message:";
|
|
|
|
|
builder.append(msg+"\n");
|
|
|
|
|
for (WorkspaceItem workspaceItem : attachments) {
|
|
|
|
|
|
|
|
|
|
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)) {
|
|
|
|
|
FolderItem folderItem = (FolderItem) workspaceItem;
|
|
|
|
|
String publicLink = "";
|
|
|
|
|
String itemName = "";
|
|
|
|
|
try {
|
|
|
|
|
itemName = workspaceItem.getName();
|
|
|
|
|
publicLink = folderItem.getPublicLink(true);
|
|
|
|
|
}
|
|
|
|
|
catch (InternalErrorException e) {
|
|
|
|
|
_log.warn("An error occurred when creating public link for attachment, skipping file: " + itemName);
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
builder.append(itemName + " ("+publicLink+")");
|
|
|
|
|
builder.append("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_log.debug("returning public links: "+builder.toString());
|
|
|
|
|
return builder.toString();
|
|
|
|
|
}
|
|
|
|
|
else return "";
|
|
|
|
|
}
|
|
|
|
|
else return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|