git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/sbd-uploadshare-portlet@163017 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
30e57e7efb
commit
77db56649d
|
@ -66,9 +66,9 @@ public class CollaborateWithUs extends MVCPortlet {
|
|||
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
|
||||
boolean result = sendNotificationToUser(request, groupId, currentUser, theManagers, experiment_name, people_institutions, theAbstract, experiment_tags);
|
||||
if (result)
|
||||
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-experiment-inserted.jsp");
|
||||
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-method-inserted.jsp");
|
||||
else
|
||||
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-experiment-error.jsp");
|
||||
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-method-error.jsp");
|
||||
} catch(Exception e){
|
||||
SessionErrors.add(actionRequest.getPortletSession(),"experiment-form-error");
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -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 "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<c:when test="${not maximised}">
|
||||
<div style="width: 100%; text-align: center; color: #3B5998;">
|
||||
<a class="btn btn-link" href="${maximizedState}"><i
|
||||
class="icon icon-share icon-3x"></i></a>
|
||||
class="icon icon-cloud-upload icon-3x"></i></a>
|
||||
</div>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
|
|
Loading…
Reference in New Issue