From 8bb9c9ad6f00e31660adf19f4fb5c4ea3cd55df9 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 5 Aug 2014 16:33:49 +0000 Subject: [PATCH] Minor Update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@99222 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/td/client/TabularDataController.java | 40 ++-- .../portlets/user/td/client/logs/TDMLogs.java | 177 ++++++++++++++++++ .../user/td/client/ribbon/FileToolBar.java | 64 +++++-- .../WEB-INF/classes/log4j_properties_sample | 19 ++ src/main/webapp/WEB-INF/classes/logback.xml | 36 ++++ .../WEB-INF/classes/logging_properties_sample | 1 + src/main/webapp/WEB-INF/web.xml | 137 ++++++-------- 7 files changed, 354 insertions(+), 120 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/client/logs/TDMLogs.java create mode 100644 src/main/webapp/WEB-INF/classes/log4j_properties_sample create mode 100644 src/main/webapp/WEB-INF/classes/logback.xml create mode 100644 src/main/webapp/WEB-INF/classes/logging_properties_sample diff --git a/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java b/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java index 955fd4c..4193c0d 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java +++ b/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java @@ -5,6 +5,7 @@ package org.gcube.portlets.user.td.client; import java.util.ArrayList; +import org.gcube.portlets.user.td.client.logs.TDMLogs; import org.gcube.portlets.user.td.client.template.TemplateApplyDialog; import org.gcube.portlets.user.td.client.template.TemplateDeleteDialog; import org.gcube.portlets.user.td.client.template.TemplateOpenDialog; @@ -38,6 +39,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.event.TasksMonitorEve import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.WidgetRequestEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.TaskType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.UIStateType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.WidgetRequestType; @@ -67,7 +69,6 @@ import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox; import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData; import com.sencha.gxt.widget.core.client.event.HideEvent; import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; -import com.sencha.gxt.widget.core.client.info.Info; //import org.gcube.portlets.user.tdtemplate.client.TdTemplateController; @@ -477,6 +478,9 @@ public class TabularDataController { break; case HELP: break; + case LOGS: + openLogsWindow(); + break; case RULENEW: break; case RULEMANAGE: @@ -629,6 +633,12 @@ public class TabularDataController { } } + protected void openLogsWindow(){ + Log.debug("Request Open Logs Window"); + TDMLogs tdmLogs=new TDMLogs(eventBus); + tdmLogs.show(); + } + protected void openBatchReplace(TRId trId, RequestProperties requestProperties){ Log.debug("Request Open Batch Replace Dialog: "+trId+" "+requestProperties); if (trId != null) { @@ -983,6 +993,8 @@ public class TabularDataController { TRShare trShare = new TRShare(trId, eventBus); } + + protected void callDiscard() { HistoryDiscard historyDiscard = new HistoryDiscard(eventBus); historyDiscard.discard(); @@ -1416,28 +1428,10 @@ public class TabularDataController { protected void asyncCodeLoadingFailed(Throwable reason) { Log.error("Async code loading failed", reason); - Info.display("Async code loading failed", - "Please retry to call the operation."); + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } - /** - * {@inheritDoc} - * - * @Override public HandlerRegistration addCloseHandler(CloseHandler - * handler) { //return eventBus.addHandler(CloseEvent.getType(), - * handler); } - * - * /** {@inheritDoc} - * @Override public HandlerRegistration addOpenHandler(OpenHandler - * handler) { //return eventBus.addHandler(OpenEvent.getType(), - * handler); } - */ - - /** - * {@inheritDoc} - * - * @Override public void fireEvent(GwtEvent event) { - * eventBus.fireEvent(event); } - */ - + } diff --git a/src/main/java/org/gcube/portlets/user/td/client/logs/TDMLogs.java b/src/main/java/org/gcube/portlets/user/td/client/logs/TDMLogs.java new file mode 100644 index 0000000..00fb812 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/client/logs/TDMLogs.java @@ -0,0 +1,177 @@ +package org.gcube.portlets.user.td.client.logs; + +import org.gcube.portlets.user.td.client.resource.TabularDataResources; +import org.gcube.portlets.user.td.informationwidget.client.util.UtilsGXT3; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; +import com.google.gwt.http.client.Request; +import com.google.gwt.http.client.RequestBuilder; +import com.google.gwt.http.client.RequestCallback; +import com.google.gwt.http.client.RequestException; +import com.google.gwt.http.client.Response; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.client.ui.HTML; +import com.google.web.bindery.event.shared.EventBus; +import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; +import com.sencha.gxt.core.client.util.Margins; +import com.sencha.gxt.widget.core.client.FramedPanel; +import com.sencha.gxt.widget.core.client.Window; +import com.sencha.gxt.widget.core.client.button.TextButton; +import com.sencha.gxt.widget.core.client.container.SimpleContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.event.SelectEvent; +import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; +import com.sencha.gxt.widget.core.client.toolbar.ToolBar; + +public class TDMLogs extends Window { + protected static final String TDMLogsServlet = "TDLogsServlet"; + protected static final String WIDTH="500px"; + protected static final String HEIGHT="500px"; + protected EventBus eventBus; + protected VerticalLayoutContainer verticalContainer; + + public TDMLogs(EventBus eventBus){ + super(); + this.eventBus=eventBus; + init(); + createLogsPanel(); + callLogsServlet(); + } + + public void init(){ + setWidth("640px"); + setHeight(HEIGHT); + setHeadingText("TDM Logs"); + setBodyBorder(false); + setClosable(true); + + } + + protected void createLogsPanel() { + FramedPanel logsPanel=new FramedPanel(); + logsPanel.setBodyBorder(false); + logsPanel.setHeaderVisible(false); + + ToolBar toolBar = new ToolBar(); + TextButton btnReload = new TextButton(); + // btnReload.setText("Reload"); + btnReload.addSelectHandler(new SelectHandler() { + + @Override + public void onSelect(SelectEvent event) { + callLogsServlet(); + } + }); + + btnReload.setIcon(TabularDataResources.INSTANCE.refresh()); + btnReload.setToolTip("Reload"); + toolBar.add(btnReload); + + + SimpleContainer contentLogs = new SimpleContainer(); + contentLogs.setBorders(false); + + verticalContainer = new VerticalLayoutContainer(); + verticalContainer.setScrollMode(ScrollMode.AUTO); + verticalContainer.getElement().getStyle().setBackgroundColor("white"); + + contentLogs.add(verticalContainer); + + VerticalLayoutContainer logsPanelLayout=new VerticalLayoutContainer(); + + logsPanelLayout.add(toolBar, new VerticalLayoutData(-1,-1,new Margins(1))); + logsPanelLayout.add(contentLogs, new VerticalLayoutData(-1,-1,new Margins(1))); + + logsPanel.add(logsPanelLayout); + add(logsPanel); + + } + + + + public void callLogsServlet() { + String path = GWT.getModuleBaseURL() + TDMLogsServlet; + Log.debug("TDMLogsServlet path:" + path); + RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path); + + try { + builder.sendRequest(null, new RequestCallback() { + + public void onError(Request request, Throwable exception) { + Log.error("Error retrienving logs. " + + exception.getLocalizedMessage()); + exception.printStackTrace(); + UtilsGXT3.alert("Logs", "Error retrienving logs"); + close(); + } + + public void onResponseReceived(Request request, + Response response) { + if (Response.SC_OK == response.getStatusCode()) { + update(response.getText()); + } else { + if (408 == response.getStatusCode()) { + Log.error("Error retrienving logs. Session expired."); + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error retrienving logs. Response StatusCode: " + + response.getStatusCode()); + UtilsGXT3.alert("Logs", "Error retrienving logs"); + } + close(); + } + } + }); + } catch (RequestException e) { + close(); + Log.error("Error retrienving logs. " + e.getLocalizedMessage()); + e.printStackTrace(); + UtilsGXT3.alert("Logs", "Error retrienving logs"); + + } + } + + + + protected void update(String text){ + verticalContainer.clear(); + + SafeHtmlBuilder builderLogs = new SafeHtmlBuilder(); + builderLogs.appendEscapedLines(text); + SafeHtml safeLogs = builderLogs.toSafeHtml(); + HTML hLogs = new HTML(safeLogs); + + verticalContainer.add(hLogs, new VerticalLayoutData(-1,-1,new Margins(1))); + verticalContainer.forceLayout(); + } + + + /** + * {@inheritDoc} + */ + @Override + protected void initTools() { + super.initTools(); + + closeBtn.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + close(); + } + }); + + } + + /** + * + */ + protected void close() { + hide(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/client/ribbon/FileToolBar.java b/src/main/java/org/gcube/portlets/user/td/client/ribbon/FileToolBar.java index 1248ae4..c10e22c 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/ribbon/FileToolBar.java +++ b/src/main/java/org/gcube/portlets/user/td/client/ribbon/FileToolBar.java @@ -67,6 +67,7 @@ public class FileToolBar { //protected TextButton discardAllButton; protected TextButton helpButton; + protected TextButton logsButton; public FileToolBar(EventBus eventBus) { @@ -113,25 +114,7 @@ public class FileToolBar { fileLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); - cloneButton = new TextButton("Clone", - TabularDataResources.INSTANCE.clone32()); - cloneButton.disable(); - cloneButton.setId("cloneButton"); - cloneButton.setScale(ButtonScale.LARGE); - cloneButton.setIconAlign(IconAlign.TOP); - cloneButton.setArrowAlign(ButtonArrowAlign.BOTTOM); - cloneButton.setToolTip("Clone Tabular Resource"); - - cloneButton.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - eventBus.fireEvent(new RibbonEvent(RibbonType.CLONE)); - } - }); - - fileLayout.setWidget(0, 1, cloneButton); - fileLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); - + closeButton = new TextButton("Close", TabularDataResources.INSTANCE.close32()); @@ -149,9 +132,30 @@ public class FileToolBar { } }); - fileLayout.setWidget(0, 2, closeButton); + fileLayout.setWidget(0, 1, closeButton); + fileLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); + + + cloneButton = new TextButton("Clone", + TabularDataResources.INSTANCE.clone32()); + cloneButton.disable(); + cloneButton.setId("cloneButton"); + cloneButton.setScale(ButtonScale.LARGE); + cloneButton.setIconAlign(IconAlign.TOP); + cloneButton.setArrowAlign(ButtonArrowAlign.BOTTOM); + cloneButton.setToolTip("Clone Tabular Resource"); + + cloneButton.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + eventBus.fireEvent(new RibbonEvent(RibbonType.CLONE)); + } + }); + + fileLayout.setWidget(0, 2, cloneButton); fileLayout.getFlexCellFormatter().setRowSpan(0, 2, 2); + deleteButton = new TextButton("Delete", TabularDataResources.INSTANCE.delete()); deleteButton.disable(); @@ -496,6 +500,26 @@ public class FileToolBar { helpLayout.setWidget(0, 0, helpButton); helpLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); + + + logsButton = new TextButton("Logs", + TabularDataResources.INSTANCE.help32()); + logsButton.enable(); + logsButton.setToolTip("Show Logs"); + logsButton.setScale(ButtonScale.LARGE); + logsButton.setIconAlign(IconAlign.TOP); + logsButton.setArrowAlign(ButtonArrowAlign.BOTTOM); + logsButton.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + eventBus.fireEvent(new RibbonEvent(RibbonType.LOGS)); + } + }); + + helpLayout.setWidget(0, 1, logsButton); + helpLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); + + cleanCells(helpLayout.getElement()); eventBus.addHandler(UIStateEvent.TYPE, diff --git a/src/main/webapp/WEB-INF/classes/log4j_properties_sample b/src/main/webapp/WEB-INF/classes/log4j_properties_sample new file mode 100644 index 0000000..6ccc40a --- /dev/null +++ b/src/main/webapp/WEB-INF/classes/log4j_properties_sample @@ -0,0 +1,19 @@ +log4j.rootCategory=TRACE, FILE, CONSOLE + +# Direct log messages to a log file +log4j.appender.FILE=org.apache.log4j.RollingFileAppender +#Redirect to Tomcat logs folder +#log4j.appender.FILE.File=C:\\logging.log +log4j.appender.FILE.File=${catalina.home}/webapps/tabular-data-portlet/logs/TabularDataManagerLog4j.log +log4j.appender.FILE.MaxFileSize=10MB +log4j.appender.FILE.MaxBackupIndex=10 +log4j.appender.FILE.layout=org.apache.log4j.PatternLayout +log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n + +# Console log +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Target=System.out +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/classes/logback.xml b/src/main/webapp/WEB-INF/classes/logback.xml new file mode 100644 index 0000000..fbf6a3c --- /dev/null +++ b/src/main/webapp/WEB-INF/classes/logback.xml @@ -0,0 +1,36 @@ + + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + ${CATALINA_HOME}/webapps/tabular-data-portlet/logs/TabularDataManagerLogBack.log + + + TabularData.%d{yyyy-MM-dd}.log + + + 30 + + + + %d [%thread] %-5level %logger{35} - %msg%n + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/classes/logging_properties_sample b/src/main/webapp/WEB-INF/classes/logging_properties_sample new file mode 100644 index 0000000..13acde2 --- /dev/null +++ b/src/main/webapp/WEB-INF/classes/logging_properties_sample @@ -0,0 +1 @@ +debug.com.sun.portal.level=WARNING \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index f297afd..484d914 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -4,7 +4,7 @@ "http://java.sun.com/dtd/web-app_2_3.dtd"> - + tdservlet @@ -28,43 +28,43 @@ TDGWTService org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl - + ExpressionService org.gcube.portlets.user.td.expressionwidget.server.ExpressionServiceImpl - + CExpressionMapServlet org.gcube.portlets.user.td.expressionwidget.server.CExpressionMapServlet - + workspacesharing org.gcube.portlets.widgets.workspacesharingwidget.server.WorkspaceSharingServiceImpl - - + + tabularDataTasksWidgetService org.gcube.portlets.user.td.taskswidget.server.TdTasksWidgetServiceImpl - + tdTemplateServiceImpl org.gcube.portlets.user.tdtemplate.server.TdTemplateServiceImpl - + - + TdColumnOperationServlet org.gcube.portlets.user.tdcolumnoperation.server.TdColumnOperationServiceImpl - + @@ -82,7 +82,7 @@ CodelistMappingUploadServlet org.gcube.portlets.user.td.gwtservice.server.CodelistMappingUploadServlet - + WorkspaceLightService @@ -91,33 +91,13 @@ - + jUnitHostImpl @@ -129,7 +109,17 @@ checkServlet org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl - + + + + TDLogsServlet + org.gcube.portlets.user.td.gwtservice.server.TDLogsServlet + + + + + + tdservlet @@ -153,7 +143,7 @@ TDGWTService /tabulardataportlet/TDGWTService - + ExpressionService @@ -163,26 +153,26 @@ CExpressionMapServlet /tabulardataportlet/CExpressionMap - + workspacesharing /tabulardataportlet/workspacesharing - - - + + + tabularDataTasksWidgetService /tabulardataportlet/tabularDataTasksService - + tdTemplateServiceImpl /tabulardataportlet/tdtemplate - + TdColumnOperationServlet @@ -199,14 +189,14 @@ LocalUploadServlet /tabulardataportlet/LocalUploadServlet - + CodelistMappingUploadServlet /tabulardataportlet/CodelistMappingUploadServlet - - + + WorkspaceLightService @@ -214,46 +204,39 @@ - - - downloadServlet - /tabulardataportlet/DownloadService - - - gWTWorkspaceServiceImpl - /tabulardataportlet/WorkspaceService - - - - imageServlet - /tabulardataportlet/ImageService - - - - uploadServlet - /tabulardataportlet/UploadService - - - --> - - checkServlet /tabulardataportlet/checksession + + + + TDLogsServlet + /tabulardataportlet/TDLogsServlet + - + + jUnitHostImpl /tabulardataportlet/junithost/* - + + + + tabulardataportlet.html