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:
Massimiliano Assante 2013-10-29 16:08:14 +00:00
parent 27ae3399f1
commit 58c22e49f4
3 changed files with 134 additions and 167 deletions

View File

@ -29,10 +29,10 @@ public class ToolboxPanel extends SimplePanel {
public ToolboxPanel(AppControllerExplorer appController) {
this.appController = appController;
// AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
// this.tp = tp;
// add(tp);
// this.appController.hideSharingFacilities(); //sharing disabled we have problems from Reports
AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
this.tp = tp;
add(tp);
this.appController.hideSharingFacilities(); //sharing disabled we have problems from Reports
}
public void showExportedVersion(String id, String fileName) {

View File

@ -237,7 +237,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} catch (ClassNotFoundException ex) {
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);
}
@ -252,57 +252,24 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
public Model readModel(String templateName, String templateObjectID, boolean isTemplate, boolean isImporting) {
ServiceUtil myUtil = new ServiceUtil(getASLSession());
_log.debug("Reading " + templateName);
if (! ReportConstants.isDeployed) {
Model toConvert = null;
FileInputStream fis = null;
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 {
Workspace root = null;
try {
root = getWorkspaceArea();
} catch (WorkspaceFolderNotFoundException e) {
e.printStackTrace();
} catch (InternalErrorException e) {
e.printStackTrace();
} catch (HomeNotFoundException e) {
e.printStackTrace();
}
WorkspaceItem item = null;
try {
root = getWorkspaceArea();
item = root.getItem(templateObjectID);
if (! isImporting)
storeReportItemIDInSession(templateObjectID);
} catch (ItemNotFoundException e) {
_log.debug("** -> getItem, id: " + templateObjectID + " Name: " + item.getName());
} catch (Exception e) {
e.printStackTrace();
}
_log.debug("getItem: " + templateObjectID);
String zipToExtract = "";
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
_log.debug("\nItem is a FolderItem");
_log.debug("Item is a FolderItem - OK... next step check if is a templet or a report");
FolderItem bi = (FolderItem) item;
boolean fromBasket = false;
@ -313,7 +280,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String zipFilename = "";
if (! isTemplate) {//then is a report
zipFilename = templateName + "-report.zip"; //gCube report
_log.debug("********************** Reading report -----------------");
_log.debug("********************** Reading template -----------------");
}
else
zipFilename = templateName + ".zip"; //gCube template
@ -331,8 +298,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String zipFilename = "";
if (! isTemplate) {//then is a report
zipFilename = templateName + "-report.zip"; //d4science template
_log.debug("********************** Reading report -----------------");
zipFilename = templateName + "-report.zip"; //gCube report
_log.debug(" Reading report -----------------");
}
else
zipFilename = templateName + ".zip"; //d4science template
@ -345,6 +312,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
zipToExtract = zipPath + zipFilename;
}
_log.info("\n\n** zipToExtract: " + zipToExtract);
if (bi.getFolderItemType() == FolderItemType.REPORT || bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
if (fromBasket) {
@ -361,19 +330,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
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");
_log.debug("Loading fileToRead from Disk -> " + fileToRead);
Model toReturn = null;
Model toConvert = null;
@ -396,6 +353,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
// 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();
@ -403,9 +362,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
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");
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) {
@ -425,7 +385,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
_log.error("FAILED TO READ FROM BASKET RETURING EMPTY Serializable Template");
return new Model();
}
}

View File

@ -3,8 +3,15 @@ log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# 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
log4j.logger.org.gcube=TRACE
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