fixed bug when opening reports created with reports modeler
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@84599 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
27ae3399f1
commit
58c22e49f4
|
@ -29,10 +29,10 @@ public class ToolboxPanel extends SimplePanel {
|
||||||
|
|
||||||
public ToolboxPanel(AppControllerExplorer appController) {
|
public ToolboxPanel(AppControllerExplorer appController) {
|
||||||
this.appController = appController;
|
this.appController = appController;
|
||||||
// AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
|
AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
|
||||||
// this.tp = tp;
|
this.tp = tp;
|
||||||
// add(tp);
|
add(tp);
|
||||||
// this.appController.hideSharingFacilities(); //sharing disabled we have problems from Reports
|
this.appController.hideSharingFacilities(); //sharing disabled we have problems from Reports
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showExportedVersion(String id, String fileName) {
|
public void showExportedVersion(String id, String fileName) {
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
_log.debug("Converting Imported Fimes to Serializable object, num sectionss: " + toConvert.getSections().size());
|
_log.debug("Converting Imported Fimes to Serializable object, num sections: " + toConvert.getSections().size());
|
||||||
return (toConvert);
|
return (toConvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,180 +252,140 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
public Model readModel(String templateName, String templateObjectID, boolean isTemplate, boolean isImporting) {
|
public Model readModel(String templateName, String templateObjectID, boolean isTemplate, boolean isImporting) {
|
||||||
ServiceUtil myUtil = new ServiceUtil(getASLSession());
|
ServiceUtil myUtil = new ServiceUtil(getASLSession());
|
||||||
_log.debug("Reading " + templateName);
|
_log.debug("Reading " + templateName);
|
||||||
if (! ReportConstants.isDeployed) {
|
|
||||||
|
|
||||||
Model toConvert = null;
|
Workspace root = null;
|
||||||
|
WorkspaceItem item = null;
|
||||||
|
try {
|
||||||
|
root = getWorkspaceArea();
|
||||||
|
item = root.getItem(templateObjectID);
|
||||||
|
if (! isImporting)
|
||||||
|
storeReportItemIDInSession(templateObjectID);
|
||||||
|
|
||||||
FileInputStream fis = null;
|
_log.debug("** -> getItem, id: " + templateObjectID + " Name: " + item.getName());
|
||||||
ObjectInputStream in = null;
|
|
||||||
try {
|
|
||||||
String path = myUtil.getTemplateFolder(getVreName(), getUsername());
|
|
||||||
fis = new FileInputStream(path + "CURRENT_OPEN/CURRENT_OPEN.d4st");
|
|
||||||
in = new ObjectInputStream(fis);
|
|
||||||
toConvert = (Model) in.readObject();
|
|
||||||
in.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
} catch (ClassNotFoundException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
_log.debug("Converting fileToRead to Serializable object");
|
|
||||||
return toConvert;
|
|
||||||
|
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
Workspace root = null;
|
String zipToExtract = "";
|
||||||
|
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
|
||||||
|
_log.debug("Item is a FolderItem - OK... next step check if is a templet or a report");
|
||||||
|
|
||||||
try {
|
FolderItem bi = (FolderItem) item;
|
||||||
root = getWorkspaceArea();
|
boolean fromBasket = false;
|
||||||
} catch (WorkspaceFolderNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InternalErrorException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (HomeNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WorkspaceItem item = null;
|
|
||||||
try {
|
|
||||||
item = root.getItem(templateObjectID);
|
|
||||||
if (! isImporting)
|
|
||||||
storeReportItemIDInSession(templateObjectID);
|
|
||||||
} catch (ItemNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
_log.debug("getItem: " + templateObjectID);
|
|
||||||
String zipToExtract = "";
|
|
||||||
|
|
||||||
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
|
|
||||||
|
|
||||||
_log.debug("\nItem is a FolderItem");
|
|
||||||
|
|
||||||
FolderItem bi = (FolderItem) item;
|
|
||||||
boolean fromBasket = false;
|
|
||||||
|
|
||||||
if (isTemplate) {
|
|
||||||
if (bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
|
|
||||||
ReportTemplate zippedTemplate = (ReportTemplate) bi;
|
|
||||||
String zipFilename = "";
|
|
||||||
if (! isTemplate) {//then is a report
|
|
||||||
zipFilename = templateName + "-report.zip"; //gCube report
|
|
||||||
_log.debug("********************** Reading report -----------------");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
zipFilename = templateName + ".zip"; //gCube template
|
|
||||||
|
|
||||||
String zipPath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
|
|
||||||
fromBasket = getTemplateFromBasket(zippedTemplate, zipPath, zipFilename);
|
|
||||||
zipToExtract = zipPath + zipFilename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bi.getFolderItemType() == FolderItemType.REPORT) {
|
|
||||||
|
|
||||||
_log.debug("Item is a REPORT");
|
|
||||||
Report zippedTemplate = (Report) bi;
|
|
||||||
|
|
||||||
|
if (isTemplate) {
|
||||||
|
if (bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
|
||||||
|
ReportTemplate zippedTemplate = (ReportTemplate) bi;
|
||||||
String zipFilename = "";
|
String zipFilename = "";
|
||||||
if (! isTemplate) {//then is a report
|
if (! isTemplate) {//then is a report
|
||||||
zipFilename = templateName + "-report.zip"; //d4science template
|
zipFilename = templateName + "-report.zip"; //gCube report
|
||||||
_log.debug("********************** Reading report -----------------");
|
_log.debug("********************** Reading template -----------------");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
zipFilename = templateName + ".zip"; //d4science template
|
zipFilename = templateName + ".zip"; //gCube template
|
||||||
|
|
||||||
File toDelete = new File(zipFilename);
|
|
||||||
toDelete.delete();
|
|
||||||
|
|
||||||
String zipPath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
|
String zipPath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
|
||||||
fromBasket = getReportFromBasket(zippedTemplate, zipPath, zipFilename);
|
fromBasket = getTemplateFromBasket(zippedTemplate, zipPath, zipFilename);
|
||||||
zipToExtract = zipPath + zipFilename;
|
zipToExtract = zipPath + zipFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bi.getFolderItemType() == FolderItemType.REPORT || bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
|
|
||||||
|
|
||||||
if (fromBasket) {
|
|
||||||
File toExtract = new File(zipToExtract);
|
|
||||||
File outputDir = new File( myUtil.getTemplatePath(templateName, getVreName(), getUsername()) );
|
|
||||||
ZipUtil.unzipArchive(toExtract, outputDir);
|
|
||||||
|
|
||||||
String templatePath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
|
|
||||||
|
|
||||||
String modelFilename = "";
|
|
||||||
try {
|
|
||||||
modelFilename = seekModel(templatePath, templateName);
|
|
||||||
} catch (FileNotFoundException e) { e.printStackTrace(); }
|
|
||||||
|
|
||||||
String fileToRead = templatePath + modelFilename + ".d4st" ;
|
|
||||||
|
|
||||||
//TODO: check
|
|
||||||
// String fileToCheck = templatePath + "gCube-label.d4s" ; //lo deve anche cancellare
|
|
||||||
// File file2Check = new File(fileToCheck);
|
|
||||||
// Logger.debug("Checking: " + fileToCheck);
|
|
||||||
// if (! file2Check.exists()) {
|
|
||||||
// Logger.debug("Not Found: " + fileToCheck);
|
|
||||||
// return new SerializableModel(950);
|
|
||||||
// } else {
|
|
||||||
// file2Check.delete();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
_log.debug("Loading fileToRead from Disk");
|
|
||||||
|
|
||||||
Model toReturn = null;
|
|
||||||
Model toConvert = null;
|
|
||||||
|
|
||||||
FileInputStream fis = null;
|
|
||||||
ObjectInputStream in = null;
|
|
||||||
try {
|
|
||||||
fis = new FileInputStream(fileToRead);
|
|
||||||
in = new ObjectInputStream(fis);
|
|
||||||
toConvert = (Model) in.readObject();
|
|
||||||
in.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
} catch (ClassNotFoundException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
_log.debug("Converting fileToRead to Serializable object");
|
|
||||||
toReturn = (toConvert);
|
|
||||||
|
|
||||||
// changes the template name model
|
|
||||||
toReturn.setTemplateName(templateName);
|
|
||||||
|
|
||||||
File toDelete1 = new File( myUtil.getTemplatePath(templateName, getVreName(), getUsername()));
|
|
||||||
boolean deleted1 = toDelete1.delete();
|
|
||||||
|
|
||||||
|
|
||||||
File toDelete2 = new File(zipToExtract);
|
|
||||||
boolean deleted2 = toDelete2.delete();
|
|
||||||
|
|
||||||
_log.debug("dirToDelete: " + toDelete1 + " result: " + deleted1 + " \n\n\n");
|
|
||||||
|
|
||||||
_log.debug("dirToDelete: " + toDelete2 + " result: " + deleted2 + " \n\n\n");
|
|
||||||
|
|
||||||
//**** IMPORTANT ****
|
|
||||||
if (! isImporting) {
|
|
||||||
storeTemplateInSession(toReturn);
|
|
||||||
_log.debug("storeTemplateInSession DONE");
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessLogger log = AccessLogger.getAccessLogger();
|
|
||||||
OpenReportLogEntry logEntry = new OpenReportLogEntry(toReturn.getTemplateName(), templateObjectID);
|
|
||||||
log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);
|
|
||||||
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_log.error("FAILED TO READ RETURING EMPTY Serializable Template");
|
|
||||||
return new Model();
|
|
||||||
}
|
}
|
||||||
_log.error("FAILED TO READ FROM BASKET RETURING EMPTY Serializable Template");
|
|
||||||
|
if (bi.getFolderItemType() == FolderItemType.REPORT) {
|
||||||
|
|
||||||
|
_log.debug("Item is a REPORT");
|
||||||
|
Report zippedTemplate = (Report) bi;
|
||||||
|
|
||||||
|
String zipFilename = "";
|
||||||
|
if (! isTemplate) {//then is a report
|
||||||
|
zipFilename = templateName + "-report.zip"; //gCube report
|
||||||
|
_log.debug(" Reading report -----------------");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
zipFilename = templateName + ".zip"; //d4science template
|
||||||
|
|
||||||
|
File toDelete = new File(zipFilename);
|
||||||
|
toDelete.delete();
|
||||||
|
|
||||||
|
String zipPath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
|
||||||
|
fromBasket = getReportFromBasket(zippedTemplate, zipPath, zipFilename);
|
||||||
|
zipToExtract = zipPath + zipFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
_log.info("\n\n** zipToExtract: " + zipToExtract);
|
||||||
|
|
||||||
|
if (bi.getFolderItemType() == FolderItemType.REPORT || bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
|
||||||
|
|
||||||
|
if (fromBasket) {
|
||||||
|
File toExtract = new File(zipToExtract);
|
||||||
|
File outputDir = new File( myUtil.getTemplatePath(templateName, getVreName(), getUsername()) );
|
||||||
|
ZipUtil.unzipArchive(toExtract, outputDir);
|
||||||
|
|
||||||
|
String templatePath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
|
||||||
|
|
||||||
|
String modelFilename = "";
|
||||||
|
try {
|
||||||
|
modelFilename = seekModel(templatePath, templateName);
|
||||||
|
} catch (FileNotFoundException e) { e.printStackTrace(); }
|
||||||
|
|
||||||
|
String fileToRead = templatePath + modelFilename + ".d4st" ;
|
||||||
|
|
||||||
|
_log.debug("Loading fileToRead from Disk -> " + fileToRead);
|
||||||
|
|
||||||
|
Model toReturn = null;
|
||||||
|
Model toConvert = null;
|
||||||
|
|
||||||
|
FileInputStream fis = null;
|
||||||
|
ObjectInputStream in = null;
|
||||||
|
try {
|
||||||
|
fis = new FileInputStream(fileToRead);
|
||||||
|
in = new ObjectInputStream(fis);
|
||||||
|
toConvert = (Model) in.readObject();
|
||||||
|
in.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
_log.debug("Converting fileToRead to Serializable object");
|
||||||
|
toReturn = (toConvert);
|
||||||
|
|
||||||
|
// changes the template name model
|
||||||
|
toReturn.setTemplateName(templateName);
|
||||||
|
|
||||||
|
File toDelete = new File(fileToRead); //to delete the file extracted from the workspace
|
||||||
|
|
||||||
|
File toDelete1 = new File( myUtil.getTemplatePath(templateName, getVreName(), getUsername()));
|
||||||
|
boolean deleted1 = toDelete1.delete();
|
||||||
|
|
||||||
|
|
||||||
|
File toDelete2 = new File(zipToExtract);
|
||||||
|
boolean deleted2 = toDelete2.delete();
|
||||||
|
|
||||||
|
boolean deleted = toDelete.delete();
|
||||||
|
_log.debug("deleting extracted file: " + fileToRead + " result: " + deleted);
|
||||||
|
_log.debug("dirToDelete: " + toDelete1 + " result: " + deleted1);
|
||||||
|
_log.debug("dirToDelete: " + toDelete2 + " result: " + deleted2);
|
||||||
|
|
||||||
|
//**** IMPORTANT ****
|
||||||
|
if (! isImporting) {
|
||||||
|
storeTemplateInSession(toReturn);
|
||||||
|
_log.debug("storeTemplateInSession DONE");
|
||||||
|
}
|
||||||
|
|
||||||
|
AccessLogger log = AccessLogger.getAccessLogger();
|
||||||
|
OpenReportLogEntry logEntry = new OpenReportLogEntry(toReturn.getTemplateName(), templateObjectID);
|
||||||
|
log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_log.error("FAILED TO READ RETURING EMPTY Serializable Template");
|
||||||
return new Model();
|
return new Model();
|
||||||
}
|
}
|
||||||
|
_log.error("FAILED TO READ FROM BASKET RETURING EMPTY Serializable Template");
|
||||||
|
return new Model();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -770,11 +730,11 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
}
|
}
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
_log.debug("Encoding image in base64");
|
_log.debug("Encoding image in base64");
|
||||||
byte[] imageBytes = IOUtils.toByteArray(data);
|
byte[] imageBytes = IOUtils.toByteArray(data);
|
||||||
String extension = getImageExtension(imageItem);
|
String extension = getImageExtension(imageItem);
|
||||||
String srcAttrValue = "data:image/"+extension+";base64,"+DatatypeConverter.printBase64Binary(imageBytes);
|
String srcAttrValue = "data:image/"+extension+";base64,"+DatatypeConverter.printBase64Binary(imageBytes);
|
||||||
_log.debug("Encoded image=" + srcAttrValue);
|
_log.debug("Encoded image=" + srcAttrValue);
|
||||||
return srcAttrValue;
|
return srcAttrValue;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -785,7 +745,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return a string for the file extension given a mimetype
|
* return a string for the file extension given a mimetype
|
||||||
*
|
*
|
||||||
|
|
|
@ -3,8 +3,15 @@ log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||||
|
|
||||||
# Print the date in ISO 8601 format
|
# Print the date in ISO 8601 format
|
||||||
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
log4j.appender.A1.layout.ConversionPattern=%d %-5p %c - %m%n
|
||||||
|
|
||||||
# Print only messages of level TRACE or above in the package org.gcube
|
# Print only messages of level TRACE or above in the package org.gcube
|
||||||
log4j.logger.org.gcube=TRACE
|
log4j.logger.org.gcube=TRACE
|
||||||
log4j.logger.org.gcube.application.framework.core.session=INFO
|
log4j.logger.org.gcube.application.framework.core.session=INFO
|
||||||
|
log4j.logger.org.gcube.contentmanager=ERROR
|
||||||
|
log4j.logger.org.gcube.common.scope=ERROR
|
||||||
|
log4j.logger.org.gcube.contentmanagement=ERROR
|
||||||
|
log4j.logger.org.gcube.resources.discovery.icclient=ERROR
|
||||||
|
log4j.logger.org.gcube.common.clients=ERROR
|
||||||
|
log4j.logger.org.gcube.common.homelibrary.jcr=ERROR
|
||||||
|
log4j.logger.org.gcube.application.framework.accesslogger=ERROR
|
||||||
|
|
Reference in New Issue