Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@99222 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-08-05 16:33:49 +00:00
parent e0f9c3e007
commit 8bb9c9ad6f
7 changed files with 354 additions and 120 deletions

View File

@ -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.");
}
/**
* {@inheritDoc}
*
* @Override public HandlerRegistration addCloseHandler(CloseHandler<Long>
* handler) { //return eventBus.addHandler(CloseEvent.getType(),
* handler); }
*
* /** {@inheritDoc}
* @Override public HandlerRegistration addOpenHandler(OpenHandler<Long>
* handler) { //return eventBus.addHandler(OpenEvent.getType(),
* handler); }
*/
/**
* {@inheritDoc}
*
* @Override public void fireEvent(GwtEvent<?> event) {
* eventBus.fireEvent(event); }
*/
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
}
}

View File

@ -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();
}
}

View File

@ -67,6 +67,7 @@ public class FileToolBar {
//protected TextButton discardAllButton;
protected TextButton helpButton;
protected TextButton logsButton;
public FileToolBar(EventBus eventBus) {
@ -113,24 +114,6 @@ 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",
@ -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,

View File

@ -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

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Insert the current time formatted as "yyyyMMdd'T'HHmmss" under the
key "bySecond" into the logger context. This value will be available to all
subsequent configuration elements. -->
<timestamp key="byDay" datePattern="yyyyMMdd" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${CATALINA_HOME}/webapps/tabular-data-portlet/logs/TabularDataManagerLogBack.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>TabularData.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d [%thread] %-5level %logger{35} - %msg%n
</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>

View File

@ -0,0 +1 @@
debug.com.sun.portal.level=WARNING

View File

@ -91,32 +91,12 @@
<!-- CSV Import Wizard Workspace -->
<!-- <servlet>
<servlet-name>CSVImportServiceWorkspace</servlet-name>
<servlet-class>org.gcube.portlets.user.csvimportwizardgxt3.ws.server.ImportWizardWSServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>downloadServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.workspace.server.DownloadServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>gWTWorkspaceServiceImpl</servlet-name>
<!-- <servlet> <servlet-name>CSVImportServiceWorkspace</servlet-name> <servlet-class>org.gcube.portlets.user.csvimportwizardgxt3.ws.server.ImportWizardWSServiceImpl</servlet-class>
</servlet> <servlet> <servlet-name>downloadServlet</servlet-name> <servlet-class>org.gcube.portlets.user.workspace.server.DownloadServlet</servlet-class>
</servlet> <servlet> <servlet-name>gWTWorkspaceServiceImpl</servlet-name>
<servlet-class>org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>imageServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.workspace.server.ImageServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>uploadServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.workspace.server.UploadServlet</servlet-class>
</servlet> <servlet> <servlet-name>imageServlet</servlet-name> <servlet-class>org.gcube.portlets.user.workspace.server.ImageServlet</servlet-class>
</servlet> <servlet> <servlet-name>uploadServlet</servlet-name> <servlet-class>org.gcube.portlets.user.workspace.server.UploadServlet</servlet-class>
</servlet> -->
<servlet>
@ -130,6 +110,16 @@
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>
</servlet>
<!-- TD Logs -->
<servlet>
<servlet-name>TDLogsServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.td.gwtservice.server.TDLogsServlet</servlet-class>
</servlet>
<!-- Servlets Mapping -->
<servlet-mapping>
<servlet-name>tdservlet</servlet-name>
@ -214,32 +204,15 @@
</servlet-mapping>
<!-- CSV Import Wizard Workspace -->
<!-- <servlet-mapping>
<servlet-name>CSVImportServiceWorkspace</servlet-name>
<!-- <servlet-mapping> <servlet-name>CSVImportServiceWorkspace</servlet-name>
<url-pattern>/tabulardataportlet/CSVImportServiceWorkspace</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>downloadServlet</servlet-name>
<url-pattern>/tabulardataportlet/DownloadService</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>gWTWorkspaceServiceImpl</servlet-name>
<url-pattern>/tabulardataportlet/WorkspaceService</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>imageServlet</servlet-name>
<url-pattern>/tabulardataportlet/ImageService</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>uploadServlet</servlet-name>
<url-pattern>/tabulardataportlet/UploadService</url-pattern>
</servlet-mapping>
-->
</servlet-mapping> <servlet-mapping> <servlet-name>downloadServlet</servlet-name>
<url-pattern>/tabulardataportlet/DownloadService</url-pattern> </servlet-mapping>
<servlet-mapping> <servlet-name>gWTWorkspaceServiceImpl</servlet-name> <url-pattern>/tabulardataportlet/WorkspaceService</url-pattern>
</servlet-mapping> <servlet-mapping> <servlet-name>imageServlet</servlet-name>
<url-pattern>/tabulardataportlet/ImageService</url-pattern> </servlet-mapping>
<servlet-mapping> <servlet-name>uploadServlet</servlet-name> <url-pattern>/tabulardataportlet/UploadService</url-pattern>
</servlet-mapping> -->
<servlet-mapping>
@ -247,6 +220,13 @@
<url-pattern>/tabulardataportlet/checksession</url-pattern>
</servlet-mapping>
<!-- TD logs -->
<servlet-mapping>
<servlet-name>TDLogsServlet</servlet-name>
<url-pattern>/tabulardataportlet/TDLogsServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jUnitHostImpl</servlet-name>
@ -254,6 +234,9 @@
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>tabulardataportlet.html</welcome-file>