2.13 final added udate notifications if report is shared
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@71464 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b1892fbda0
commit
e5fff81cf0
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/reports-4.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/reports-4.1.5-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -30,5 +30,6 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/reports-4.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="lib" path="/Users/massi/portal/Portal-Bundle/gCore/lib/is-collector-stubs-3.0.0-20130114.171438-377.jar"/>
|
||||
<classpathentry kind="output" path="target/reports-4.1.5-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#Fri Mar 15 19:55:49 CET 2013
|
||||
#Fri Mar 15 19:58:46 CET 2013
|
||||
=\=\=\=\=\=\=
|
||||
<<<<<<<=.mine
|
||||
>>>>>>>=.r71295
|
||||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.1.0-SNAPSHOT
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.1.5-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="report-exporter-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/report-exporter-widget/report-exporter-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="reports"/>
|
||||
</wb-module>
|
||||
|
|
28
pom.xml
28
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>reports</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.1.5-SNAPSHOT</version>
|
||||
<name>gCube Reports Portlet</name>
|
||||
<description>
|
||||
gCube Reports Portlet.
|
||||
|
@ -79,14 +79,26 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<version>[3.2.1-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
|
||||
<version>[3.2.1-SNAPSHOT, 3.2.2-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>ghn-client-runtime</artifactId>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslsocial</artifactId>
|
||||
<version>[0.1.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||
<scope>${setScope}</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>ghn-client-runtime</artifactId>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
|
@ -123,6 +135,12 @@
|
|||
<artifactId>workspace-light-tree</artifactId>
|
||||
<version>[2.9.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>${setScope}</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>is-collector-stubs</artifactId>
|
||||
<groupId>org.gcube.informationsystem</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.admin</groupId>
|
||||
|
@ -165,6 +183,12 @@
|
|||
<version>[1.3.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<classifier>${setClassifier}</classifier>
|
||||
<scope>${setScope}</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>is-collector-stubs</artifactId>
|
||||
<groupId>org.gcube.informationsystem</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
|
|
|
@ -1147,7 +1147,28 @@ public class Presenter {
|
|||
* @param type
|
||||
*/
|
||||
public void showExportSaveOptions(final String filePath, final String itemName, final TypeExporter type) {
|
||||
ExportOptions exo = new ExportOptions(this, toolBoxPanel, filePath, itemName, type, reportService);
|
||||
/*
|
||||
* I need to save a temp file, in case the user uses the Save & Open.
|
||||
* Smart popup blockers will allow a popup if it is directly associated to a user’s action.
|
||||
* If it’s delayed in anyway, there’s a good chance it’s going to get blocked. The exported File needs to be there when clicking open.
|
||||
*/
|
||||
reportService.save(filePath, null, "system.tmp", type, true, new AsyncCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String createdItemId) {
|
||||
//here i pass the temp createdItemId
|
||||
showExportPanel(filePath, itemName, type, createdItemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("Error: " + caught.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void showExportPanel(final String filePath, final String itemName, final TypeExporter type, String tempFileId) {
|
||||
ExportOptions exo = new ExportOptions(this, toolBoxPanel, filePath, itemName, type, reportService, tempFileId);
|
||||
exportsPanel.add(exo);
|
||||
}
|
||||
|
||||
|
|
|
@ -412,10 +412,10 @@ public class TemplateModel {
|
|||
public void saveReport (String folderid, String name) {
|
||||
modelService.saveReport(folderid, name, new AsyncCallback<Void>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("Report Not Saved: " + caught.getMessage());
|
||||
MessageBox.alert("Warning","Report Not Saved: " + caught.getMessage(), null);
|
||||
}
|
||||
public void onSuccess(Void result) {
|
||||
Window.alert("Report Saved Successfully");
|
||||
MessageBox.info("Saving Operation","Report Saved Successfully", null);
|
||||
presenter.refreshWorkspace();
|
||||
}
|
||||
});
|
||||
|
@ -432,7 +432,7 @@ public class TemplateModel {
|
|||
MessageBox.alert("Warning","Report Not Saved: " + caught.getMessage(), null);
|
||||
}
|
||||
public void onSuccess(Void result) {
|
||||
MessageBox.alert("Warning","Report Saved Successfully", null);
|
||||
MessageBox.info("Saving Operation","Report Saved Successfully", null);
|
||||
presenter.refreshWorkspace();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -34,15 +34,15 @@ public class ExportOptions extends Composite {
|
|||
@UiField HTML save;
|
||||
@UiField HTML saveAs;
|
||||
|
||||
|
||||
private String tempFileId;
|
||||
private String filePath;
|
||||
private String itemName;
|
||||
private String workspaceFolderId;
|
||||
|
||||
private TypeExporter type;
|
||||
private ReportServiceAsync rpc;
|
||||
private Presenter p;
|
||||
|
||||
public ExportOptions(Presenter p, ToolboxPanel tbp, final String filePath, final String itemName, final TypeExporter type, ReportServiceAsync rpc) {
|
||||
public ExportOptions(Presenter p, ToolboxPanel tbp, final String filePath, final String itemName, final TypeExporter type, ReportServiceAsync rpc, String tempFileId) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.tbp = tbp;
|
||||
this.filePath = filePath;
|
||||
|
@ -50,7 +50,7 @@ public class ExportOptions extends Composite {
|
|||
this.type= type;
|
||||
this.rpc = rpc;
|
||||
this.p = p;
|
||||
workspaceFolderId = null;
|
||||
this.tempFileId = tempFileId;
|
||||
}
|
||||
|
||||
@UiHandler("saveOpen")
|
||||
|
@ -73,7 +73,7 @@ public class ExportOptions extends Composite {
|
|||
private void doCallBack(ExportMode mode) {
|
||||
switch(mode) {
|
||||
case SAVE:
|
||||
rpc.save(filePath, workspaceFolderId, itemName, type, true, new AsyncCallback<String>() {
|
||||
rpc.save(filePath, null, itemName, type, true, new AsyncCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String createdItemId) {
|
||||
p.clearExportPanel();
|
||||
|
@ -112,12 +112,17 @@ public class ExportOptions extends Composite {
|
|||
break;
|
||||
case
|
||||
SAVE_OPEN:
|
||||
rpc.save(filePath, workspaceFolderId, itemName, type, true, new AsyncCallback<String>() {
|
||||
/*
|
||||
* Smart popup blockers (Chrome and Safari have them) will allow a popup if it is directly associated to a user’s action.
|
||||
* If it’s delayed in anyway, there’s a good chance it’s going to get blocked.
|
||||
* So the exported File needs to be there when clicking open, and I've saved a temp version previously.
|
||||
*/
|
||||
tbp.showExportedVersion(tempFileId, itemName);
|
||||
rpc.save(filePath, null, itemName, type, true, new AsyncCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String createdItemId) {
|
||||
p.clearExportPanel();
|
||||
tbp.refreshRoot();
|
||||
tbp.showExportedVersion(createdItemId, itemName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.portlets.user.reportgenerator.server.servlet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
*
|
||||
*/
|
||||
public class NotificationsThread implements Runnable {
|
||||
private static GCUBEClientLog _log = new GCUBEClientLog(NotificationsThread.class);
|
||||
private static final String WORKSPACE_PORTLET_ID = "org.gcube.portlets.user.wsmail.server.WsMailServiceImpl";
|
||||
|
||||
|
||||
private NotificationsManager nm;
|
||||
private List<String> userIdsToBeNotified;
|
||||
private WorkspaceItem subjectItem;
|
||||
private WorkspaceFolder sharedFolder;
|
||||
|
||||
|
||||
public NotificationsThread(ASLSession session, List<String> userIdsToBeNotified, WorkspaceItem item, WorkspaceFolder sharedFolder) {
|
||||
nm = new ApplicationNotificationsManager(session, WORKSPACE_PORTLET_ID);
|
||||
this.userIdsToBeNotified = userIdsToBeNotified;
|
||||
subjectItem = item;
|
||||
this.sharedFolder = sharedFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String userId : userIdsToBeNotified) {
|
||||
try {
|
||||
boolean notifResult = nm.notifyUpdatedItem(userId, subjectItem, sharedFolder);
|
||||
_log.trace("Update Notification sent to " + userId + " result="+notifResult);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -31,7 +31,6 @@ import org.gcube.application.framework.core.session.ASLSession;
|
|||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.common.core.scope.GCUBEScope.MalformedScopeExpressionException;
|
||||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
|
@ -57,7 +56,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
|||
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.WorkspaceItemType;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
|
@ -70,9 +69,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Ima
|
|||
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries;
|
||||
import org.gcube.portlets.user.reportgenerator.client.ReportConstants;
|
||||
import org.gcube.portlets.user.reportgenerator.client.ReportService;
|
||||
import org.gcube.portlets.user.reportgenerator.client.model.ExportManifestationType;
|
||||
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.CreateReportLogEntry;
|
||||
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.GenerateReportLogEntry;
|
||||
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenReportLogEntry;
|
||||
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenWorkflowLogEntry;
|
||||
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.SaveWorkflowLogEntry;
|
||||
|
@ -100,19 +97,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
* used for debugging in eclipse
|
||||
*/
|
||||
private boolean withinPortal = true;
|
||||
/**
|
||||
* EXPORT DIR
|
||||
*/
|
||||
private static final String EXPORTS_DIR = "EXPORTS";
|
||||
/**
|
||||
* EXPORT DIR
|
||||
*/
|
||||
private static final String TEST_SCOPE = "/gcube/devsec/devVRE";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String USERNAME_ATTRIBUTE = "user";
|
||||
private static final String TEST_SCOPE = "/gcube/devsec/devVRE";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -152,8 +138,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
public static final String PREVIOUS_REPORT_INSTANCE = "myPreviousReport";
|
||||
|
||||
|
||||
private String currentHost = "";
|
||||
|
||||
/**
|
||||
* the WF DB Store
|
||||
*/
|
||||
|
@ -177,12 +161,19 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
*/
|
||||
private ASLSession getASLSession() {
|
||||
String sessionID = this.getThreadLocalRequest().getSession().getId();
|
||||
|
||||
|
||||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
if (user == null) {
|
||||
user = "massimiliano.assante";
|
||||
this.getThreadLocalRequest().getSession().setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setScope(TEST_SCOPE);
|
||||
String email = user+"@isti.cnr.it";
|
||||
String fullName = "Massimiliano Assante";
|
||||
String thumbnailURL = "images/Avatar_default.png";
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setUserEmailAddress(email);
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setUserAvatarId(thumbnailURL);
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setUserFullName(fullName);
|
||||
|
||||
}
|
||||
|
||||
if (!withinPortal)
|
||||
|
@ -549,7 +540,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the shared session
|
||||
|
@ -601,16 +592,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an instance of the user WorkspaceArea
|
||||
* @throws HomeNotFoundException
|
||||
* @throws InternalErrorException
|
||||
* @throws WorkspaceFolderNotFoundException
|
||||
* @throws WorkspaceNotFoundException
|
||||
* @return
|
||||
* @throws WorkspaceFolderNotFoundException
|
||||
* @throws InternalErrorException
|
||||
* @throws HomeNotFoundException
|
||||
*/
|
||||
|
@ -622,24 +607,16 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
/**
|
||||
* reads from the file system and returns the user workspace as TreeNode object
|
||||
*
|
||||
* @return the Default basket if if there is no basket in session, else the basket in session id
|
||||
* @return the Default folder if if there is no basket in session, else the folder in session id
|
||||
*/
|
||||
public String getDefaultBasket() {
|
||||
_log.info("getDefaultBasket()");
|
||||
|
||||
public String getRootFolder() {
|
||||
try {
|
||||
Workspace workspaceArea = getWorkspaceArea();
|
||||
WorkspaceFolder basket = workspaceArea.getRoot();
|
||||
return basket.getId();
|
||||
} catch (MalformedScopeExpressionException e) { e.printStackTrace();
|
||||
} catch (InternalErrorException e) {e.printStackTrace();
|
||||
} catch (HomeNotFoundException e) { e.printStackTrace();
|
||||
} catch (WorkspaceFolderNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) { e.printStackTrace();
|
||||
}
|
||||
|
||||
return "Coud not open default basket";
|
||||
return "Coud not open default folder";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -696,9 +673,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
}
|
||||
ServiceUtil myUtil = new ServiceUtil(getASLSession());
|
||||
String dirToClean = myUtil.getTemplateFolder(getVreName(), getUsername());
|
||||
_log.info("RETURNING NULL, going to clean user template area: " + dirToClean);
|
||||
if (ReportConstants.isDeployed)
|
||||
delTemplateDir(new File(dirToClean));
|
||||
_log.info("No data on session for Reports, cleaning temp dir: " + dirToClean);
|
||||
delTemplateDir(new File(dirToClean));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -727,23 +703,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
public void storeTemplateInSession(Model model) {
|
||||
ASLSession d4Session = getASLSession();
|
||||
d4Session.setAttribute(CURRENT_REPORT_INSTANCE, model);
|
||||
|
||||
Vector<BasicSection> sections = model.getSections();
|
||||
for (BasicSection section : sections) {
|
||||
for (BasicComponent component : section.getComponents()) {
|
||||
if (component.getType() == ComponentType.DYNA_IMAGE) {
|
||||
System.out.println("****FOUND DYNA IMAGE : " + component.getPossibleContent().toString());
|
||||
}
|
||||
if (component.getType() == ComponentType.REPEAT_SEQUENCE) {
|
||||
RepeatableSequence res = (RepeatableSequence) component.getPossibleContent();
|
||||
for (BasicComponent co : res.getGroupedComponents()) {
|
||||
if (co.getType() == ComponentType.DYNA_IMAGE) {
|
||||
System.out.println("****FOUND DYNA IMAGE In Sequence: " + component.getPossibleContent().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -763,8 +722,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
String imageTargetDIR =
|
||||
new StringBuilder(
|
||||
myUtil.getTemplatePath(model.getTemplateName(), getVreName(), getUsername()))
|
||||
.append("images").append(File.separator).toString();
|
||||
|
||||
.append("images").append(File.separator).toString();
|
||||
|
||||
imageNameFile = copyImageFromBasket(imageID, imageTargetDIR, imageNameFile);
|
||||
component.setPossibleContent(getImageURL(imageNameFile, model.getTemplateName()));
|
||||
_log.trace("NEW setPossibleContent: " + component.getPossibleContent());
|
||||
|
@ -781,7 +740,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
String imageTargetDIR =
|
||||
new StringBuilder(
|
||||
myUtil.getTemplatePath(model.getTemplateName(), getVreName(), getUsername()))
|
||||
.append("images").append(File.separator).toString();
|
||||
.append("images").append(File.separator).toString();
|
||||
imageNameFile = copyImageFromBasket(imageID, imageTargetDIR, imageNameFile);
|
||||
|
||||
co.setPossibleContent(getImageURL(imageNameFile, model.getTemplateName()));
|
||||
|
@ -977,23 +936,16 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
Workspace root = null;
|
||||
try {
|
||||
root = getWorkspaceArea();
|
||||
} catch (WorkspaceFolderNotFoundException e) {e.printStackTrace();
|
||||
} catch (InternalErrorException e) { e.printStackTrace();
|
||||
} catch (HomeNotFoundException e) { e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) { e.printStackTrace();}
|
||||
|
||||
WorkspaceItem item = null;
|
||||
String folderid = "";
|
||||
String itemName = "";
|
||||
try {
|
||||
if (getReportItemIDFromSession().equals("")) {
|
||||
folderid = getDefaultBasket();
|
||||
|
||||
folderid = getRootFolder();
|
||||
}
|
||||
|
||||
else {
|
||||
_log.debug("getReportItemIDFromSession RETURNS -> " + getReportItemIDFromSession() + "");
|
||||
|
||||
item = root.getItem(getReportItemIDFromSession());
|
||||
folderid = item.getParent().getId();
|
||||
itemName = item.getName();
|
||||
|
@ -1002,12 +954,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
_log.error("ITEM NOT FOUND -> " + getReportItemIDFromSession());
|
||||
|
||||
} catch (InternalErrorException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
_log.debug("folderid -> " + folderid);
|
||||
|
||||
saveReport(folderid, itemName);
|
||||
}
|
||||
|
||||
|
@ -1028,8 +976,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
ServiceUtil myUtil = new ServiceUtil(getASLSession());
|
||||
boolean result = myUtil.writeModel(model, "CURRENT_OPEN", getVreName(), getUsername());
|
||||
|
||||
|
||||
|
||||
if (!result) {
|
||||
_log.debug("Could not save report, serializing failed");
|
||||
}
|
||||
|
@ -1060,7 +1006,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
try {
|
||||
isZip = new BufferedInputStream(new FileInputStream(outZip));
|
||||
|
||||
toSaveIn = getBasketInstance(folderid);
|
||||
toSaveIn = getRootFolder(folderid);
|
||||
|
||||
String templateName = newname;
|
||||
|
||||
if (templateName.endsWith("d4sR") ) {
|
||||
|
@ -1080,25 +1027,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
if (! templateToInsert.endsWith(".d4sR"))
|
||||
templateToInsert+=".d4sR";
|
||||
|
||||
|
||||
/**
|
||||
* Create a Report into this basket.
|
||||
* @param name the report name.
|
||||
* @param description the report description.
|
||||
* @param created the report creation time.
|
||||
* @param lastEdit the last edit time.
|
||||
* @param author the report author.
|
||||
* @param lastEditBy the last report editor.
|
||||
* @param templateName the source template name.
|
||||
* @param numberOfSections the number of sections.
|
||||
* @param status the report status.
|
||||
* @param reportData the report data.
|
||||
* @return the report.
|
||||
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
|
||||
* @throws InternalErrorException if an internal error occurs.
|
||||
* @throws ItemAlreadyExistException if an item with the specified name already exists.
|
||||
*/
|
||||
|
||||
Calendar dateCreated = Calendar.getInstance();
|
||||
dateCreated.setTime(model.getDateCreated());
|
||||
|
||||
|
@ -1112,44 +1040,27 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
//Report rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, isZip);
|
||||
storeReportItemIDInSession(rep.getId());
|
||||
|
||||
if (toSaveIn.getType() == WorkspaceItemType.SHARED_FOLDER) {
|
||||
sendReportUpdateNotification(toSaveIn, rep);
|
||||
}
|
||||
|
||||
AccessLogger log = AccessLogger.getAccessLogger();
|
||||
CreateReportLogEntry logEntry = new CreateReportLogEntry(model.getTemplateName(), rep.getId());
|
||||
log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);
|
||||
|
||||
} catch (InsufficientPrivilegesException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (InternalErrorException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ItemAlreadyExistException e) {
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ItemNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean removeIfExist(String name2Check, WorkspaceFolder basket) throws InternalErrorException, InsufficientPrivilegesException {
|
||||
List<WorkspaceItem> items = basket.getChildren();
|
||||
for (WorkspaceItem item : items)
|
||||
if (item.getName().equals(name2Check)) {
|
||||
item.remove();
|
||||
_log.info("ITEM REMOVED: "+ name2Check);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of
|
||||
* @param basketId
|
||||
* Return an instance of the root folder
|
||||
* @param folderId
|
||||
* @return
|
||||
* @throws ItemNotFoundException
|
||||
*/
|
||||
private WorkspaceFolder getBasketInstance(String basketId) throws ItemNotFoundException {
|
||||
private WorkspaceFolder getRootFolder(String folderId) throws ItemNotFoundException {
|
||||
Workspace root = null;
|
||||
try {
|
||||
root = getWorkspaceArea();
|
||||
|
@ -1160,22 +1071,33 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
|
||||
WorkspaceItem item = null;
|
||||
try {
|
||||
item = root.getItem(basketId);
|
||||
item = root.getItem(folderId);
|
||||
} catch (ItemNotFoundException e) {
|
||||
_log.info("BASKET : " + basketId + " NOT FOUND RETURNING DEFAULT ONE");
|
||||
return(WorkspaceFolder)root.getItem(getDefaultBasket());
|
||||
_log.info("Folder : " + folderId + " NOT FOUND RETURNING DEFAULT ONE");
|
||||
return(WorkspaceFolder)root.getItem(getRootFolder());
|
||||
|
||||
|
||||
}
|
||||
_log.debug("Item Type: "+item.getType());
|
||||
if (item.getType() != WorkspaceItemType.FOLDER) {
|
||||
_log.error("The item id does not belong to a basket id:" + basketId);
|
||||
return null;
|
||||
if (item.getType() == WorkspaceItemType.FOLDER || item.getType() == WorkspaceItemType.SHARED_FOLDER) {
|
||||
return (WorkspaceFolder) item;
|
||||
}
|
||||
return (WorkspaceFolder) item;
|
||||
_log.error("The item id does not belong to a valid folder id:" + folderId);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* send an update notification to all the user sharing this folder
|
||||
* @param toSaveIn
|
||||
* @throws InternalErrorException
|
||||
*/
|
||||
private void sendReportUpdateNotification(WorkspaceFolder sharedFolder, WorkspaceItem wsItem) throws InternalErrorException {
|
||||
if (sharedFolder.getType() == WorkspaceItemType.SHARED_FOLDER) {
|
||||
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) sharedFolder;
|
||||
List<String> usersToNotify = wsFolder.getUsers();
|
||||
Thread thread = new Thread(new NotificationsThread(getASLSession(), usersToNotify, wsItem, sharedFolder));
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* return a sample of the given TS to the client
|
||||
* @param sTS .
|
||||
|
@ -1372,8 +1294,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
* @return a SessionInfo bean containing the username the scope andis opening a workflow document or not
|
||||
*/
|
||||
public SessionInfo getSessionInfo(String currentHost) {
|
||||
this.currentHost = currentHost;
|
||||
|
||||
if (testWorkflow) {
|
||||
|
||||
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE, "1");
|
||||
|
@ -1663,32 +1583,32 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
_log.info("Saving in Workspace of " + workspace.getOwner().getPortalLogin());
|
||||
WorkspaceFolder folder = (workspaceFolderId != null)?
|
||||
(WorkspaceFolder)workspace.getItem(workspaceFolderId):workspace.getRoot();
|
||||
|
||||
itemName = itemName + "." + type.toString().toLowerCase();
|
||||
if (workspace.exists(itemName, folder.getId())) {
|
||||
if (overwrite)
|
||||
workspace.remove(itemName, folder.getId());
|
||||
else
|
||||
throw new SaveReportFileException("The item " + itemName + " already exists");
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PDF:
|
||||
return folder.createExternalPDFFileItem(itemName,
|
||||
"", null, new FileInputStream(file)).getId();
|
||||
|
||||
case HTML:
|
||||
return folder.createExternalFileItem(itemName,
|
||||
"", "text/html", new FileInputStream(file)).getId();
|
||||
case DOCX:
|
||||
return folder.createExternalFileItem(itemName,
|
||||
"", "application/msword", new FileInputStream(file)).getId();
|
||||
|
||||
case XML:
|
||||
return folder.createExternalFileItem(itemName,
|
||||
"", "application/xml", new FileInputStream(file)).getId();
|
||||
}
|
||||
throw new SaveReportFileException("Unknown file type");
|
||||
|
||||
itemName = itemName + "." + type.toString().toLowerCase();
|
||||
if (workspace.exists(itemName, folder.getId())) {
|
||||
if (overwrite)
|
||||
workspace.remove(itemName, folder.getId());
|
||||
else
|
||||
throw new SaveReportFileException("The item " + itemName + " already exists");
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PDF:
|
||||
return folder.createExternalPDFFileItem(itemName,
|
||||
"", null, new FileInputStream(file)).getId();
|
||||
|
||||
case HTML:
|
||||
return folder.createExternalFileItem(itemName,
|
||||
"", "text/html", new FileInputStream(file)).getId();
|
||||
case DOCX:
|
||||
return folder.createExternalFileItem(itemName,
|
||||
"", "application/msword", new FileInputStream(file)).getId();
|
||||
|
||||
case XML:
|
||||
return folder.createExternalFileItem(itemName,
|
||||
"", "application/xml", new FileInputStream(file)).getId();
|
||||
}
|
||||
throw new SaveReportFileException("Unknown file type");
|
||||
} catch (ItemAlreadyExistException e) {
|
||||
throw new SaveReportFileExistException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
|
|
Reference in New Issue