added handling for single attributes

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@70827 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-03-05 14:26:22 +00:00
parent 55c7dc8df2
commit 1448a8ef51
11 changed files with 434 additions and 153 deletions

View File

@ -31,7 +31,8 @@ import org.gcube.portlets.user.reportgenerator.client.model.ExportManifestationT
import org.gcube.portlets.user.reportgenerator.client.model.TemplateComponent;
import org.gcube.portlets.user.reportgenerator.client.model.TemplateModel;
import org.gcube.portlets.user.reportgenerator.client.model.TemplateSection;
import org.gcube.portlets.user.reportgenerator.client.targets.ClientAttributeArea;
import org.gcube.portlets.user.reportgenerator.client.targets.AttributeMultiSelection;
import org.gcube.portlets.user.reportgenerator.client.targets.AttributeSingleSelection;
import org.gcube.portlets.user.reportgenerator.client.targets.BasicTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.Coords;
import org.gcube.portlets.user.reportgenerator.client.targets.D4sRichTextarea;
@ -43,6 +44,7 @@ import org.gcube.portlets.user.reportgenerator.client.targets.ClientRepeatableSe
import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.TSArea;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.UserBean;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
@ -88,7 +90,7 @@ public class Presenter {
private TitleBar titleBar;
private String currentUser;
private UserBean currentUser;
private String currentScope;
/**
* Model
@ -1002,10 +1004,15 @@ public class Presenter {
wp.addComponentToLayout(gt, component.isDoubleColLayout());
break;
case ATTRIBUTE_MULTI:
ClientAttributeArea at = (ClientAttributeArea) component.getContent();
AttributeMultiSelection at = (AttributeMultiSelection) component.getContent();
wp.addComponentToLayout(at, component.isDoubleColLayout());
setCurrCursorPos(uiY);
break;
case ATTRIBUTE_UNIQUE:
AttributeSingleSelection atu = (AttributeSingleSelection) component.getContent();
wp.addComponentToLayout(atu, component.isDoubleColLayout());
setCurrCursorPos(uiY);
break;
case COMMENT:
HTML text = (HTML) component.getContent();
wp.addComponentToLayout(text, component.isDoubleColLayout());
@ -1123,7 +1130,7 @@ public class Presenter {
*
* @return the user username who is using the application
*/
public String getCurrentUser() {
public UserBean getCurrentUser() {
return currentUser;
}

View File

@ -5,12 +5,12 @@ import org.gcube.portlets.d4sreporting.common.client.uicomponents.resources.Imag
import org.gcube.portlets.user.reportgenerator.client.events.AddCommentEvent;
import org.gcube.portlets.user.reportgenerator.client.events.RemovedUserCommentEvent;
import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea;
import org.gcube.portlets.user.reportgenerator.shared.UserBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Image;
@ -24,14 +24,14 @@ public class CommentDialog extends DialogBox {
AbsolutePanel header = new AbsolutePanel();
TextArea area;
Images images = GWT.create(Images.class);
public CommentDialog(final HandlerManager eventBus, final ReportTextArea source, final String username, final String previousComment, int areaHeight) {
public CommentDialog(final HandlerManager eventBus, final ReportTextArea source, final UserBean user, final String previousComment, int areaHeight) {
super(true);
setStyleName("comment-popup");
area = new TextArea();
if (previousComment != null && !(previousComment.compareTo("") == 0)) {
area.setText(previousComment);
} else {
area.setText(" - " + username+":\n");
area.setText(" - " + user.getFullName()+":\n");
}
if (areaHeight > 0) {
area.setPixelSize(PANEL_WIDTH, areaHeight);
@ -62,7 +62,7 @@ public class CommentDialog extends DialogBox {
enterImage.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
area.setText(area.getText() + "\n______\n"+username+":\n");
area.setText(area.getText() + "\n______\n"+user.getFullName()+":\n");
area.setPixelSize(PANEL_WIDTH, area.getOffsetHeight()+70);
}
});

View File

@ -183,7 +183,7 @@ public class ImageUploaderDialog extends DialogBox {
* @return .
*/
public String getImageURL(String imageName, String templateName) {
String currentUser = presenter.getCurrentUser();
String currentUser = presenter.getCurrentUser().getUsername();
String currentScope = presenter.getCurrentScope();
/**
* Images will be stored under webapps/usersArea...

View File

@ -14,7 +14,8 @@ import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import org.gcube.portlets.user.reportgenerator.client.targets.ClientAttributeArea;
import org.gcube.portlets.user.reportgenerator.client.targets.AttributeMultiSelection;
import org.gcube.portlets.user.reportgenerator.client.targets.AttributeSingleSelection;
import org.gcube.portlets.user.reportgenerator.client.targets.BasicTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.D4sRichTextarea;
import org.gcube.portlets.user.reportgenerator.client.targets.DropImageListener;
@ -33,6 +34,7 @@ import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.Widget;
@ -260,16 +262,27 @@ public class TemplateComponent {
this.content = table;
break;
case ATTRIBUTE_MULTI:
ClientAttributeArea ta = null;
AttributeMultiSelection ta = null;
if (sc.getPossibleContent() instanceof AttributeArea) {
AttributeArea sata = (AttributeArea) sc.getPossibleContent();
ta = new ClientAttributeArea(presenter, sc.getX(), sc.getY(), width, height, sata);
ta = new AttributeMultiSelection(presenter, sc.getX(), sc.getY(), width, height, sata);
}
else {
ta = new ClientAttributeArea(presenter, sc.getX(), sc.getY(), width, height, sc.getPossibleContent().toString());
ta = new AttributeMultiSelection(presenter, sc.getX(), sc.getY(), width, height, sc.getPossibleContent().toString());
}
this.content = ta;
break;
case ATTRIBUTE_UNIQUE:
AttributeSingleSelection atu = null;
if (sc.getPossibleContent() instanceof AttributeArea) {
AttributeArea sata = (AttributeArea) sc.getPossibleContent();
atu = new AttributeSingleSelection(presenter, sc.getX(), sc.getY(), width, height, sata);
}
else {
atu = new AttributeSingleSelection(presenter, sc.getX(), sc.getY(), width, height, sc.getPossibleContent().toString());
}
this.content = atu;
break;
case COMMENT:
HTML comment = new HTML();
comment.setStyleName("commentArea");
@ -398,15 +411,23 @@ public class TemplateComponent {
content = st;
break;
case ATTRIBUTE_MULTI:
ClientAttributeArea att = (ClientAttributeArea) this.content;
AttributeMultiSelection att = (AttributeMultiSelection) this.content;
ArrayList<Attribute> values = new ArrayList<Attribute>();
for (CheckBox box : att.getBoxes()) {
values.add(new Attribute(box.getText().trim(), box.getValue()));
}
GWT.log("Attr: " + att.getAttrName());
AttributeArea sat= new AttributeArea(att.getAttrName().trim(), values);
content = sat;
break;
case ATTRIBUTE_UNIQUE:
AttributeSingleSelection atu = (AttributeSingleSelection) this.content;
ArrayList<Attribute> singlevalues = new ArrayList<Attribute>();
for (RadioButton box : atu.getBoxes()) {
singlevalues.add(new Attribute(box.getText().trim(), box.getValue()));
}
AttributeArea satu = new AttributeArea(atu.getAttrName().trim(), singlevalues);
content = satu;
break;
case COMMENT:
content = ((HTML) this.content).getHTML();
break;

View File

@ -17,9 +17,8 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
* <code> AttributeArea </code> class
*
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @version April 2011 (1.0)
*/
public class ClientAttributeArea extends Composite {
public class AttributeMultiSelection extends Composite {
private HorizontalPanel myPanel;
private String attrName;
@ -28,7 +27,7 @@ public class ClientAttributeArea extends Composite {
/**
* Coming form a template constructor
*/
public ClientAttributeArea(final Presenter presenter, int left, int top, int width, final int height, String textToDisplay) {
public AttributeMultiSelection(final Presenter presenter, int left, int top, int width, final int height, String textToDisplay) {
myPanel = new HorizontalPanel();
myPanel.setTitle("Attribute Area");
myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
@ -51,7 +50,7 @@ public class ClientAttributeArea extends Composite {
/**
* Coming form a report constructor
*/
public ClientAttributeArea(final Presenter presenter, int left, int top, int width, final int height, AttributeArea sata) {
public AttributeMultiSelection(final Presenter presenter, int left, int top, int width, final int height, AttributeArea sata) {
myPanel = new HorizontalPanel();
myPanel.setTitle("Attribute Area");
myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
@ -94,7 +93,7 @@ public class ClientAttributeArea extends Composite {
try {
toReturn = toParse.substring(0, toParse.indexOf(":"));
} catch (StringIndexOutOfBoundsException e) {
GWT.log("Could not find : returning empty");
//GWT.log("Could not find : returning empty");
}
return toReturn;
}
@ -106,8 +105,8 @@ public class ClientAttributeArea extends Composite {
private CheckBox[] getCheckboxes(String toParse) {
String toSplit = toParse.substring(toParse.indexOf(":")+1, toParse.length());
String[] values = toSplit.split("\\|");
GWT.log("toSplit" + toSplit);
GWT.log("values" + values.length);
//GWT.log("toSplit" + toSplit);
//GWT.log("values" + values.length);
CheckBox[] boxes = new CheckBox[values.length];
for (int i = 0; i < values.length; i++) {
boxes[i] = new CheckBox();

View File

@ -0,0 +1,144 @@
package org.gcube.portlets.user.reportgenerator.client.targets;
import org.gcube.portlets.d4sreporting.common.shared.Attribute;
import org.gcube.portlets.d4sreporting.common.shared.AttributeArea;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RadioButton;
/**
* <code> AttributeArea </code> class
*
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
*/
public class AttributeSingleSelection extends Composite {
private final String RADIO_NAME = "radio_unique";
private HorizontalPanel myPanel;
private String attrName;
private RadioButton[] boxes;
/**
* Coming form a template constructor
*/
public AttributeSingleSelection(final Presenter presenter, int left, int top, int width, final int height, String textToDisplay) {
myPanel = new HorizontalPanel();
myPanel.setTitle("Attribute Area");
myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
myPanel.setPixelSize(width, 20);
myPanel.addStyleName("attributeArea");
attrName = getAttributeName(textToDisplay);
HTML attrNameLabel = new HTML(attrName+":");
attrNameLabel.getElement().getStyle().setMarginRight(5, Unit.PX);
FlowPanel boxesPanel = new FlowPanel();
boxesPanel.add(attrNameLabel);
myPanel.add(boxesPanel);
myPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
boxes = getRadioboxes(textToDisplay);
for (int i = 0; i < boxes.length; i++) {
boxesPanel.add(boxes[i]);
}
initWidget(myPanel);
}
/**
* Coming form a report constructor
*/
public AttributeSingleSelection(final Presenter presenter, int left, int top, int width, final int height, AttributeArea sata) {
myPanel = new HorizontalPanel();
myPanel.setTitle("Attribute Area");
myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
myPanel.setPixelSize(width, 20);
myPanel.addStyleName("attributeArea");
attrName = sata.getAttrName();
HTML attrNameLabel = new HTML(attrName+":");
attrNameLabel.getElement().getStyle().setMarginRight(5, Unit.PX);
FlowPanel boxesPanel = new FlowPanel();
boxesPanel.add(attrNameLabel);
myPanel.add(boxesPanel);
myPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
int values = sata.getValues().size();
boxes = new RadioButton[values];
int j = 0;
for (Attribute attr: sata.getValues()) {
RadioButton toAdd = new RadioButton(RADIO_NAME, attr.getName());
toAdd.setStyleName("checkAttribute");
toAdd.setValue(attr.getValue());
boxes[j] = toAdd;
j++;
}
//adding it to the panel
for (int i = 0; i < boxes.length; i++) {
boxesPanel.add(boxes[i]);
}
initWidget(myPanel);
}
/**
*
* @param toParse
* @return
*/
private String getAttributeName(String toParse) {
if (toParse == null)
return "";
String toReturn = "";
try {
toReturn = toParse.substring(0, toParse.indexOf(":"));
} catch (StringIndexOutOfBoundsException e) {
//GWT.log("Could not find : returning empty");
}
return toReturn;
}
/**
*
* @param toParse
* @return
*/
private RadioButton[] getRadioboxes(String toParse) {
String toSplit = toParse.substring(toParse.indexOf(":")+1, toParse.length());
String[] values = toSplit.split("\\|");
// GWT.log("toSplit" + toSplit);
// GWT.log("values" + values.length);
RadioButton[] boxes = new RadioButton[values.length];
for (int i = 0; i < values.length; i++) {
boxes[i] = new RadioButton(RADIO_NAME, values[i].trim());
boxes[i].setStyleName("checkAttribute");
}
return boxes;
}
/**
*
* @return
*/
public ComponentType getType() {
return ComponentType.ATTRIBUTE_MULTI;
}
/**
*
* @return
*/
public RadioButton[] getBoxes() {
return boxes;
}
/**
*
* @return
*/
public String getAttrName() {
return attrName;
}
}

View File

@ -154,7 +154,7 @@ public class DroppingArea extends Component {
* @return .
*/
public String getImageURL(String imageName, String templateName) {
currentUser = presenter.getCurrentUser();
currentUser = presenter.getCurrentUser().getUsername();
currentScope = presenter.getCurrentScope();
/**
* Images will be stored under webapps/usersArea...

View File

@ -39,7 +39,7 @@ public class ImageArea extends Composite {
*/
public ImageArea(Presenter presenter, String param, String myTemplate, boolean isURL, int w, int h) {
myPanel = new VerticalPanel();
currentUser = presenter.getCurrentUser();
currentUser = presenter.getCurrentUser().getUsername();
currentScope = presenter.getCurrentScope();
//Window.alert("Image Area");

View File

@ -33,17 +33,18 @@ 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;
import org.gcube.portlets.admin.wfdocslibrary.client.WfDocsLibrary;
import org.gcube.portlets.admin.wfdocslibrary.server.db.MyDerbyStore;
import org.gcube.portlets.admin.wfdocslibrary.server.db.Store;
import org.gcube.portlets.d4sreporting.common.server.ServiceUtil;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
import org.gcube.portlets.d4sreporting.common.shared.Model;
import org.gcube.portlets.d4sreporting.common.shared.BasicSection;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.Model;
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
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;
@ -73,9 +74,12 @@ import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenReport
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenWorkflowLogEntry;
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.SaveWorkflowLogEntry;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.UserBean;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.model.UserModel;
import com.liferay.portal.service.LockLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
@ -84,12 +88,11 @@ import com.liferay.portlet.documentlibrary.model.DLFileEntry;
*
* class implementing services
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @version Feb 2012 (3.3)
*/
@SuppressWarnings("serial")
public class ReportServiceImpl extends RemoteServiceServlet implements ReportService {
public static GCUBEClientLog logger = new GCUBEClientLog(ReportServiceImpl.class);
public static GCUBEClientLog _log = new GCUBEClientLog(ReportServiceImpl.class);
/**
* EXPORT DIR
*/
@ -153,10 +156,13 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
* Called then servlet is intialized
*/
public void init() {
logger.info("Initializing Servlet ReportServiceImpl...");
_log.info("Initializing Servlet ReportServiceImpl...");
store = new MyDerbyStore();
}
/**
* used for debugging in eclipse
*/
private boolean withinPortal = false;
/**
* the current ASLSession
* @return .
@ -164,16 +170,17 @@ 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);
logger.error("Report PORTLET SessionID= " + sessionID);
if (user == null) {
user = "massimiliano.assante";
this.getThreadLocalRequest().getSession().setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec");
}
if (!withinPortal)
_log.warn("\n\n****** Starting in Development MODE ******\n\n");
return SessionManager.getInstance().getASLSession(sessionID, user);
}
/**
* Retrieve the user saved template names
@ -185,7 +192,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
Vector<String> tmp = new Vector<String>();
String userDir = myUtil.getTemplateFolder(getVreName(), getUsername());
logger.debug("userDir: " + userDir);
_log.debug("userDir: " + userDir);
File f = new File(userDir);
//checking if dir exists
@ -229,7 +236,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
logger.debug("Converting Imported Fimes to Serializable object, num sectionss: " + toConvert.getSections().size());
_log.debug("Converting Imported Fimes to Serializable object, num sectionss: " + toConvert.getSections().size());
return (toConvert);
}
@ -243,7 +250,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*/
public Model readModel(String templateName, String templateObjectID, boolean isTemplate, boolean isImporting) {
ServiceUtil myUtil = new ServiceUtil(getASLSession());
logger.debug("Reading " + templateName);
_log.debug("Reading " + templateName);
if (! ReportConstants.isDeployed) {
Model toConvert = null;
@ -261,7 +268,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
logger.debug("Converting fileToRead to Serializable object");
_log.debug("Converting fileToRead to Serializable object");
return toConvert;
} else {
@ -289,12 +296,12 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
e.printStackTrace();
}
logger.debug("getItem: " + templateObjectID);
_log.debug("getItem: " + templateObjectID);
String zipToExtract = "";
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
logger.debug("\nItem is a BASKET_ITEM");
_log.debug("\nItem is a FolderItem");
FolderItem bi = (FolderItem) item;
boolean fromBasket = false;
@ -305,7 +312,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String zipFilename = "";
if (! isTemplate) {//then is a report
zipFilename = templateName + "-report.zip"; //gCube report
logger.debug("********************** Reading report -----------------");
_log.debug("********************** Reading report -----------------");
}
else
zipFilename = templateName + ".zip"; //gCube template
@ -318,13 +325,13 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if (bi.getFolderItemType() == FolderItemType.REPORT) {
logger.debug("Item is a REPORT");
_log.debug("Item is a REPORT");
Report zippedTemplate = (Report) bi;
String zipFilename = "";
if (! isTemplate) {//then is a report
zipFilename = templateName + "-report.zip"; //d4science template
logger.debug("********************** Reading report -----------------");
_log.debug("********************** Reading report -----------------");
}
else
zipFilename = templateName + ".zip"; //d4science template
@ -365,7 +372,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
// }
logger.debug("Loading fileToRead from Disk");
_log.debug("Loading fileToRead from Disk");
Model toReturn = null;
Model toConvert = null;
@ -382,7 +389,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
logger.debug("Converting fileToRead to Serializable object");
_log.debug("Converting fileToRead to Serializable object");
toReturn = (toConvert);
// changes the template name model
@ -395,14 +402,14 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
File toDelete2 = new File(zipToExtract);
boolean deleted2 = toDelete2.delete();
logger.debug("dirToDelete: " + toDelete1 + " result: " + deleted1 + " \n\n\n");
_log.debug("dirToDelete: " + toDelete1 + " result: " + deleted1 + " \n\n\n");
logger.debug("dirToDelete: " + toDelete2 + " result: " + deleted2 + " \n\n\n");
_log.debug("dirToDelete: " + toDelete2 + " result: " + deleted2 + " \n\n\n");
//**** IMPORTANT ****
if (! isImporting) {
storeTemplateInSession(toReturn);
logger.debug("storeTemplateInSession DONE");
_log.debug("storeTemplateInSession DONE");
}
AccessLogger log = AccessLogger.getAccessLogger();
@ -412,10 +419,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
return toReturn;
}
}
logger.error("FAILED TO READ RETURING EMPTY Serializable Template");
_log.error("FAILED TO READ RETURING EMPTY Serializable Template");
return new Model();
}
logger.error("FAILED TO READ FROM BASKET RETURING EMPTY Serializable Template");
_log.error("FAILED TO READ FROM BASKET RETURING EMPTY Serializable Template");
return new Model();
}
}
@ -431,23 +438,23 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
* @throws FileNotFoundException
*/
private String seekModel(String templatePath, String templateName) throws FileNotFoundException {
logger.debug("seekModel: tPath=" + templatePath);
_log.debug("seekModel: tPath=" + templatePath);
String fileToSeek = templatePath + templateName + ".d4st";
File toSeek = new File(fileToSeek);
if (toSeek.exists()) {
logger.debug("seekModel: modelName is the SAME returning");
_log.debug("seekModel: modelName is the SAME returning");
return templateName;
}
else {
logger.debug("seekModel: modelName DIFFERENT upgrading");
_log.debug("seekModel: modelName DIFFERENT upgrading");
File dirToLookIn = new File(templatePath);
File[] innerFiles = dirToLookIn.listFiles();
for (int i = 0; i < innerFiles.length; i++)
if (innerFiles[i].getName().endsWith(".d4st")) {
String toReturn = innerFiles[i].getName();
toReturn = toReturn.substring(0, toReturn.length()-5);
logger.debug("seekModel: returning.. =" + toReturn);
_log.debug("seekModel: returning.. =" + toReturn);
return toReturn;
}
}
@ -463,7 +470,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
private boolean getTemplateFromBasket(ReportTemplate repTmp, String pathToFile, String filename) {
try {
File dir = new File(pathToFile);
logger.debug("DIR: " + pathToFile);
_log.debug("DIR: " + pathToFile);
if (! dir.exists() )
dir.mkdirs();
@ -484,7 +491,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
out.write(buf,0,len);
out.close();
inputStream.close();
logger.info("Successfully got ReportTemplate from Basket: " + pathToFile);
_log.info("Successfully got ReportTemplate from Basket: " + pathToFile);
return true;
}
catch (IOException e){
@ -504,7 +511,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
private boolean getReportFromBasket(Report repTmp, String pathToFile, String filename) {
try {
File dir = new File(pathToFile);
logger.debug("DIR: " + pathToFile);
_log.debug("DIR: " + pathToFile);
if (! dir.exists() )
dir.mkdirs();
@ -525,7 +532,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
out.write(buf,0,len);
out.close();
inputStream.close();
logger.info("Successfully got ReportTemplate from Basket: " + pathToFile);
_log.info("Successfully got ReportTemplate from Basket: " + pathToFile);
return true;
}
catch (IOException e){
@ -537,14 +544,14 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*
*/
public String generateTempDocx(Model model) {
logger.info("Generating docx file");
_log.info("Generating docx file");
DocxGenerator docxGenerator = new DocxGenerator(model);
logger.debug("DocxGenerator instanciated:");
_log.debug("DocxGenerator instanciated:");
//boolean result = new DocxGenerator(model, true, true);
// logger.trace("RESULT:" + result);
// if (! result)
// return "ERROR";
// logger.trace("RESULT:" + result);
// if (! result)
// return "ERROR";
File docx = null;
try {
@ -553,7 +560,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
e.printStackTrace();
return "ERROR";
}
logger.info("Generated docx file: " + docx.getAbsolutePath());
_log.info("Generated docx file: " + docx.getAbsolutePath());
return docx.getAbsolutePath();
}
/**
@ -585,12 +592,12 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
boolean result = false;
ServiceUtil myUtil = new ServiceUtil(getASLSession());
logger.info("Generating docx file");
logger.debug("Model Converted");
_log.info("Generating docx file");
_log.debug("Model Converted");
DocxGenerator docxGenerator = new DocxGenerator(model);
logger.info("DocxGenerator instanciated:");
// result = docxGenerator.exportInDocx(model, true, true);
logger.trace("RESULT:" + result);
_log.info("DocxGenerator instanciated:");
// result = docxGenerator.exportInDocx(model, true, true);
_log.trace("RESULT:" + result);
//remove the extension
String exportName = model.getTemplateName();
if (exportName.endsWith(".d4sT") || exportName.endsWith(".d4sR") )
@ -602,13 +609,13 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
case DOCX:
try {
File docx = docxGenerator.outputTmpFile();
logger.debug("Generated docx file: " + docx.getAbsolutePath());
_log.debug("Generated docx file: " + docx.getAbsolutePath());
File toMoveTo = new File(myUtil.getTemplateFolder(getVreName(), getUsername()) + EXPORTS_DIR + File.separator + exportName + ".docx");
String folder = (myUtil.getTemplateFolder(getVreName(), getUsername()) + EXPORTS_DIR + File.separator);
myUtil.copyFile(docx, toMoveTo, folder);
logger.trace("1 File Copied to " + toMoveTo.getAbsolutePath());
_log.trace("1 File Copied to " + toMoveTo.getAbsolutePath());
String name = exportName+".docx";
String desc = name;
@ -622,12 +629,12 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
case HTML:
try {
File html = docxGenerator.outputHTMLTmpFile();
logger.info("Generated HTML file: " + html.getAbsolutePath());
_log.info("Generated HTML file: " + html.getAbsolutePath());
File toMoveTo = new File(myUtil.getTemplateFolder(getVreName(), getUsername()) + EXPORTS_DIR + File.separator + exportName + ".html");
String folder = (myUtil.getTemplateFolder(getVreName(), getUsername()) + EXPORTS_DIR + File.separator);
myUtil.copyFile(html, toMoveTo, folder);
logger.trace("1 File Copied to " + toMoveTo.getAbsolutePath());
_log.trace("1 File Copied to " + toMoveTo.getAbsolutePath());
String name = exportName+".html";
String desc = name;
@ -666,7 +673,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
WorkspaceFolder toSaveIn = wp.getRoot();
if (toSaveIn.exists(name)) {
logger.warn("Item exists already, deleting and creating new one");
_log.warn("Item exists already, deleting and creating new one");
toSaveIn.removeChild(toSaveIn.find(name));
}
@ -704,9 +711,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if(session.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE)== null)
{
user = "massimiliano.assante";
logger.warn("D4ScienceSession user NULL set to: " + user);
_log.warn("D4ScienceSession user NULL set to: " + user);
}
logger.warn("ASLSession user: " + user);
_log.warn("ASLSession user: " + user);
ASLSession d4session = SessionManager.getInstance().getASLSession(session.getId(), user);
d4session.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
@ -730,13 +737,13 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if(scope == null) {
scope = "gcube/devsec";
logger.warn("ASL Session scope NULL set to: " + scope);
_log.warn("ASL Session scope NULL set to: " + scope);
}
//need to remove the initial / of the scope
if (scope.charAt(0) == '/')
scope = scope.substring(1, scope.length());
logger.info("SCOPE: " + scope);
_log.info("SCOPE: " + scope);
return scope;
}
@ -765,7 +772,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
* @return the Default basket if if there is no basket in session, else the basket in session id
*/
public String getDefaultBasket() {
logger.info("getDefaultBasket()");
_log.info("getDefaultBasket()");
try {
Workspace workspaceArea = getWorkspaceArea();
@ -792,17 +799,17 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String templateid = (String) d4Session.getAttribute("idreport");
Object workflowid = getASLSession().getAttribute(WfDocsLibrary.LAST_WORKFLOW_ID);
logger.debug(" (templateid != null && workflowid != null) = " + (templateid != null) + " - " + (workflowid != null));
_log.debug(" (templateid != null && workflowid != null) = " + (templateid != null) + " - " + (workflowid != null));
if (workflowid != null) {
getASLSession().setAttribute(WfDocsLibrary.LAST_WORKFLOW_ID, null);
return null;
}
String templateName = "";
logger.debug("TEMPLATE ID==NULL " + (templateid == null));
_log.debug("TEMPLATE ID==NULL " + (templateid == null));
if (templateid != null) {
if (! templateid.equals("")) {
logger.debug("READING SESSION VARIABLE FOR REPORT ID... " + templateid);
_log.debug("READING SESSION VARIABLE FOR REPORT ID... " + templateid);
//reset the value
d4Session.setAttribute("idreport", "");
Workspace root = null;
@ -811,7 +818,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
root = getWorkspaceArea();
item = root.getItem(templateid);
logger.info("READ REPORT FROM WP... " + item.getName());
_log.info("READ REPORT FROM WP... " + item.getName());
templateName = item.getName();
} catch (WorkspaceFolderNotFoundException e) {e.printStackTrace();
} catch (InternalErrorException e) { e.printStackTrace();
@ -827,16 +834,16 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
else {
if (d4Session.getAttribute(CURRENT_REPORT_INSTANCE) != null) {
logger.debug("getAttribute(\"CURRENT_REPORT_INSTANCE\")...");
_log.debug("getAttribute(\"CURRENT_REPORT_INSTANCE\")...");
Model model = (Model) d4Session.getAttribute(CURRENT_REPORT_INSTANCE) ;
logger.debug(model.getTemplateName());
_log.debug(model.getTemplateName());
return model;
}
}
ServiceUtil myUtil = new ServiceUtil(getASLSession());
String dirToClean = myUtil.getTemplateFolder(getVreName(), getUsername());
logger.info("RETURNING NULL, going to clean user template area: " + dirToClean);
_log.info("RETURNING NULL, going to clean user template area: " + dirToClean);
if (ReportConstants.isDeployed)
delTemplateDir(new File(dirToClean));
return null;
@ -880,15 +887,15 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
private void importDynamicImagesFromHL(Model model) {
ServiceUtil myUtil = new ServiceUtil(getASLSession());
logger.debug("model == NULL " + (model == null));
_log.debug("model == NULL " + (model == null));
Vector<BasicSection> sections = model.getSections();
for (BasicSection section : sections) {
logger.debug("\n\n****section.getComponents() == NULL " + (section.getComponents() == null));
_log.debug("\n\n****section.getComponents() == NULL " + (section.getComponents() == null));
for (BasicComponent component : section.getComponents()) {
if (component.getType() == ComponentType.DYNA_IMAGE) {
logger.debug("Found DP: " + component.getPossibleContent());
_log.debug("Found DP: " + component.getPossibleContent());
logger.debug("ID In Basket null?: " + (component.getIdInBasket() == null));
_log.debug("ID In Basket null?: " + (component.getIdInBasket() == null));
if (component.getIdInBasket() != null) {
@ -899,7 +906,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
imageNameFile = copyImageFromBasket(imageID, imageTargetDIR, imageNameFile);
component.setPossibleContent(getImageURL(imageNameFile, model.getTemplateName()));
logger.trace("NEW setPossibleContent: " + component.getPossibleContent());
_log.trace("NEW setPossibleContent: " + component.getPossibleContent());
}
}
}
@ -914,7 +921,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*/
private String getImageURL(String imageName, String templateName) {
String toReturn = currentHost + "usersArea/" + getVreName() + "/templates/" + getUsername() + "/CURRENT_OPEN/images/" + imageName;
logger.info("getImageURL" + toReturn);
_log.info("getImageURL" + toReturn);
return toReturn;
}
@ -943,15 +950,15 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
e.printStackTrace();
}
logger.debug("pathToFile: " + pathToFile);
_log.debug("pathToFile: " + pathToFile);
File f = null;
String toReturn ="";
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
logger.debug("\nItem is a BASKET_ITEM");
_log.debug("\nItem is a BASKET_ITEM");
FolderItem bi = (FolderItem) item;
try {
File dir = new File(pathToFile);
logger.debug("DIR: " + pathToFile);
_log.debug("DIR: " + pathToFile);
if (! dir.exists() )
dir.mkdirs();
@ -960,7 +967,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
InputStream data = null;
if (bi.getFolderItemType()==FolderItemType.EXTERNAL_IMAGE){
logger.debug("EXTERNAL_IMAGE -|- " + item.getType());
_log.debug("EXTERNAL_IMAGE -|- " + item.getType());
ExternalImage image = (ExternalImage)item;
data = image.getData();
}
@ -989,7 +996,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
e.printStackTrace();
}
}
logger.info("RETURNING: " + f.getAbsolutePath());
_log.info("RETURNING: " + f.getAbsolutePath());
return toReturn;
}
@ -1056,7 +1063,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String imageNewFolder = myUtil.getTemplatePath(toTemplate, getVreName(), getUsername()) + "images" + File.separator;
logger.debug("Copying:\n" + imageFrom + "\nto: " + imageTarget);
_log.debug("Copying:\n" + imageFrom + "\nto: " + imageTarget);
File from = new File(imageFrom);
File to = new File(imageTarget);
@ -1064,10 +1071,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
try {
myUtil.copyFile(from, to, imageNewFolder);
} catch (Exception e) {
logger.error("Error While Copying: " + e.getMessage());
_log.error("Error While Copying: " + e.getMessage());
return false;
}
logger.debug("Copying Success\n");
_log.debug("Copying Success\n");
return true;
}
@ -1079,7 +1086,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
public void storeReportItemIDInSession(String reportItemid) {
ASLSession d4Session = getASLSession();
d4Session.setAttribute(CURRENT_REPORT_ID_ATTRIBUTE, reportItemid);
logger.debug("WROTE REPORT ID IN SESSION: " + reportItemid);
_log.debug("WROTE REPORT ID IN SESSION: " + reportItemid);
}
/**
@ -1114,21 +1121,21 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
else {
logger.debug("getReportItemIDFromSession RETURNS -> " + getReportItemIDFromSession() + "");
_log.debug("getReportItemIDFromSession RETURNS -> " + getReportItemIDFromSession() + "");
item = root.getItem(getReportItemIDFromSession());
folderid = item.getParent().getId();
itemName = item.getName();
}
} catch (ItemNotFoundException e) {
logger.error("ITEM NOT FOUND -> " + getReportItemIDFromSession());
_log.error("ITEM NOT FOUND -> " + getReportItemIDFromSession());
} catch (InternalErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.debug("folderid -> " + folderid);
_log.debug("folderid -> " + folderid);
saveReport(folderid, itemName);
}
@ -1142,9 +1149,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
Model model = readTemplateFromSession();
//raplacing " " with _
logger.info("Serializing Model basketidToSaveIn: " + folderid );
_log.info("Serializing Model basketidToSaveIn: " + folderid );
logger.info("Trying to convert dynamic images ... ");
_log.info("Trying to convert dynamic images ... ");
importDynamicImagesFromHL(model);
ServiceUtil myUtil = new ServiceUtil(getASLSession());
@ -1153,7 +1160,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if (!result) {
logger.debug("Could not save report, serializing failed");
_log.debug("Could not save report, serializing failed");
}
else {
String templatePath = myUtil.getTemplateFolder(getVreName(), getUsername()) + "CURRENT_OPEN";
@ -1163,7 +1170,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
e.printStackTrace();
}
logger.debug("Trying to zip folder: " + templatePath);
_log.debug("Trying to zip folder: " + templatePath);
String folderToZip = templatePath;
String outZip = templatePath+"-report.zip";
@ -1171,10 +1178,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
try {
ZipUtil.zipDir(outZip, folderToZip);
} catch (IOException e) {
logger.error("Could not zip template, serializing failed");
_log.error("Could not zip template, serializing failed");
e.printStackTrace();
}
logger.info("Folder zipped, result: "+ outZip);
_log.info("Folder zipped, result: "+ outZip);
InputStream isZip = null;
@ -1187,13 +1194,13 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if (templateName.endsWith("d4sR") ) {
if (toSaveIn.exists(templateName)) {
logger.warn("Item exists already, deleting and creating new one");
_log.warn("Item exists already, deleting and creating new one");
toSaveIn.removeChild(toSaveIn.find(templateName));
}
}
if (toSaveIn.exists(templateName + ".d4sR")) {
logger.warn("Item exists already, deleting and creating new one");
_log.warn("Item exists already, deleting and creating new one");
toSaveIn.removeChild(toSaveIn.find(templateName + ".d4sR"));
}
@ -1259,7 +1266,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
for (WorkspaceItem item : items)
if (item.getName().equals(name2Check)) {
item.remove();
logger.info("ITEM REMOVED: "+ name2Check);
_log.info("ITEM REMOVED: "+ name2Check);
return true;
}
return false;
@ -1284,14 +1291,14 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
try {
item = root.getItem(basketId);
} catch (ItemNotFoundException e) {
logger.info("BASKET : " + basketId + " NOT FOUND RETURNING DEFAULT ONE");
_log.info("BASKET : " + basketId + " NOT FOUND RETURNING DEFAULT ONE");
return(WorkspaceFolder)root.getItem(getDefaultBasket());
}
logger.debug("Item Type: "+item.getType());
_log.debug("Item Type: "+item.getType());
if (item.getType() != WorkspaceItemType.FOLDER) {
logger.error("The item id does not belong to a basket id:" + basketId);
_log.error("The item id does not belong to a basket id:" + basketId);
return null;
}
return (WorkspaceFolder) item;
@ -1339,15 +1346,15 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} catch (ItemNotFoundException e) {
e.printStackTrace();
}
logger.debug("Got Item TS From HL, Item Type: "+item.getType());
_log.debug("Got Item TS From HL, Item Type: "+item.getType());
if (item.getType() != WorkspaceItemType.FOLDER_ITEM) {
logger.debug("The item id does not belong to a timeseries, id:" + timeSeriesBasketID);
_log.debug("The item id does not belong to a timeseries, id:" + timeSeriesBasketID);
return null;
}
FolderItem bItem = (FolderItem) item;
if (bItem.getFolderItemType() != FolderItemType.TIME_SERIES) {
logger.debug("The basket item does not belong to a timeseries, id:" + timeSeriesBasketID);
_log.debug("The basket item does not belong to a timeseries, id:" + timeSeriesBasketID);
return null;
}
@ -1355,7 +1362,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
return getTSFromBasket(ts);
}
catch (NullPointerException e) {
logger.error("No TS was dragged in the Area returning NULL");
_log.error("No TS was dragged in the Area returning NULL");
return null;
}
}
@ -1473,7 +1480,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
out.write(buf,0,len);
out.close();
inputStream.close();
logger.debug("Successfully got TimeSeries from Basket: \n" + temp.getAbsolutePath());
_log.debug("Successfully got TimeSeries from Basket: \n" + temp.getAbsolutePath());
return temp;
}
catch (IOException e){
@ -1501,21 +1508,20 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE, "1");
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_GIVEN_NAME, "TEST REPORT");
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_READONLY_ATTRIBUTE, true);
return new SessionInfo(getUsername(), getVreName(), true, true);
return new SessionInfo(getUserBean(), getVreName(), true, true);
}
if (getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE) == null) {
logger.debug("WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE is NULL: ");
return new SessionInfo(getUsername(), getVreName(), false, false);
_log.debug("WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE is NULL: ");
return new SessionInfo(getUserBean(), getVreName(), false, false);
}
else {
logger.debug("FOUND WORKFLOW_ID_ATTRIBUTE ***** ");
_log.debug("FOUND WORKFLOW_ID_ATTRIBUTE ***** ");
//String workflowid = getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE).toString();
Boolean canEdit = ! (Boolean) getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_READONLY_ATTRIBUTE);
return new SessionInfo(getUsername(), getVreName(), true, canEdit);
return new SessionInfo(getUserBean(), getVreName(), true, canEdit);
}
}
public Model getWorkflowDocumentFromDocumentLibrary() {
ServiceUtil myUtil = new ServiceUtil(getASLSession());
@ -1534,19 +1540,19 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
ex.printStackTrace();
}
toConvert.setTemplateName("TEST");
logger.info(" Converting TEST REPORT to Serializable object, model name: \n" + toConvert.getTemplateName());
_log.info(" Converting TEST REPORT to Serializable object, model name: \n" + toConvert.getTemplateName());
return toConvert;
}
else {
String workflowid = getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE).toString();
Boolean canEdit = ! (Boolean) getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_READONLY_ATTRIBUTE);
String documentName = getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_GIVEN_NAME).toString();
logger.info("getWorkflowDocumentFromDocumentLibrary() CALLED ***** ID = " + workflowid + " name:\n " + documentName);
_log.info("getWorkflowDocumentFromDocumentLibrary() CALLED ***** ID = " + workflowid + " name:\n " + documentName);
//TODO: check this
//reset the values in session
logger.info("Reset the values in session ... ");
_log.info("Reset the values in session ... ");
getASLSession().setAttribute(WfDocsLibrary.LAST_WORKFLOW_ID, workflowid);
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE, null);
@ -1581,7 +1587,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
ex.printStackTrace();
}
toConvert.setTemplateName(documentName);
logger.debug("Converting fileToRead to Serializable object, model name: \n" + toConvert.getTemplateName());
_log.debug("Converting fileToRead to Serializable object, model name: \n" + toConvert.getTemplateName());
Model toReturn = (toConvert);
//saves this model as previous one in session
@ -1610,7 +1616,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
private File writeReportToDisk(InputStream isData, String pathToFile, String filename) {
try {
File dir = new File(pathToFile);
logger.debug("DIR: " + pathToFile);
_log.debug("DIR: " + pathToFile);
if (! dir.exists() )
dir.mkdirs();
@ -1619,7 +1625,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
IOUtils.copy(isData, out);
out.close();
logger.debug("Successfully WROTE ReportTemplate from DL: " + pathToFile);
_log.debug("Successfully WROTE ReportTemplate from DL: " + pathToFile);
return f;
}
catch (IOException e){
@ -1639,18 +1645,18 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String documentWorkflowOwnerId = store.getWorkflowById(workflowid).getAuthor();
String documentWorkflowName = store.getWorkflowById(workflowid).getName();
if (update) {
logger.debug("SAVING in WorkflowDocument Library ");
_log.debug("SAVING in WorkflowDocument Library ");
model = (Model) session.getAttribute(CURRENT_REPORT_INSTANCE);
logger.debug("Trying to convert dynamic images ... ");
_log.debug("Trying to convert dynamic images ... ");
importDynamicImagesFromHL(model);
boolean result = myUtil.writeModel(model, "CURRENT_OPEN", getVreName(), getUsername());
if (!result) {
logger.error("Could not save report, serializing failed");
_log.error("Could not save report, serializing failed");
}
else {
String templatePath = myUtil.getTemplateFolder(getVreName(), getUsername()) + "CURRENT_OPEN";
@ -1660,18 +1666,18 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
e.printStackTrace();
}
logger.debug("Trying to zip folder: " + templatePath);
_log.debug("Trying to zip folder: " + templatePath);
String folderToZip = templatePath;
String outZip = templatePath+"-report.zip";
try {
ZipUtil.zipDir(outZip, folderToZip);
logger.debug("Folder zipped, result: "+ outZip);
_log.debug("Folder zipped, result: "+ outZip);
InputStream isZip = new BufferedInputStream(new FileInputStream(outZip));
DocLibraryUtil.updateFileIntoDocLibrary(getASLSession(), workflowid, getBytesFromInputStream(isZip));
logger.info("Updated in DOC LIB OK");
_log.info("Updated in DOC LIB OK");
store.addWorkflowLogAction(workflowid, getASLSession().getUsername(), "Updated");
//send the notification
@ -1684,7 +1690,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
catch (Exception e) {
logger.error("Could not zip template, serializing failed");
_log.error("Could not zip template, serializing failed");
e.printStackTrace();
}
}
@ -1698,7 +1704,39 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
unlock(workflowid);
getASLSession().setAttribute("idreport", null);
}
/**
*
* @return the info about the current user
*/
private UserBean getUserBean() {
try {
String username = getASLSession().getUsername();
String email = username+"@isti.cnr.it";
String fullName = username+" FULL";
String thumbnailURL = "images/Avatar_default.png";
if (withinPortal) {
UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
fullName = user.getFirstName() + " " + user.getLastName();
email = user.getEmailAddress();
UserBean toReturn = new UserBean(username, fullName, thumbnailURL, user.getEmailAddress());
_log.info("Returning USER: " + toReturn);
return toReturn;
}
else {
UserBean toReturn = new UserBean(getASLSession().getUsername(), fullName, thumbnailURL, email);
_log.info("Returning test USER: " + toReturn);
return toReturn;
}
} catch (Exception e) {
e.printStackTrace();
}
return new UserBean();
}
/**
*/
byte[] getBytesFromInputStream(InputStream is) {
@ -1719,9 +1757,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
DLFileEntry fileEntry;
try {
fileEntry = DocLibraryUtil.getFileEntry(getASLSession(), workflowid);
logger.info("Log action saved, trying ot unlock document ...");
_log.info("Log action saved, trying ot unlock document ...");
LockLocalServiceUtil.unlock(DLFileEntry.class.getName(), fileEntry.getFileEntryId());
logger.info("UNLOCK OK!");
_log.info("UNLOCK OK!");
}
catch (Exception e) {
e.printStackTrace();
@ -1734,11 +1772,11 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String workflowid = getASLSession().getAttribute(WfDocsLibrary.LAST_WORKFLOW_ID).toString();
try {
DLFileEntry fileEntry = DocLibraryUtil.getFileEntry(getASLSession(), workflowid);
logger.info("Renewing Lock ...");
_log.info("Renewing Lock ...");
long fifteenMin = 900000;
Date currTimePlus15 = new Date(new Date().getTime() + fifteenMin);
LockLocalServiceUtil.getLock(DLFileEntry.class.getName(), fileEntry.getFileEntryId()).setExpirationDate(currTimePlus15);
logger.info("Lock Renewed, expiring: " + currTimePlus15);
_log.info("Lock Renewed, expiring: " + currTimePlus15);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -5,28 +5,28 @@ import java.io.Serializable;
@SuppressWarnings("serial")
public class SessionInfo implements Serializable {
private String username;
private UserBean user;
private String scope;
private Boolean isWorkflowDocument;
private Boolean isEditable;
public SessionInfo() { }
public SessionInfo(String username, String scope,
public SessionInfo(UserBean user, String scope,
Boolean isWorkflowDocument, Boolean canEdit) {
super();
this.username = username;
this.user = user;
this.scope = scope;
this.isWorkflowDocument = isWorkflowDocument;
this.isEditable = canEdit;
}
public String getUsername() {
return username;
public UserBean getUsername() {
return user;
}
public void setUsername(String username) {
this.username = username;
public void UserBean(UserBean userBean) {
this.user = userBean;
}
public String getScope() {

View File

@ -0,0 +1,72 @@
package org.gcube.portlets.user.reportgenerator.shared;
import java.io.Serializable;
import java.util.HashMap;
/**
* @author Massimiliano Assante ISTI-CNR
*/
@SuppressWarnings("serial")
public class UserBean implements Serializable {
public transient final static String USER_INFO_ATTR = "USER_INFO_ATTR";
private String username;
private String fullName;
private String avatarId;
private String emailaddress;
public UserBean() {
super();
}
public UserBean(String username, String fullName, String avatarId, String emailaddress) {
super();
this.username = username;
this.fullName = fullName;
this.avatarId = avatarId;
this.emailaddress = emailaddress;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getAvatarId() {
return avatarId;
}
public void setAvatarId(String avatarId) {
this.avatarId = avatarId;
}
public String getEmailaddress() {
return emailaddress;
}
public void setEmailaddress(String emailaddress) {
this.emailaddress = emailaddress;
}
@Override
public String toString() {
return "UserBean [username=" + username + ", fullName=" + fullName
+ ", avatarId=" + avatarId + ", emailaddress=" + emailaddress + "]";
}
}