Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements of the gui #193

Merged
merged 26 commits into from Dec 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cedccfd
Fixed create new coverage data store functionality in gui
dstenger Nov 23, 2013
3f6b21c
Fixed error messages on workspace startup failure and add utility cla…
MrSnyder Nov 23, 2013
e3c339d
Fixed NPE
MrSnyder Nov 23, 2013
1b13b1d
Log JSF errors as well
MrSnyder Nov 23, 2013
39dbd64
Fixed bug preventing to create new feature stores via gui
dstenger Nov 23, 2013
8defd27
Also log errors for workspace resources that are not initialized due …
MrSnyder Nov 23, 2013
bd2d17e
Improve error messages
MrSnyder Nov 23, 2013
8776d55
Merge remote-tracking branch 'fossgis-hacking/3.4-improvementsGui' in…
MrSnyder Nov 23, 2013
ea3ce7c
Addded hasErrors to menuitem tag
MrSnyder Nov 23, 2013
6fc0d91
Implemented configuration error check in AbstractResourceManagerBean
dstenger Nov 23, 2013
c5ec4bb
Merge branch '3.4-improvementsGui' of https://github.com/FOSSGIS-Hack…
dstenger Nov 23, 2013
9f018e7
Added configuration error checks to the main menu
dstenger Nov 23, 2013
aa916e9
Fixed resource deletion in console
MrSnyder Nov 23, 2013
c5d6da0
Merge remote-tracking branch 'fossgis-hacking/3.4-improvementsGui' in…
MrSnyder Nov 23, 2013
3c1fadb
Fixed issue when creating new resources in console
MrSnyder Nov 23, 2013
57bbe09
Fixed ConcurrentModificationException
MrSnyder Nov 23, 2013
5578595
Implemented creation of new workspaces in gui
dstenger Nov 24, 2013
6d1efa6
Improved layout of workspace page in gui
dstenger Nov 24, 2013
0dd5fad
Improved messages in console
MrSnyder Nov 24, 2013
8aa0eb4
Fixed resource creation when directory does not exist
MrSnyder Nov 24, 2013
c0d6049
Fixed creation of coverage datastore configuration files in gui
dstenger Nov 24, 2013
0f065ee
Merge branch '3.4-improvementsGui' of https://github.com/FOSSGIS-Hack…
dstenger Nov 24, 2013
8ba2796
Fixed issues with management of JDBC resources
MrSnyder Nov 24, 2013
5edb1f0
Merge remote-tracking branch 'fossgis-hacking/3.4-improvementsGui' in…
MrSnyder Nov 24, 2013
eb4b9af
Bumped Primefaces to 4.0
MrSnyder Nov 24, 2013
09c9a5c
Fixed some JSF bean deserializations
MrSnyder Nov 24, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deegree-client/deegree-jsf-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
<version>4.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@
----------------------------------------------------------------------------*/
package org.deegree.console;

import static javax.faces.application.FacesMessage.SEVERITY_ERROR;
import static org.deegree.console.JsfUtils.getWorkspace;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AjaxBehaviorEvent;

import org.apache.commons.io.IOUtils;
import org.deegree.console.metadata.ResourceManagerMetadata;
import org.deegree.console.metadata.ResourceProviderMetadata;
import org.deegree.services.controller.OGCFrontController;
import org.deegree.workspace.ResourceLocation;
import org.deegree.workspace.ResourceManager;
import org.deegree.workspace.ResourceMetadata;
import org.deegree.workspace.ResourceProvider;
import org.deegree.workspace.Workspace;
import org.deegree.workspace.standard.DefaultResourceIdentifier;
import org.deegree.workspace.standard.IncorporealResourceLocation;
import org.deegree.workspace.standard.DefaultResourceLocation;
import org.deegree.workspace.standard.DefaultWorkspace;

/**
* JSF backing bean for views of type "Create new XYZ resource".
*
* @author <a href="mailto:schneider@occamlabs.de">Markus Schneider</a>
*
* @since 3.3
* @since 3.4
*/
@ManagedBean
@ViewScoped
Expand All @@ -70,14 +70,19 @@ public abstract class AbstractCreateResourceBean {

private List<String> configTemplates;

private final transient ResourceManagerMetadata metadata;
private transient ResourceManagerMetadata metadata;

private Workspace workspace;
private File resourceDir;

public AbstractCreateResourceBean( Class<? extends ResourceManager<?>> resourceMgrClass ) {
workspace = OGCFrontController.getServiceWorkspace().getNewWorkspace();
ResourceManager<?> mgr = (ResourceManager<?>) workspace.getResourceManager( resourceMgrClass );
metadata = ResourceManagerMetadata.getMetadata( mgr, workspace );
protected AbstractCreateResourceBean() {
// required by JSF
}

protected AbstractCreateResourceBean( Class<? extends ResourceManager<?>> resourceMgrClass ) {
ResourceManager<?> mgr = getWorkspace().getResourceManager( resourceMgrClass );
metadata = ResourceManagerMetadata.getMetadata( mgr, getWorkspace() );
File wsDir = ( (DefaultWorkspace) getWorkspace() ).getLocation();
resourceDir = new File( wsDir, mgr.getMetadata().getWorkspacePath() );
if ( !getTypes().isEmpty() ) {
type = getTypes().get( 0 );
changeType( null );
Expand Down Expand Up @@ -132,16 +137,21 @@ public String create() {
try {
Class<?> pcls = metadata.getManager().getMetadata().getProviderClass();
DefaultResourceIdentifier<?> ident = new DefaultResourceIdentifier( pcls, id );
ResourceLocation<?> loc = new IncorporealResourceLocation( IOUtils.toByteArray( templateURL ), ident );
workspace.add( loc );
ResourceMetadata<?> rmd = workspace.getResourceMetadata( ident.getProvider(), ident.getId() );
if ( !resourceDir.mkdirs() ) {
throw new IOException( "Could not create resource directory '" + resourceDir + "'" );
}
File resourceFile = new File( resourceDir, id + ".xml" );
FileOutputStream os = new FileOutputStream( resourceFile );
IOUtils.copy( templateURL.openStream(), os );
os.close();
ResourceLocation<?> loc = new DefaultResourceLocation( resourceFile, ident );
getWorkspace().add( loc );
ResourceMetadata<?> rmd = getWorkspace().getResourceMetadata( ident.getProvider(), ident.getId() );
Config c = new Config( rmd, metadata.getManager(), getOutcome(), true );
c.setTemplate( templateURL );
return c.edit();
} catch ( Exception t ) {
t.printStackTrace();
FacesMessage fm = new FacesMessage( SEVERITY_ERROR, "Unable to create config: " + t.getMessage(), null );
FacesContext.getCurrentInstance().addMessage( null, fm );
JsfUtils.indicateException( "Creating resource", t );
}
return getOutcome();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
----------------------------------------------------------------------------*/
package org.deegree.console;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.deegree.console.datastore.feature.FeatureStoreConfig;
import org.deegree.console.metadata.ResourceManagerMetadata;
import org.deegree.console.metadata.ResourceProviderMetadata;
import org.deegree.services.controller.OGCFrontController;
Expand All @@ -55,7 +57,9 @@
*
* @version $Revision: $, $Date: $
*/
public abstract class AbstractResourceManagerBean<T extends ResourceManager<?>> {
public abstract class AbstractResourceManagerBean<T extends ResourceManager<?>> implements Serializable {

private static final long serialVersionUID = -7795125766411006135L;

private String newConfigType;

Expand All @@ -65,11 +69,15 @@ public abstract class AbstractResourceManagerBean<T extends ResourceManager<?>>

private String newConfigId;

protected final ResourceManager<?> resourceManager;
private transient ResourceManagerMetadata metadata;

protected transient ResourceManager<?> resourceManager;

private final ResourceManagerMetadata metadata;
private transient Workspace workspace;

private Workspace workspace;
protected AbstractResourceManagerBean() {
// default constructor required
}

protected AbstractResourceManagerBean( Class<T> mgrClass ) {
workspace = OGCFrontController.getServiceWorkspace().getNewWorkspace();
Expand Down Expand Up @@ -132,4 +140,15 @@ public String getStartView() {
return null;
}

public boolean getHasErrors() {
for ( ResourceMetadata<?> md : resourceManager.getResourceMetadata() ) {
FeatureStoreConfig config = new FeatureStoreConfig( md, resourceManager );
String state = config.getState();
if ( "Error".equals( state ) ) {
return true;
}
}
return false;
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//$HeadURL$
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
This file is part of deegree
Copyright (C) 2001-2013 by:
- Department of Geography, University of Bonn -
and
- lat/lon GmbH -
and
- Occam Labs UG (haftungsbeschränkt) -
and others

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Expand All @@ -20,25 +22,17 @@

Contact information:

lat/lon GmbH
Aennchenstr. 19, 53177 Bonn
Germany
http://lat-lon.de/

Department of Geography, University of Bonn
Prof. Dr. Klaus Greve
Postfach 1147, 53001 Bonn
Germany
http://www.geographie.uni-bonn.de/deegree/

e-mail: info@deegree.org
----------------------------------------------------------------------------*/
website: http://www.deegree.org/
----------------------------------------------------------------------------*/
package org.deegree.console;

import static javax.faces.application.FacesMessage.SEVERITY_ERROR;
import static org.deegree.console.JsfUtils.getWorkspace;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -47,26 +41,24 @@
import javax.faces.context.FacesContext;

import org.apache.commons.io.IOUtils;
import org.deegree.services.controller.OGCFrontController;
import org.deegree.workspace.Resource;
import org.deegree.workspace.ResourceManager;
import org.deegree.workspace.ResourceMetadata;
import org.deegree.workspace.ResourceStates.ResourceState;
import org.deegree.workspace.Workspace;
import org.deegree.workspace.WorkspaceUtils;
import org.deegree.workspace.standard.AbstractResourceProvider;
import org.slf4j.Logger;

/**
* Wraps information on a {@link Resource} and its configuration file.
* JSF bean that wraps a {@link ResourceMetadata} and actions.
*
* @author <a href="mailto:schneider@lat-lon.de">Markus Schneider</a>
* @author <a href="mailto:schneider@occamlabs.de">Markus Schneider</a>
* @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
* @author last edited by: $Author$
*
* @version $Revision$, $Date$
* @since 3.4
*/
public class Config implements Comparable<Config> {
public class Config implements Comparable<Config>, Serializable {

private static final long serialVersionUID = -175529275940063759L;

private static final Logger LOG = getLogger( Config.class );

Expand All @@ -80,13 +72,14 @@ public class Config implements Comparable<Config> {

private String resourceOutcome;

private ResourceMetadata<?> metadata;
private transient ResourceMetadata<?> metadata;

protected Workspace workspace;
public Config() {
// constructor required by JSF
}

public Config( ResourceMetadata<?> metadata, ResourceManager<?> resourceManager, String resourceOutcome,
boolean autoActivate ) {
workspace = OGCFrontController.getServiceWorkspace().getNewWorkspace();
if ( metadata != null ) {
this.id = metadata.getIdentifier().getId();
}
Expand All @@ -107,9 +100,9 @@ public Config( ResourceMetadata<?> metadata, ResourceManager<?> resourceManager,

public void activate() {
try {
workspace.getLocationHandler().activate( metadata.getLocation() );
workspace.add( metadata.getLocation() );
WorkspaceUtils.reinitializeChain( workspace, metadata.getIdentifier() );
getWorkspace().getLocationHandler().activate( metadata.getLocation() );
getWorkspace().add( metadata.getLocation() );
WorkspaceUtils.reinitializeChain( getWorkspace(), metadata.getIdentifier() );
} catch ( Exception t ) {
t.printStackTrace();
FacesMessage fm = new FacesMessage( SEVERITY_ERROR, "Unable to activate resource: " + t.getMessage(), null );
Expand All @@ -120,12 +113,12 @@ public void activate() {

public void deactivate() {
try {
workspace.destroy( metadata.getIdentifier() );
workspace.getLocationHandler().deactivate( metadata.getLocation() );
getWorkspace().destroy( metadata.getIdentifier() );
getWorkspace().getLocationHandler().deactivate( metadata.getLocation() );
List<ResourceMetadata<?>> list = new ArrayList<ResourceMetadata<?>>();
WorkspaceUtils.collectDependents( list, workspace.getDependencyGraph().getNode( metadata.getIdentifier() ) );
WorkspaceUtils.collectDependents( list, getWorkspace().getDependencyGraph().getNode( metadata.getIdentifier() ) );
for ( ResourceMetadata<?> md : list ) {
workspace.getLocationHandler().deactivate( md.getLocation() );
getWorkspace().getLocationHandler().deactivate( md.getLocation() );
}
} catch ( Throwable t ) {
FacesMessage fm = new FacesMessage( SEVERITY_ERROR, "Unable to deactivate resource: " + t.getMessage(),
Expand All @@ -147,27 +140,28 @@ public String edit()

public void delete() {
try {
workspace.getLocationHandler().delete( metadata.getLocation() );
getWorkspace().getLocationHandler().delete( metadata.getLocation() );
} catch ( Throwable t ) {
FacesMessage fm = new FacesMessage( SEVERITY_ERROR, "Unable to deactivate resource: " + t.getMessage(),
null );
FacesContext.getCurrentInstance().addMessage( null, fm );
JsfUtils.indicateException( "Deleting resource file", t );
return;
}
try {
getWorkspace().destroy( metadata.getIdentifier() );
} catch ( Throwable t ) {
JsfUtils.indicateException( "Destroying resource", t );
}
}

public void showErrors() {
String msg = "Initialization of resource with id '" + id + "' failed:";

for ( String error : workspace.getErrorHandler().getErrors( metadata.getIdentifier() ) ) {
String msg = "Initialization of resource '" + id + "' failed: ";
for ( String error : getWorkspace().getErrorHandler().getErrors( metadata.getIdentifier() ) ) {
msg += error;
}

msg += " (The application server log may contain additional information.)";

FacesMessage fm = new FacesMessage( SEVERITY_ERROR, msg, null );
FacesContext.getCurrentInstance().addMessage( null, fm );
}

@Override
public int compareTo( Config o ) {
return id.compareTo( o.id );
}
Expand Down Expand Up @@ -213,7 +207,7 @@ public void setSchemaURL( URL schemaURL ) {
}

public String getState() {
ResourceState state = workspace.getStates().getState( metadata.getIdentifier() );
ResourceState state = getWorkspace().getStates().getState( metadata.getIdentifier() );
return state == null ? "Deactivated" : state.toString();
}

Expand Down
Loading