Task #22596 Ported to git and removed Home Library dep.

This commit is contained in:
Massimiliano Assante 2021-12-22 18:26:22 +01:00
parent ad85a6435b
commit 79965d8b6f
26 changed files with 103 additions and 1032 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target/ /target/
/.DS_Store

View File

@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v1.2.0-SNAPSHOT] - 2021-12-17 ## [v1.2.0-SNAPSHOT] - 2021-12-17
- Ported to git - Task #22596 Ported to git and removed Home Library dep.
## [v1.0.0] - 2019-05-21 ## [v1.0.0] - 2019-05-21

17
pom.xml
View File

@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.6.3</version> <version>3.6.3-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -54,24 +54,29 @@
<artifactId>aslsocial</artifactId> <artifactId>aslsocial</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-wrapper</artifactId>
<version>[1.1.0-SNAPSHOT ,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>notifications-common-library</artifactId> <artifactId>notifications-common-library</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId> <artifactId>authorization-client</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId> <artifactId>common-authorization</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.core</groupId>
<artifactId>social-networking-library</artifactId> <artifactId>common-encryption</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

1
src/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.DS_Store

1
src/main/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.DS_Store

1
src/main/java/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.DS_Store

1
src/main/java/org/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.DS_Store

1
src/main/java/org/gcube/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -0,0 +1 @@
/.DS_Store

View File

@ -1,271 +0,0 @@
package org.gcube.portlets.user.sbdportlets;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.servlet.http.HttpServletRequest;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
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.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.util.WorkspaceUtil;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.notifications.bean.GenericItemBean;
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.upload.FileItem;
import com.liferay.portal.kernel.upload.UploadPortletRequest;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.User;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* upload method/dataset: UserUpload Admin
- Share idea: UserIdea Admin
* Portlet implementation class CollaborateWithUs
*/
public class CollaborateWithUs extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(CollaborateWithUs.class);
private static String SHARE_IDEA_ROLE_MANAGER_NAME = "UserIdea-Admin";
private final static String UPLOADED_FILE_ATTR_NAME = "myfile";
//make sure in the jsp there's <portlet:resourceURL var="uploadFileURL" id="uploadFiles" />
private final static String RESOURCE_URL_ID = "uploadFiles";
public static final String ATTACHMENT_FOLDER ="_shared attachments";
private LiferayRoleManager roleManager = new LiferayRoleManager();
private LiferayUserManager userManager = new LiferayUserManager();
public void addIdea(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException {
try{
User currentUser = (User) actionRequest.getAttribute(WebKeys.USER);
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = themeDisplay.getLayout().getGroupId();
String experiment_name = ParamUtil.getString(actionRequest, "experiment_name");
String people_institutions = ParamUtil.getString(actionRequest, "people_institutions");
String theAbstract = ParamUtil.getString(actionRequest, "abstract");
String experiment_tags = ParamUtil.getString(actionRequest, "experiment_tags");
String[] attachmentIds = ParamUtil.getParameterValues(actionRequest, "selected-attachment");
for (int i = 0; i < attachmentIds.length; i++) {
_log.debug(i+"id="+attachmentIds[i]);
}
SessionMessages.add(actionRequest.getPortletSession(), "method-form-success");
_log.debug("new experiment shared: " + experiment_name);
SessionMessages.add(actionRequest.getPortletSession(), "experiment-form-success");
long teamId = roleManager.getTeam(groupId, SHARE_IDEA_ROLE_MANAGER_NAME).getTeamId();
List<GCubeUser> theManagers = userManager.listUsersByTeam(teamId);
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
boolean result = sendNotificationToUser(request, groupId, currentUser, theManagers,
experiment_name, people_institutions, theAbstract, attachmentIds, experiment_tags);
if (result)
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-experiment-inserted.jsp");
else
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-experiment-error.jsp");
} catch(Exception e){
SessionErrors.add(actionRequest.getPortletSession(),"experiment-form-error");
e.printStackTrace();
}
}
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException, IOException {
String resourceID = resourceRequest.getResourceID();
if (resourceID.equals(RESOURCE_URL_ID)) {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(resourceRequest);
File multipartFile = uploadRequest.getFile(UPLOADED_FILE_ATTR_NAME);
FileItem[] items = uploadRequest.getMultipartParameterMap().get(UPLOADED_FILE_ATTR_NAME);
String fileName = "";
String contentType = "";
for (int i = 0; i < items.length; i++) {
fileName = items[i].getFileName();
contentType = items[i].getContentType();
System.out.println(fileName);
System.out.println(contentType);
}
JSONObject fileObject = JSONFactoryUtil.createJSONObject();
try {
Workspace workspace = getWorkspace(uploadRequest);
String wsItemId = uploadToUserWorkspace(workspace, fileName, contentType, new ByteArrayInputStream(FileUtil.getBytes(multipartFile)));
fileObject.put("itemId", wsItemId);
fileObject.put("fileName", fileName);
} catch (Exception e) {
_log.error("There was an error uploading the file " + fileName, e);
}
resourceResponse.getWriter().println(fileObject);
} else {
_log.debug("nothing to do");
}
}
/**
*
* @param uploadRequest is the XHR http servlet request
* @return
* @throws Exception
*/
private Workspace getWorkspace(UploadPortletRequest uploadRequest ) throws Exception {
Workspace workspace;
try{
PortalContext pContext = PortalContext.getConfiguration();
ScopeProvider.instance.set(pContext.getCurrentScope(uploadRequest));
workspace = HomeLibrary.getUserWorkspace(pContext.getCurrentUser(uploadRequest).getUsername());
}catch(InternalErrorException | HomeNotFoundException | WorkspaceFolderNotFoundException e){
String msg = "Sorry, an error occurred when retrieving workspace item, Refresh an try again";
_log.error("HL error: ",e);
throw new Exception(msg);
}
return workspace;
}
private String uploadToUserWorkspace(Workspace ownerWS, String fileName, String mimeType,InputStream fileData) throws Exception {
WorkspaceFolder attachment = null;
try{
attachment = (WorkspaceFolder) ownerWS.getItemByPath(ownerWS.getRoot().getPath() + "/" + ATTACHMENT_FOLDER);
} catch (ItemNotFoundException e) {
_log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it ");
attachment = ownerWS.getRoot().createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System");
}
String itemName = WorkspaceUtil.getUniqueName(fileName, attachment);
FolderItem item = WorkspaceUtil.createExternalFile(attachment, itemName, "File created automatically by the System", mimeType, fileData);
String toReturn = item.getId();
_log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" +toReturn);
return toReturn;
}
private boolean sendNotificationToUser(HttpServletRequest request, long groupId, User currentUser, List<GCubeUser> theManagers
, String experiment_name, String people_institutions, String theAbstract, String[] attachmentIds, String experiment_tags) throws Exception {
String scope = PortalContext.getConfiguration().getCurrentScope(""+groupId);
_log.info("sendNotificationToUser Scope: " + scope);
String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(scope, currentUser.getScreenName());
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
Workspace workspace = HomeLibrary.getUserWorkspace(currentUser.getScreenName());
List<String> recipientIds = new ArrayList<String>();
List<GenericItemBean> recipients = new ArrayList<GenericItemBean>();
for (GCubeUser addressee : theManagers) {
recipients.add(new GenericItemBean(addressee.getUsername(), addressee.getUsername(), addressee.getFullname(), ""));
recipientIds.add(addressee.getUsername());
}
String subject = "A new user shared an idea";
StringBuilder sb = new StringBuilder("Hi, the following idea was shared by ").append(currentUser.getFullName())
.append(" (").append(currentUser.getEmailAddress()).append(").")
.append("\n\n").append("Experiment name: ").append(experiment_name).append("\n")
.append("\n").append("Involved people and or institutions: ").append(people_institutions).append("\n")
.append("\n").append("Abstract:\n").append(theAbstract).append("\n")
.append("\n").append("Keywords (Comma separated): ").append(experiment_tags).append("\n");
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);
_log.info("Sending upload method message notification to: " + recipientIds.toString());
NotificationsManager nm = new ApplicationNotificationsManager(new SocialNetworkingSite(request), scope, new SocialNetworkingUser(
currentUser.getScreenName(), currentUser.getEmailAddress(), currentUser.getFullName(), ""));
Thread thread = new Thread(new MessageNotificationsThread(recipients, messageId, subject, body, nm));
thread.start();
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 "";
}
}

View File

@ -1,268 +0,0 @@
package org.gcube.portlets.user.sbdportlets;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.servlet.http.HttpServletRequest;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
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.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.util.WorkspaceUtil;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.notifications.bean.GenericItemBean;
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.upload.FileItem;
import com.liferay.portal.kernel.upload.UploadPortletRequest;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.User;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* upload method/dataset: UserUpload Admin
- Share idea: UserIdea Admin
* Portlet implementation class UploadDataset
*/
public class UploadDataset extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(UploadDataset.class);
private static String UPLOAD_DATASET_ROLE_MANAGER_NAME = "UserUpload-Admin";
private final static String UPLOADED_FILE_ATTR_NAME = "myfile";
//make sure in the jsp there's <portlet:resourceURL var="uploadFileURL" id="uploadFiles" />
private final static String RESOURCE_URL_ID = "uploadFiles";
public static final String ATTACHMENT_FOLDER ="_shared attachments";
private LiferayRoleManager roleManager = new LiferayRoleManager();
private LiferayUserManager userManager = new LiferayUserManager();
public void addExperiment(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException {
try{
User currentUser = (User) actionRequest.getAttribute(WebKeys.USER);
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = themeDisplay.getLayout().getGroupId();
String method_name = ParamUtil.getString(actionRequest, "method_name");
String people_institutions = ParamUtil.getString(actionRequest, "people_institutions");
String demo_tutorial = ParamUtil.getString(actionRequest, "demo_tutorial");
String experiment_tags = ParamUtil.getString(actionRequest, "experiment_tags");
String[] attachmentIds = ParamUtil.getParameterValues(actionRequest, "selected-attachment");
for (int i = 0; i < attachmentIds.length; i++) {
System.out.println(i+"id="+attachmentIds[i]);
}
_log.debug("new dataset_name : " + method_name);
SessionMessages.add(actionRequest.getPortletSession(), "method-form-success");
long teamId = roleManager.getTeam(groupId, UPLOAD_DATASET_ROLE_MANAGER_NAME).getTeamId();
List<GCubeUser> theManagers = userManager.listUsersByTeam(teamId);
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
boolean result = sendNotificationToUser(
request, groupId, currentUser, theManagers, method_name, people_institutions, demo_tutorial, attachmentIds, experiment_tags);
if (result)
actionResponse.setRenderParameter("mvcPath", "/html/uploaddataset/view-method-inserted.jsp");
else
actionResponse.setRenderParameter("mvcPath", "/html/uploaddataset/view-method-error.jsp");
}catch(Exception e){
SessionErrors.add(actionRequest.getPortletSession(),"view-method-error");
e.printStackTrace();
}
}
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException, IOException {
String resourceID = resourceRequest.getResourceID();
if (resourceID.equals(RESOURCE_URL_ID)) {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(resourceRequest);
File multipartFile = uploadRequest.getFile(UPLOADED_FILE_ATTR_NAME);
FileItem[] items = uploadRequest.getMultipartParameterMap().get(UPLOADED_FILE_ATTR_NAME);
String fileName = "";
String contentType = "";
for (int i = 0; i < items.length; i++) {
fileName = items[i].getFileName();
contentType = items[i].getContentType();
System.out.println(fileName);
System.out.println(contentType);
}
JSONObject fileObject = JSONFactoryUtil.createJSONObject();
try {
Workspace workspace = getWorkspace(uploadRequest);
String wsItemId = uploadToUserWorkspace(workspace, fileName, contentType, new ByteArrayInputStream(FileUtil.getBytes(multipartFile)));
fileObject.put("itemId", wsItemId);
fileObject.put("fileName", fileName);
} catch (Exception e) {
_log.error("There was an error uploading the file " + fileName, e);
}
resourceResponse.getWriter().println(fileObject);
} else {
_log.debug("nothing to do");
}
}
/**
*
* @param uploadRequest is the XHR http servlet request
* @return
* @throws Exception
*/
private Workspace getWorkspace(UploadPortletRequest uploadRequest ) throws Exception {
Workspace workspace;
try{
PortalContext pContext = PortalContext.getConfiguration();
ScopeProvider.instance.set(pContext.getCurrentScope(uploadRequest));
workspace = HomeLibrary.getUserWorkspace(pContext.getCurrentUser(uploadRequest).getUsername());
}catch(InternalErrorException | HomeNotFoundException | WorkspaceFolderNotFoundException e){
String msg = "Sorry, an error occurred when retrieving workspace item, Refresh an try again";
_log.error("HL error: ",e);
throw new Exception(msg);
}
return workspace;
}
private String uploadToUserWorkspace(Workspace ownerWS, String fileName, String mimeType,InputStream fileData) throws Exception {
WorkspaceFolder attachment = null;
try{
attachment = (WorkspaceFolder) ownerWS.getItemByPath(ownerWS.getRoot().getPath() + "/" + ATTACHMENT_FOLDER);
} catch (ItemNotFoundException e) {
_log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it ");
attachment = ownerWS.getRoot().createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System");
}
String itemName = WorkspaceUtil.getUniqueName(fileName, attachment);
FolderItem item = WorkspaceUtil.createExternalFile(attachment, itemName, "File created automatically by the System", mimeType, fileData);
String toReturn = item.getId();
_log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" +toReturn);
return toReturn;
}
private boolean sendNotificationToUser(HttpServletRequest request, long groupId, User currentUser, List<GCubeUser> theManagers
, String method_name, String people_institutions, String demo_tutorial, String[] attachmentIds, String experiment_tags) throws Exception {
String scope = PortalContext.getConfiguration().getCurrentScope(""+groupId);
_log.info("sendNotificationToUser Scope: " + scope);
String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(scope, currentUser.getScreenName());
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
Workspace workspace = HomeLibrary.getUserWorkspace(currentUser.getScreenName());
List<String> recipientIds = new ArrayList<String>();
List<GenericItemBean> recipients = new ArrayList<GenericItemBean>();
for (GCubeUser addressee : theManagers) {
recipients.add(new GenericItemBean(addressee.getUsername(), addressee.getUsername(), addressee.getFullname(), ""));
recipientIds.add(addressee.getUsername());
}
String subject = "A new user uploaded a method or dataset";
StringBuilder sb = new StringBuilder("Hi, the following dataset/method was shared by ").append(currentUser.getFullName())
.append(" (").append(currentUser.getEmailAddress()).append(").")
.append("\n\n").append("Dataset/Method name: ").append(method_name).append("\n")
.append("\n").append("Involved people and or institutions: ").append(people_institutions).append("\n")
.append("\n").append("Demo/Tutorial:\n").append(demo_tutorial).append("\n")
.append("\n").append("Keywords (Comma separated): ").append(experiment_tags).append("\n");
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);
_log.info("Sending upload method message notification to: " + recipientIds.toString());
NotificationsManager nm = new ApplicationNotificationsManager(new SocialNetworkingSite(request), scope, new SocialNetworkingUser(
currentUser.getScreenName(), currentUser.getEmailAddress(), currentUser.getFullName(), ""));
Thread thread = new Thread(new MessageNotificationsThread(recipients, messageId, subject, body, nm));
thread.start();
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 "";
}
}

View File

@ -7,6 +7,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.portlet.ActionRequest; import javax.portlet.ActionRequest;
@ -21,19 +22,18 @@ import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; 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.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.util.WorkspaceUtil;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.MessageManagerClient;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
import org.gcube.portal.notifications.bean.GenericItemBean; import org.gcube.portal.notifications.bean.GenericItemBean;
import org.gcube.portal.notifications.thread.MessageNotificationsThread; import org.gcube.portal.notifications.thread.MessageNotificationsThread;
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
@ -162,37 +162,72 @@ public class RequestVRE extends MVCPortlet {
_log.debug("nothing to do"); _log.debug("nothing to do");
} }
} }
/** /**
* *
* @param uploadRequest is the XHR http servlet request * @param uploadRequest is the XHR http servlet request
* @return * @return
* @throws Exception * @throws Exception
*/ */
private Workspace getWorkspace(UploadPortletRequest uploadRequest ) throws Exception { public static Workspace getWorkspace(UploadPortletRequest uploadRequest) {
Workspace workspace; long userId;
try{ String username = null;
PortalContext pContext = PortalContext.getConfiguration(); try {
ScopeProvider.instance.set(pContext.getCurrentScope(uploadRequest)); userId = PortalUtil.getUser(uploadRequest).getUserId();
workspace = HomeLibrary.getUserWorkspace(pContext.getCurrentUser(uploadRequest).getUsername()); username = new LiferayUserManager().getUserById(userId).getUsername();
}catch(InternalErrorException | HomeNotFoundException | WorkspaceFolderNotFoundException e){ } catch (Exception e) {
String msg = "Sorry, an error occurred when retrieving workspace item, Refresh an try again"; e.printStackTrace();
_log.error("HL error: ",e); }
throw new Exception(msg);
PortalContext pContext = PortalContext.getConfiguration();
String context = pContext.getCurrentScope(uploadRequest);
ScopeProvider.instance.set(context);
String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(context, username);
SecurityTokenProvider.instance.set(authorizationToken);
ScopeProvider.instance.set(context);
try {
StorageHubWrapper wrap = new StorageHubWrapper(context, authorizationToken);
return wrap.getWorkspace();
}
catch (Exception e) {
e.printStackTrace();
return null;
} }
return workspace;
} }
/**
*
* @param currentUsername
* @param context
* @return
*/
public static Workspace getWorkspace(String currentUsername, String context) {
String username = currentUsername;
String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(context, username);
SecurityTokenProvider.instance.set(authorizationToken);
ScopeProvider.instance.set(context);
try {
StorageHubWrapper wrap = new StorageHubWrapper(context, authorizationToken);
return wrap.getWorkspace();
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
private String uploadToUserWorkspace(Workspace ownerWS, String fileName, String mimeType,InputStream fileData) throws Exception { private String uploadToUserWorkspace(Workspace ownerWS, String fileName, String mimeType,InputStream fileData) throws Exception {
WorkspaceFolder attachment = null; WorkspaceFolder attachment = null;
try{ if (!ownerWS.exists(ATTACHMENT_FOLDER, ownerWS.getRoot().getId())) {
attachment = (WorkspaceFolder) ownerWS.getItemByPath(ownerWS.getRoot().getPath() + "/" + ATTACHMENT_FOLDER);
} catch (ItemNotFoundException e) {
_log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it "); _log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it ");
attachment = ownerWS.getRoot().createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System"); attachment = ownerWS.createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System", ownerWS.getRoot().getId());
} }
String itemName = WorkspaceUtil.getUniqueName(fileName, attachment); else {
FolderItem item = WorkspaceUtil.createExternalFile(attachment, itemName, "File created automatically by the System", mimeType, fileData); attachment = (WorkspaceFolder) ownerWS.find(ATTACHMENT_FOLDER, ownerWS.getRoot().getId()).get(0);
String toReturn = item.getId(); }
WorkspaceItem item = ownerWS.uploadFile(attachment.getId(), fileData, fileName, "File created automatically by the System on " + new Date());
String toReturn = item.getId();
_log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" +toReturn); _log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" +toReturn);
return toReturn; return toReturn;
} }
@ -200,13 +235,13 @@ public class RequestVRE extends MVCPortlet {
private boolean sendNotificationToUser(HttpServletRequest request, long groupId, User currentUser, List<GCubeUser> theManagers private boolean sendNotificationToUser(HttpServletRequest request, long groupId, User currentUser, List<GCubeUser> theManagers
, String vre_name, String theAbstract, String vreManagerName, String email, String[] attachmentIds) throws Exception { , String vre_name, String theAbstract, String vreManagerName, String email, String[] attachmentIds) throws Exception {
String scope = PortalContext.getConfiguration().getCurrentScope(""+groupId); String context = PortalContext.getConfiguration().getCurrentScope(""+groupId);
_log.info("sendNotificationToUser Scope: " + scope); _log.info("sendNotificationToUser context: " + context);
String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(scope, currentUser.getScreenName()); String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(context, currentUser.getScreenName());
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(context);
SecurityTokenProvider.instance.set(authorizationToken); SecurityTokenProvider.instance.set(authorizationToken);
Workspace workspace = HomeLibrary.getUserWorkspace(currentUser.getScreenName()); Workspace workspace = getWorkspace(currentUser.getScreenName(), context);
List<String> recipientIds = new ArrayList<String>(); List<String> recipientIds = new ArrayList<String>();
List<GenericItemBean> recipients = new ArrayList<GenericItemBean>(); List<GenericItemBean> recipients = new ArrayList<GenericItemBean>();
@ -231,12 +266,11 @@ public class RequestVRE extends MVCPortlet {
catch (Exception e) { catch (Exception e) {
_log.error("Ops, could not generate publick link for some of the attachments"); _log.error("Ops, could not generate publick link for some of the attachments");
} }
String messageId =
workspace.getWorkspaceMessageManager(). MessageManagerClient client = AbstractPlugin.messages().build();
sendMessageToPortalLogins(subject, body, attachmentsList, recipientIds); String messageId = client.sendMessage(recipientIds, subject, body, attachmentsList);
_log.info("Sending new VRE Request message notification to: " + recipientIds.toString()); _log.info("Sending new VRE Request message notification to: " + recipientIds.toString());
NotificationsManager nm = new ApplicationNotificationsManager(new SocialNetworkingSite(request), scope, new SocialNetworkingUser( NotificationsManager nm = new ApplicationNotificationsManager(new SocialNetworkingSite(request), context, new SocialNetworkingUser(
currentUser.getScreenName(), currentUser.getEmailAddress(), currentUser.getFullName(), "")); currentUser.getScreenName(), currentUser.getEmailAddress(), currentUser.getFullName(), ""));
Thread thread = new Thread(new MessageNotificationsThread(recipients, messageId, subject, body, nm)); Thread thread = new Thread(new MessageNotificationsThread(recipients, messageId, subject, body, nm));
thread.start(); thread.start();
@ -249,17 +283,18 @@ public class RequestVRE extends MVCPortlet {
* @param workspace * @param workspace
* @param listAttachmentsId * @param listAttachmentsId
* @return * @return
* @throws Exception
* @throws ItemNotFoundException * @throws ItemNotFoundException
* @throws InternalErrorException * @throws InternalErrorException
*/ */
private String getPublicLinksForAttachs(Workspace workspace, List<String> listAttachmentsId) throws ItemNotFoundException, InternalErrorException{ private String getPublicLinksForAttachs(Workspace workspace, List<String> listAttachmentsId) throws ItemNotFoundException, InternalErrorException, Exception {
if (listAttachmentsId != null && (!listAttachmentsId.isEmpty()) ) { if (listAttachmentsId != null && (!listAttachmentsId.isEmpty()) ) {
List<WorkspaceItem> attachments = new ArrayList<WorkspaceItem>(); List<WorkspaceItem> attachments = new ArrayList<WorkspaceItem>();
for (String itemId : listAttachmentsId) { for (String itemId : listAttachmentsId) {
attachments.add(workspace.getItem(itemId)); attachments.add(workspace.getItem(itemId));
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
if(attachments!=null && attachments.size() > 0){ if(attachments!=null && attachments.size() > 0){
@ -268,15 +303,15 @@ public class RequestVRE extends MVCPortlet {
builder.append(msg+"\n"); builder.append(msg+"\n");
for (WorkspaceItem workspaceItem : attachments) { for (WorkspaceItem workspaceItem : attachments) {
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)) { if(workspaceItem.getType().equals(WorkspaceItemType.FILE_ITEM)) {
FolderItem folderItem = (FolderItem) workspaceItem; FolderItem folderItem = (FolderItem) workspaceItem;
String publicLink = ""; String publicLink = "";
String itemName = ""; String itemName = "";
try { try {
itemName = workspaceItem.getName(); itemName = workspaceItem.getName();
publicLink = folderItem.getPublicLink(true); publicLink = workspace.getPublicLinkForFile(folderItem.getId()).toString();
} }
catch (InternalErrorException e) { catch (Exception e) {
_log.warn("An error occurred when creating public link for attachment, skipping file: " + itemName); _log.warn("An error occurred when creating public link for attachment, skipping file: " + itemName);
return ""; return "";
} }

View File

@ -2,13 +2,9 @@
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN" "http://www.liferay.com/dtd/liferay-display_6_2_0.dtd"> <!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN" "http://www.liferay.com/dtd/liferay-display_6_2_0.dtd">
<display> <display>
<category name="SoBigData Apps"> <category name="D4Science">
<portlet id="upload-dataset"></portlet>
<portlet id="collaborate-with-us"></portlet>
<portlet id="access-exploratory"></portlet> <portlet id="access-exploratory"></portlet>
<portlet id="access-application"></portlet> <portlet id="access-application"></portlet>
</category>
<category name="D4Science">
<portlet id="request-vre"></portlet> <portlet id="request-vre"></portlet>
</category> </category>
</display> </display>

View File

@ -1,6 +1,6 @@
name=SBD-UploadAndSharePortlets name=SBD-UploadAndSharePortlets
module-group-id=liferay module-group-id=liferay
module-incremental-version=4 module-incremental-version=6
tags= tags=
short-description= short-description=
change-log= change-log=

View File

@ -2,34 +2,6 @@
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd"> <!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">
<liferay-portlet-app> <liferay-portlet-app>
<portlet>
<portlet-name>upload-dataset</portlet-name>
<icon>/icon.png</icon>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-javascript>
/js/jquery.min.js
</header-portlet-javascript>
<footer-portlet-javascript>
/js/main.js
</footer-portlet-javascript>
<css-class-wrapper>upload-dataset-portlet</css-class-wrapper>
</portlet>
<portlet>
<portlet-name>collaborate-with-us</portlet-name>
<icon>/icon.png</icon>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-javascript>
/js/jquery.min.js
</header-portlet-javascript>
<footer-portlet-javascript>
/js/main.js
</footer-portlet-javascript>
<css-class-wrapper>
collaborate-with-us-portlet
</css-class-wrapper>
</portlet>
<portlet> <portlet>
<portlet-name>access-exploratory</portlet-name> <portlet-name>access-exploratory</portlet-name>
<icon>/icon.png</icon> <icon>/icon.png</icon>

View File

@ -1,72 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0"> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
<portlet>
<portlet-name>upload-dataset</portlet-name>
<display-name>Upload your Method / Dataset</display-name>
<portlet-class>
org.gcube.portlets.user.sbdportlets.UploadDataset
</portlet-class>
<init-param>
<name>view-template</name>
<value>/html/uploaddataset/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Upload your Method / Dataset</title>
<short-title>Upload Dataset</short-title>
<keywords></keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
<portlet>
<portlet-name>collaborate-with-us</portlet-name>
<display-name>Collaborate With Us</display-name>
<portlet-class>
org.gcube.portlets.user.sbdportlets.CollaborateWithUs
</portlet-class>
<init-param>
<name>view-template</name>
<value>/html/collaboratewithus/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Submit your Idea</title>
<short-title>Collaborate With Us</short-title>
<keywords></keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
<portlet> <portlet>
<portlet-name>access-exploratory</portlet-name> <portlet-name>access-exploratory</portlet-name>
<display-name>Access Exploratory</display-name> <display-name>Access Exploratory</display-name>

View File

@ -1,29 +0,0 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@page import="com.liferay.portal.model.User"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
User currentUser = (User) request.getAttribute(WebKeys.USER);
%>
<portlet:renderURL var="normalState"
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
<p class="lead">
Thank you
<%=currentUser.getFirstName()%>. There was an error submitting your request. Please report this issue.
</p>
<a class="btn btn-large btn-primary" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Close and return to home</a>
<div

View File

@ -1,30 +0,0 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@page import="com.liferay.portal.model.User"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
User currentUser = (User) request.getAttribute(WebKeys.USER);
%>
<portlet:renderURL var="normalState"
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
<p class="lead">
Thank you
<%=currentUser.getFirstName()%>. We have been notified about your
request, will get back to you shortly.
</p>
<a class="btn btn-large btn-primary" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Close and return to home</a>
<div

View File

@ -1,104 +0,0 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<portlet:resourceURL var="uploadFileURL" id="uploadFiles" />
<%
if (SessionErrors.contains(renderRequest.getPortletSession(), "experiment-form-error")) {
%>
<liferay-ui:error key="experiment-form-error"
message="Experiment idea form submit had an issue, Please try again." />
<%
}
%>
<portlet:actionURL var="addIdeaActionURL" windowState="maximized"
name="addIdea">
</portlet:actionURL>
<portlet:renderURL var="maximizedState"
windowState="<%=LiferayWindowState.MAXIMIZED.toString()%>" />
<portlet:renderURL var="normalState"
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
<c:set var="maximised" scope="session"
value="${renderRequest.getWindowState().toString().equalsIgnoreCase('maximized')}" />
<c:choose>
<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>
</div>
</c:when>
<c:otherwise>
<script
src="<%=request.getContextPath()%>/js/jquery.uploadfile.min.js"></script>
<script>
$(document).ready(function(){
$("#multipleupload").uploadFile({
url:"<%=uploadFileURL.toString()%>",
multiple : true,
dragDrop : true,
sequential : true,
sequentialCount : 1,
maxFileCount : 3,
maxFileSize: 10*1024*1024,
showStatusAfterSuccess: false,
fileName : "myfile",
onSuccess : function(files, data, xhr, pd) {
var content = JSON.parse(data);
appendChip(content.fileName, content.itemId);
}
});
});
</script>
<a class="btn btn-link btn-large" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Back (Cancel)</a>
<p style="font-size: 15px; padding: 15px;">
Please give us a description about the dataset/method you want to
insert in the catalogue. The SoBigData research, technical and
ethical boards will evaluate your application before the actual
upload. In particular, in case of datasets, please visit also our <a
href="http://146.48.83.51/moodle" target="_blank"> First aid for
Responsible data Scientists</a>: we provide resources and information to
understand and check possible ethical issues for your dataset.
</p>
<div
style="width: 100%; text-align: left; padding: 10px; color: #3B5998;">
<aui:form action="<%=addIdeaActionURL%>" method="post" name="fm">
<aui:input name="experiment_name" label="Experiment name" value=""
required="true" style="width:90%;" />
<aui:input type="textarea" rows="3" name="people_institutions"
label="Involved people and or institutions" value=""
required="true" style="width:90%;" />
<aui:input type="textarea" rows="10" name="abstract"
label="Abstract, 2 pages max" value="" required="true"
style="width:90%;" />
<span> Additional Material (max 3 files, allowed max size per file: 10 MB):</span>
<div id="multipleupload">Select file to attach</div>
<div id="attachedFiles"></div>
<aui:input name="experiment_tags" label="Keywords (Comma separated)"
value="" required="false" style="width:90%;" />
<aui:button-row>
<a class="btn" href="${normalState}"><i class="icon-remove"></i>
Cancel</a>
<aui:button type="submit" value="Submit" />
</aui:button-row>
</aui:form>
</div>
</c:otherwise>
</c:choose>

View File

@ -26,4 +26,3 @@ User currentUser = (User) request.getAttribute(WebKeys.USER);
<a class="btn btn-large btn-primary" href="${normalState}"><i <a class="btn btn-large btn-primary" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Close and return to home</a> class="icon icon-angle-left"></i>&nbsp;Close and return to home</a>
<div

View File

@ -27,4 +27,3 @@ User currentUser = (User) request.getAttribute(WebKeys.USER);
<a class="btn btn-large btn-primary" href="${normalState}"><i <a class="btn btn-large btn-primary" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Close and return to home</a> class="icon icon-angle-left"></i>&nbsp;Close and return to home</a>
<div

View File

@ -1,29 +0,0 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@page import="com.liferay.portal.model.User"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
User currentUser = (User) request.getAttribute(WebKeys.USER);
%>
<portlet:renderURL var="normalState"
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
<p class="lead">
Thank you
<%=currentUser.getFirstName()%>. There was an error submitting your request. Please report this issue.
</p>
<a class="btn btn-large btn-primary" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Close and return to home</a>
<div

View File

@ -1,30 +0,0 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@page import="com.liferay.portal.model.User"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
User currentUser = (User) request.getAttribute(WebKeys.USER);
%>
<portlet:renderURL var="normalState"
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
<p class="lead">
Thank you
<%=currentUser.getFirstName()%>. We have been notified about your
request, will get back to you shortly.
</p>
<a class="btn btn-large btn-primary" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Close and return to home</a>
<div

View File

@ -1,117 +0,0 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<portlet:resourceURL var="uploadFileURL" id="uploadFiles" />
<%
String wpExplorerId = "workspaceexplorerportlet_WAR_workspaceexplorerportlet";
%>
<%
if (SessionErrors.contains(renderRequest.getPortletSession(), "dataset-form-error")) {
%>
<liferay-ui:error key="dataset-form-error"
message="Dataset experiment form submit had an issue, Please try again." />
<%
}
%>
<portlet:actionURL var="addExperimentActionURL" windowState="maximized"
name="addExperiment">
</portlet:actionURL>
<liferay-portlet:renderURL var="wpExplorerPopupURL"
portletName="workspaceexplorerportlet_WAR_workspaceexplorerportlet"
windowState="<%=LiferayWindowState.POP_UP.toString()%>">
</liferay-portlet:renderURL>
<portlet:renderURL var="maximizedState"
windowState="<%=LiferayWindowState.MAXIMIZED.toString()%>" />
<portlet:renderURL var="normalState"
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
<div id="ciccio"></div>
<c:set var="maximised" scope="session"
value="${renderRequest.getWindowState().toString().equalsIgnoreCase('maximized')}" />
<c:choose>
<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-cloud-upload icon-3x"></i></a>
</div>
</c:when>
<c:otherwise>
<script
src="<%=request.getContextPath()%>/js/jquery.uploadfile.min.js"></script>
<script>
$(document).ready(function(){
$("#multipleupload").uploadFile({
url:"<%=uploadFileURL.toString()%>",
multiple : true,
dragDrop : true,
sequential : true,
sequentialCount : 1,
maxFileCount : 3,
maxFileSize: 10*1024*1024,
showStatusAfterSuccess: false,
fileName : "myfile",
onSuccess : function(files, data, xhr, pd) {
var content = JSON.parse(data);
appendChip(content.fileName, content.itemId);
}
});
});
</script>
<a class="btn btn-link btn-large" href="${normalState}"><i
class="icon icon-angle-left"></i>&nbsp;Back (Cancel)</a>
<p style="font-size: 15px; padding: 15px;">
Please give us a description about the dataset/method you want to
insert in the catalogue. The SoBigData research, technical and
ethical boards will evaluate your application before the actual
upload. In particular, in case of datasets, please visit also our <a
href="http://146.48.83.51/moodle" target="_blank"> First aid for
Responsible data Scientists</a>: we provide resources and information to
understand and check possible ethical issues for your dataset.
</p>
<div
style="width: 100%; text-align: left; padding: 10px; color: #3B5998;">
<aui:form action="<%=addExperimentActionURL%>" method="post"
name="fm">
<aui:input name="method_name" label="Dataset/Method name" value=""
required="true" style="width:90%;" />
<aui:input type="textarea" rows="3" name="people_institutions"
label="Involved people and or institutions" value=""
required="true" style="width:90%;" />
<aui:input type="textarea" rows="10" name="demo_tutorial"
label="Description + Demo/Tutorial, 2 pages max" value=""
required="true" style="width:90%;" />
<span> Additional Material (max 3 files, allowed max size per file: 10 MB):</span>
<div id="multipleupload">Select file to attach</div>
<div id="attachedFiles"></div>
<aui:input name="experiment_tags" label="Keywords (Comma separated)"
value="" required="false" style="width:90%;" />
<aui:button-row>
<a class="btn" href="${normalState}"><i class="icon-remove"></i>
Cancel</a>
<aui:button type="submit" value="Submit" />
</aui:button-row>
<p>Please note: depending on the number of attachments it could
take some time (seconds) to submit the request.</p>
</aui:form>
</div>
</c:otherwise>
</c:choose>