fix for production support #582
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@74191 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9a1a6298c8
commit
fdc58b4e98
|
@ -19,7 +19,6 @@
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="lib" path="/Users/massi/portal/Portal-Bundle/gCore/lib/is-collector-stubs-3.0.0-20130114.171438-377.jar"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
|
|
@ -385,11 +385,6 @@ public class TemplateComponent {
|
||||||
switch (this.getType()) {
|
switch (this.getType()) {
|
||||||
case DYNA_IMAGE:
|
case DYNA_IMAGE:
|
||||||
ClientImage da = (ClientImage) this.content;
|
ClientImage da = (ClientImage) this.content;
|
||||||
/*
|
|
||||||
* 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");
|
content = da.getDroppedImage().getElement().getAttribute("src");
|
||||||
GWT.log("Poss Content=" + content);
|
GWT.log("Poss Content=" + content);
|
||||||
id = da.getIdInBasket();
|
id = da.getIdInBasket();
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Vector;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
|
||||||
import net.sf.csv4j.CSVFileProcessor;
|
import net.sf.csv4j.CSVFileProcessor;
|
||||||
import net.sf.csv4j.CSVLineProcessor;
|
import net.sf.csv4j.CSVLineProcessor;
|
||||||
|
@ -706,8 +707,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void importDynamicImagesFromHL(Model model) {
|
private void convertDynamicImagesFromHL(Model model) {
|
||||||
ServiceUtil myUtil = new ServiceUtil(getASLSession());
|
|
||||||
_log.debug("model == NULL " + (model == null));
|
_log.debug("model == NULL " + (model == null));
|
||||||
Vector<BasicSection> sections = model.getSections();
|
Vector<BasicSection> sections = model.getSections();
|
||||||
for (BasicSection section : sections) {
|
for (BasicSection section : sections) {
|
||||||
|
@ -715,18 +715,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
if (component.getType() == ComponentType.DYNA_IMAGE) {
|
if (component.getType() == ComponentType.DYNA_IMAGE) {
|
||||||
_log.debug("Found Simple Image: " + component.getPossibleContent());
|
_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
|
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 imageID = component.getIdInBasket();
|
||||||
String imageNameFile = UUID.randomUUID().toString();
|
component.setPossibleContent(getdDataImagebase64(imageID));
|
||||||
|
_log.trace("Image converted base 64 OK: " + component.getPossibleContent());
|
||||||
String imageTargetDIR =
|
|
||||||
new StringBuilder(
|
|
||||||
myUtil.getTemplatePath(model.getTemplateName(), getVreName(), getUsername()))
|
|
||||||
.append("images").append(File.separator).toString();
|
|
||||||
|
|
||||||
imageNameFile = copyImageFromBasket(imageID, imageTargetDIR, imageNameFile);
|
|
||||||
component.setPossibleContent(getImageURL(imageNameFile, model.getTemplateName()));
|
|
||||||
_log.trace("NEW setPossibleContent: " + component.getPossibleContent());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (component.getType() == ComponentType.REPEAT_SEQUENCE || component.getType() == ComponentType.BODY_TABLE_IMAGE) { //there could be images inside
|
if (component.getType() == ComponentType.REPEAT_SEQUENCE || component.getType() == ComponentType.BODY_TABLE_IMAGE) { //there could be images inside
|
||||||
|
@ -735,16 +726,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
_log.debug("Found Image IN SEQUENCE, type is: " + component.getType());
|
_log.debug("Found Image IN SEQUENCE, type is: " + component.getType());
|
||||||
if (co.getIdInBasket() != null) { // you need to convert only new images that stay in the HL Workspace, this is the check
|
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 imageID = co.getIdInBasket();
|
||||||
String imageNameFile = UUID.randomUUID().toString();
|
co.setPossibleContent(getdDataImagebase64(imageID));
|
||||||
|
_log.trace("Image converted base 64 OK, in SEQUENCE: " + co.getPossibleContent());
|
||||||
String imageTargetDIR =
|
|
||||||
new StringBuilder(
|
|
||||||
myUtil.getTemplatePath(model.getTemplateName(), getVreName(), getUsername()))
|
|
||||||
.append("images").append(File.separator).toString();
|
|
||||||
imageNameFile = copyImageFromBasket(imageID, imageTargetDIR, imageNameFile);
|
|
||||||
|
|
||||||
co.setPossibleContent(getImageURL(imageNameFile, model.getTemplateName()));
|
|
||||||
_log.trace("NEW setPossibleContent in SEQUENCE: " + co.getPossibleContent());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,6 +735,56 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert the image into a String encoded base 64
|
||||||
|
* @param imageIDinWorkspace the id of the image in workspace
|
||||||
|
* @return the string representing the image converted to be put in the img src attribute e.g. data:image/ong;base64,a...z
|
||||||
|
*/
|
||||||
|
private String getdDataImagebase64(String imageIDinWorkspace) {
|
||||||
|
Workspace root = null;
|
||||||
|
try {
|
||||||
|
root = getWorkspaceArea();
|
||||||
|
|
||||||
|
WorkspaceItem item = null;
|
||||||
|
item = root.getItem(imageIDinWorkspace);
|
||||||
|
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
|
||||||
|
_log.debug("Item is a Folder Item");
|
||||||
|
FolderItem imageItem = (FolderItem) item;
|
||||||
|
InputStream data = null;
|
||||||
|
|
||||||
|
if (imageItem.getFolderItemType()==FolderItemType.EXTERNAL_IMAGE){
|
||||||
|
_log.debug("EXTERNAL_IMAGE -|- " + item.getType() + " itemId=" + item.getId());
|
||||||
|
ExternalImage image = (ExternalImage)item;
|
||||||
|
_log.debug("EXTERNAL_IMAGE Name= " + item.getName() + " Asking InputStream ..");
|
||||||
|
data = image.getData();
|
||||||
|
_log.debug("Got inputStream");
|
||||||
|
}
|
||||||
|
else if (imageItem.getFolderItemType()==FolderItemType.IMAGE_DOCUMENT){
|
||||||
|
ImageDocument image = (ImageDocument)item;
|
||||||
|
if (image.getMimeType().equals("image/tiff"))
|
||||||
|
data = image.getThumbnail();
|
||||||
|
else
|
||||||
|
data = image.getData();
|
||||||
|
}
|
||||||
|
if (data != null) {
|
||||||
|
_log.debug("Encoding image in base64");
|
||||||
|
byte[] imageBytes = IOUtils.toByteArray(data);
|
||||||
|
String extension = getImageExtension(imageItem);
|
||||||
|
String srcAttrValue = "data:image/"+extension+";base64,"+DatatypeConverter.printBase64Binary(imageBytes);
|
||||||
|
_log.debug("Encoded image=" + srcAttrValue);
|
||||||
|
return srcAttrValue;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param imageName the generated image name
|
* @param imageName the generated image name
|
||||||
|
@ -769,7 +802,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param imageIDinBasket .
|
* @param imageIDinBasket .
|
||||||
|
@ -967,11 +999,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
public void saveReport(String folderid, String newname) {
|
public void saveReport(String folderid, String newname) {
|
||||||
|
|
||||||
Model model = readTemplateFromSession();
|
Model model = readTemplateFromSession();
|
||||||
//raplacing " " with _
|
|
||||||
_log.info("Serializing Model in folder: " + folderid );
|
_log.info("Serializing Model in folder: " + folderid );
|
||||||
|
|
||||||
_log.info("Trying to convert dynamic images ... ");
|
_log.info("Trying to convert dynamic images ... ");
|
||||||
importDynamicImagesFromHL(model);
|
convertDynamicImagesFromHL(model);
|
||||||
|
|
||||||
ServiceUtil myUtil = new ServiceUtil(getASLSession());
|
ServiceUtil myUtil = new ServiceUtil(getASLSession());
|
||||||
boolean result = myUtil.writeModel(model, "CURRENT_OPEN", getVreName(), getUsername());
|
boolean result = myUtil.writeModel(model, "CURRENT_OPEN", getVreName(), getUsername());
|
||||||
|
@ -1441,7 +1471,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
model = (Model) session.getAttribute(CURRENT_REPORT_INSTANCE);
|
model = (Model) session.getAttribute(CURRENT_REPORT_INSTANCE);
|
||||||
|
|
||||||
_log.debug("Trying to convert dynamic images ... ");
|
_log.debug("Trying to convert dynamic images ... ");
|
||||||
importDynamicImagesFromHL(model);
|
convertDynamicImagesFromHL(model);
|
||||||
|
|
||||||
|
|
||||||
boolean result = myUtil.writeModel(model, "CURRENT_OPEN", getVreName(), getUsername());
|
boolean result = myUtil.writeModel(model, "CURRENT_OPEN", getVreName(), getUsername());
|
||||||
|
|
Reference in New Issue