Skip to content

Commit

Permalink
GSIP 67 - workspace local settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeolive committed Dec 21, 2011
1 parent 4bd35f0 commit 6d9fce0
Show file tree
Hide file tree
Showing 78 changed files with 1,578 additions and 388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.geoserver.config.GeoServerInfo;
import org.geoserver.config.LoggingInfo;
import org.geoserver.config.ServiceInfo;
import org.geoserver.config.SettingsInfo;
import org.geoserver.hibernate.AbstractHibFacade;
import org.geoserver.ows.util.OwsUtils;
import org.hibernate.Query;
Expand Down Expand Up @@ -42,6 +43,25 @@ public void save(GeoServerInfo geoServer) {
merge(geoServer);
}

//
// settings
//
public SettingsInfo getSettings(WorkspaceInfo workspace) {
throw new UnsupportedOperationException("not implemnted");
}

public void add(SettingsInfo settings) {
throw new UnsupportedOperationException("not implemnted");
}

public void save(SettingsInfo settings) {
throw new UnsupportedOperationException("not implemnted");
}

public void remove(SettingsInfo settings) {
throw new UnsupportedOperationException("not implemnted");
}

//
// logging
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public VersionedGML2OutputFormat(GeoServer geoServer) {
super(geoServer);
}

protected String wfsSchemaLocation(GeoServerInfo global, String baseUrl) {
protected String wfsSchemaLocation(String baseUrl) {
return ResponseUtils.buildSchemaURL(baseUrl, "/wfs/1.0.0/WFS-versioning.xsd");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@
*/
public abstract class AbstractTransactionOutputFormat extends Response {
/**
* WFS configuration
* configuration
*/
WFSInfo wfs;
Catalog catalog;
GeoServerInfo global;
GeoServer geoServer;

/**
* Xml configuration
Expand All @@ -76,10 +74,8 @@ public AbstractTransactionOutputFormat(GeoServer gs, Configuration configuration
FilterFactory filterFactory, QName element, String mime) {
super(FeatureDiffReader[].class);

this.wfs = gs.getService( WFSInfo.class );
this.global = gs.getGlobal();
this.geoServer = gs;
this.configuration = configuration;
this.catalog = gs.getCatalog();
this.filterFactory = filterFactory;
this.element = element;
this.mime = mime;
Expand Down Expand Up @@ -119,7 +115,7 @@ public void write(Object value, OutputStream output, Operation operation)
encodeWfsSchemaLocation(encoder, gft.getBaseUrl());

encoder.setIndenting(true);
encoder.setEncoding(Charset.forName( global.getCharset() ));
encoder.setEncoding(Charset.forName( geoServer.getSettings().getCharset() ));

// set up schema locations
// round up the info objects for each feature collection
Expand All @@ -131,7 +127,7 @@ public void write(Object value, OutputStream output, Operation operation)

// load the metadata for the feature type
String namespaceURI = featureType.getName().getNamespaceURI();
FeatureTypeInfo meta = catalog.getFeatureTypeByName( namespaceURI, featureType.getName().getLocalPart() );
FeatureTypeInfo meta = geoServer.getCatalog().getFeatureTypeByName( namespaceURI, featureType.getName().getLocalPart() );

// add it to the map
Set metas = (Set) ns2metas.get(namespaceURI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@
*/
public class VersionedGML3OutputFormat extends Response {

private WFSInfo wfs;

private GeoServer gs;
private Catalog catalog;

private WFSVConfiguration configuration;

public VersionedGML3OutputFormat(GeoServer gs,
Expand All @@ -63,7 +61,7 @@ public VersionedGML3OutputFormat(GeoServer gs,
new HashSet<String>(Arrays.asList(new String[] { "gml3",
"text/xml; subtype=gml/3.1.1" })));

this.wfs = gs.getService( WFSInfo.class );
this.gs = gs;
this.catalog = gs.getCatalog();
this.configuration = configuration;
}
Expand Down Expand Up @@ -104,9 +102,10 @@ public void write(Object value, OutputStream output, Operation getFeature)
metas.add(meta);
}

WFSInfo wfs = gs.getService(WFSInfo.class);
GeoServerInfo global = wfs.getGeoServer().getGlobal();
Encoder encoder = new Encoder(configuration, configuration.schema());
encoder.setEncoding(Charset.forName( global.getCharset() ));
encoder.setEncoding(Charset.forName( gs.getSettings().getCharset() ));

// declare wfs schema location
BaseRequestType gft = (BaseRequestType) getFeature.getParameters()[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Object read(Object request, Reader reader, Map kvp) throws Exception {

// set the input source with the correct encoding
InputSource source = new InputSource(reader);
source.setEncoding(wfs.getGeoServer().getGlobal().getCharset());
source.setEncoding(wfs.getGeoServer().getSettings().getCharset());

Object parsed = parser.parse(source);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Object read(Object request, Reader reader, Map kvp) throws Exception {

// set the input source with the correct encoding
InputSource source = new InputSource(reader);
source.setEncoding(wfs.getGeoServer().getGlobal().getCharset());
source.setEncoding(wfs.getGeoServer().getSettings().getCharset());

Object parsed = parser.parse(source);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ public void encode(Object o) throws IllegalArgumentException {
element("name", title);
element("visibility", "1");
element("open", "1");
GeoServerInfo geoServerInfo = wms.getGeoServer().getGlobal();
element("atom:author", geoServerInfo.getContact().getContactPerson());

element("atom:author", wms.getGeoServer().getSettings().getContact().getContactPerson());

AttributesImpl href = new AttributesImpl();
href.addAttribute("", "href", "href", "", wms.getGeoServer().getGlobal()
href.addAttribute("", "href", "href", "", wms.getGeoServer().getSettings()
.getOnlineResource());
element("atom:link", null, href);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.eclipse.emf.common.util.ECollections;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.config.SettingsInfo;
import org.geoserver.ows.Ows11Util;
import org.geoserver.ows.util.RequestUtils;
import org.geoserver.wps.ppio.ProcessParameterIO;
Expand Down Expand Up @@ -109,16 +110,16 @@ public WPSCapabilitiesType run(GetCapabilitiesType request) throws WPSException
caps.setServiceProvider(sp);

// TODO: set provder name from context
GeoServerInfo geoServer = wps.getGeoServer().getGlobal();
if (geoServer.getContact().getContactOrganization() != null) {
sp.setProviderName(geoServer.getContact().getContactOrganization());
SettingsInfo settings = wps.getGeoServer().getSettings();
if (settings.getContact().getContactOrganization() != null) {
sp.setProviderName(settings.getContact().getContactOrganization());
} else {
sp.setProviderName("GeoServer");
}

sp.setProviderSite(owsf.createOnlineResourceType());
sp.getProviderSite().setHref(geoServer.getOnlineResource());
sp.setServiceContact(responsibleParty(geoServer, owsf));
sp.getProviderSite().setHref(settings.getOnlineResource());
sp.setServiceContact(responsibleParty(settings, owsf));

// OperationsMetadata
OperationsMetadataType om = owsf.createOperationsMetadataType();
Expand Down Expand Up @@ -241,7 +242,7 @@ Set<Name> getProcessBlacklist() {
return PROCESS_BLACKLIST;
}

ResponsiblePartySubsetType responsibleParty(GeoServerInfo global, Ows11Factory f) {
ResponsiblePartySubsetType responsibleParty(SettingsInfo settings, Ows11Factory f) {
ResponsiblePartySubsetType rp = f.createResponsiblePartySubsetType();
return rp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,38 @@ public interface ConfigurationListener {
*/
void handlePostGlobalChange( GeoServerInfo global );

/**
* Handles the event fired when a settings configuration is added.
*
* @param settings The settings.
*/
void handleSettingsAdded(SettingsInfo settings);

/**
* Handles the event fired when a settings configuration is changed.
*
* @param settings The settings.
* @param propertyNames The names of the properties that were changed.
* @param oldValue The old values for the properties that were changed.
* @param newValue The new values for the properties that were changed.
*/
void handleSettingsModified(SettingsInfo settings, List<String> propertyNames,
List<Object> oldValues, List<Object> newValues);

/**
* Handles the event fired post change to a settings configuration.
*
* @param settings The settings.
*/
void handleSettingsPostModified(SettingsInfo settings);

/**
* Handles the event fired when a settings configuration is removed.
*
* @param settings The settings.
*/
void handleSettingsRemoved(SettingsInfo settings);

/**
* Handles a change to the logging configuration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ public void handleGlobalChange(GeoServerInfo global, List<String> propertyNames,
public void handlePostGlobalChange(GeoServerInfo global) {
}

public void handleSettingsAdded(SettingsInfo settings) {
}

public void handleSettingsModified(SettingsInfo settings, List<String> propertyNames,
List<Object> oldValues, List<Object> newValues) {
}

public void handleSettingsPostModified(SettingsInfo settings) {
}

public void handleSettingsRemoved(SettingsInfo settings) {
}

public void handleLoggingChange(LoggingInfo logging, List<String> propertyNames,
List<Object> oldValues, List<Object> newValues) {
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/src/main/java/org/geoserver/config/ContactInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
*/
package org.geoserver.config;

import org.geoserver.catalog.Info;

/**
* GeoServer contact information.
*
* @author Justin Deoliveira, The Open Planning Project
*
*/
public interface ContactInfo {
public interface ContactInfo extends Info {

/**
* Identifier.
Expand Down
44 changes: 42 additions & 2 deletions src/main/src/main/java/org/geoserver/config/GeoServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,38 @@ public interface GeoServer {
* Sets the global configuration.
*/
void setGlobal( GeoServerInfo global );


/**
* Returns the global settings configuration.
* <p>
* This method will return {@link GeoServerInfo#getSettings()} unless a local workspace is
* set. In that case the settings for that workspace will be checked via
* {@link #getSettings(WorkspaceInfo)}, and if one exists will be returned. If local workspace
* settings do not exist the global settings ({@link GeoServerInfo#getSettings()}) are returned.
* </p>
*/
SettingsInfo getSettings();

/**
* The settings configuration for the specified workspoace, or <code>null</code> if non exists.
*/
SettingsInfo getSettings(WorkspaceInfo workspace);

/**
* Adds a settings configuration for the specified workspace.
*/
void add(SettingsInfo settings);

/**
* Saves the settings configuration for the specified workspace.
*/
void save(SettingsInfo settings);

/**
* Removes the settings configuration for the specified workspace.
*/
void remove(SettingsInfo settings);

/**
* The logging configuration.
*/
Expand Down Expand Up @@ -216,7 +247,16 @@ public interface GeoServer {
* </p>
*/
void fireGlobalModified(GeoServerInfo global, List<String> propertyNames, List oldValues, List newValues);


/**
* Fires the event for a settings configuration being modified.
* <p>
* This method should not be called by client code. It is meant to be called
* internally by the configuration subsystem.
* </p>
*/
void fireSettingsModified(SettingsInfo global, List<String> propertyNames, List oldValues, List newValues);

/**
* Fires the event for the logging configuration being modified.
* <p>
Expand Down
20 changes: 20 additions & 0 deletions src/main/src/main/java/org/geoserver/config/GeoServerFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ public interface GeoServerFacade {
*/
void save(GeoServerInfo geoServer);

/**
* The settings configuration for the specified workspoace, or <code>null</code> if non exists.
*/
SettingsInfo getSettings(WorkspaceInfo workspace);

/**
* Adds a settings configuration for the specified workspace.
*/
void add(SettingsInfo settings);

/**
* Saves the settings configuration for the specified workspace.
*/
void save(SettingsInfo settings);

/**
* Removes the settings configuration for the specified workspace.
*/
void remove(SettingsInfo settings);

/**
* The logging configuration.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public interface GeoServerFactory {
*/
GeoServerInfo createGlobal();

/**
* Creates a new settings.
*/
SettingsInfo createSettings();

/**
* Creates a new contact.
*/
Expand Down
Loading

0 comments on commit 6d9fce0

Please sign in to comment.