fixed bug for images (perhaps)

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@71338 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-03-13 17:44:20 +00:00
parent e0bbdad6db
commit 0a4dbffefc
3 changed files with 41 additions and 78 deletions

View File

@ -368,7 +368,13 @@ public class TemplateComponent {
switch (this.getType()) {
case DYNA_IMAGE:
ClientImage da = (ClientImage) this.content;
content = da.getDroppedImage().getUrl();
/*
* to get the URL of the image for the offline version you cannot use getURL(), it will return the absolut url of the image with host too
* so just go inside and get /usersArea.....
*
* */
content = da.getDroppedImage().getElement().getAttribute("src");
GWT.log("Poss Content=" + content);
id = da.getIdInBasket();
idInBasket = id;
if (((String) content).compareTo("") == 0)

View File

@ -313,36 +313,36 @@ public class ClientImage extends Composite {
return new Image();
return currImage;
}
/**
* return a URL which is lookable for on the web
* @param imageName .
* @param templateName .
* @return .
*/
public String getImageURL(String imageName, String templateName) {
currentUser = presenter.getCurrentUser().getUsername();
currentScope = presenter.getCurrentScope();
/**
* Images will be stored under webapps/usersArea...
* GWT.getModuleBaseURL() returns * e.g. http://dlib28.isti.cnr.it/templatecreator/html/
* need to get just http://dlib28.isti.cnr.it/
*/
//remove "/html/" and get e.g. http://dlib28.isti.cnr.it/templatecreator
String host = GWT.getModuleBaseURL().substring(0, GWT.getModuleBaseURL().length()-6);
//loog for last slash
int lastSlash = host.lastIndexOf("/");
//get what i need : e.g. http://dlib28.isti.cnr.it/ or host = "http://localhost:8080/";
host = host.substring(0, lastSlash +1 );
//host = "http://localhost:8080/";
String imgURL = host + "usersArea/" + currentScope + "/templates/"
+ currentUser + "/CURRENT_OPEN/images/" + imageName;
return imgURL;
}
//
// /**
// * return a URL which is lookable for on the web
// * @param imageName .
// * @param templateName .
// * @return .
// */
// public String getImageURL(String imageName, String templateName) {
// currentUser = presenter.getCurrentUser().getUsername();
// currentScope = presenter.getCurrentScope();
// /**
// * Images will be stored under webapps/usersArea...
// * GWT.getModuleBaseURL() returns * e.g. http://dlib28.isti.cnr.it/templatecreator/html/
// * need to get just http://dlib28.isti.cnr.it/
// */
// //remove "/html/" and get e.g. http://dlib28.isti.cnr.it/templatecreator
// String host = GWT.getModuleBaseURL().substring(0, GWT.getModuleBaseURL().length()-6);
//
// //loog for last slash
// int lastSlash = host.lastIndexOf("/");
//
// //get what i need : e.g. http://dlib28.isti.cnr.it/ or host = "http://localhost:8080/";
// host = host.substring(0, lastSlash +1 );
// //host = "http://localhost:8080/";
//
// String imgURL = host + "usersArea/" + currentScope + "/templates/"
// + currentUser + "/CURRENT_OPEN/images/" + imageName;
//
// return imgURL;
// }
/**
*

View File

@ -47,7 +47,6 @@ import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.TableCell;
import org.gcube.portlets.docxgenerator.DocxGenerator;
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
@ -544,48 +543,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
}
/**
* save the manifestation in default folder, overwrites if the file name exists already
*
* @param name the name in the Workspace
* @param desc the desc
* @param mimeType its mimetype
* @param payLoad a File instance
*/
private boolean saveInWorkSpace(String name, String desc, String mimeType, File payLoad, ExportManifestationType type ) {
try {
String defaultBasketID = getDefaultBasket();
// Read the pdf input stream
InputStream inputStream = new BufferedInputStream(new FileInputStream(payLoad));
Workspace wp = getWorkspaceArea();
WorkspaceFolder toSaveIn = wp.getRoot();
if (toSaveIn.exists(name)) {
_log.warn("Item exists already, deleting and creating new one");
toSaveIn.removeChild(toSaveIn.find(name));
}
if (type == ExportManifestationType.PDF) {
wp.createExternalPDFFile(name, name, mimeType, inputStream, defaultBasketID);
} else
wp.createExternalFile(name, name, mimeType, inputStream, defaultBasketID);
AccessLogger log = AccessLogger.getAccessLogger();
GenerateReportLogEntry logEntry = new GenerateReportLogEntry(name, mimeType, type.toString());
log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/**
*
* @return the shared session
@ -790,8 +747,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
for (BasicSection section : sections) {
for (BasicComponent component : section.getComponents()) {
if (component.getType() == ComponentType.DYNA_IMAGE) {
_log.debug("Found DP: " + component.getPossibleContent());
if (component.getIdInBasket() != null) {
_log.debug("Found Simple Image: " + component.getPossibleContent());
if (component.getIdInBasket() != null) { // you need to convert only new images that stay in the HL Workspace, this is the check
String imageID = component.getIdInBasket();
String imageNameFile = UUID.randomUUID().toString();
@ -810,7 +767,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
RepeatableSequence res = (RepeatableSequence) component.getPossibleContent();
for (BasicComponent co : res.getGroupedComponents()) {
_log.debug("Found Image IN SEQUENCE, type is: " + component.getType());
if (co.getIdInBasket() != null) {
if (co.getIdInBasket() != null) { // you need to convert only new images that stay in the HL Workspace, this is the check
String imageID = co.getIdInBasket();
String imageNameFile = UUID.randomUUID().toString();
@ -1056,7 +1013,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
Model model = readTemplateFromSession();
//raplacing " " with _
_log.info("Serializing Model basketidToSaveIn: " + folderid );
_log.info("Serializing Model in folder: " + folderid );
_log.info("Trying to convert dynamic images ... ");
importDynamicImagesFromHL(model);