/** * Returns the mime type that should be exposed to the client when sending the exception * message. * * <p>Defaults to <code>geoserver.getMimeType()</code> */ public String getMimeType(GeoServer geoserver) { return "text/xml; charset=" + geoserver.getSettings().getCharset(); } }
private boolean useNameDequalifyingProxy() { WorkspaceInfo workspaceInfo = LocalWorkspace.get(); if (workspaceInfo == null) { return false; } return geoServer == null || !geoServer.getSettings().isLocalWorkspaceIncludesPrefix(); }
String url = geoserver.getSettings().getProxyBaseUrl();
String url = ((geoserver != null) ? geoserver.getSettings().getProxyBaseUrl() : null);
void createAppContext(String proxyBaseUrl) { SettingsInfo settings = createNiceMock(SettingsInfo.class); expect(settings.getProxyBaseUrl()).andReturn(proxyBaseUrl).anyTimes(); replay(settings); GeoServer geoServer = createNiceMock(GeoServer.class); expect(geoServer.getGlobal()).andReturn(new GeoServerInfoImpl()); expect(geoServer.getSettings()).andReturn(settings).anyTimes(); replay(geoServer); ProxifyingURLMangler mangler = new ProxifyingURLMangler(geoServer); ApplicationContext appContext = createNiceMock(ApplicationContext.class); expect(appContext.getBeanNamesForType(URLMangler.class)) .andReturn(new String[] {"mangler"}); expect(appContext.getBean("mangler")).andReturn(mangler).anyTimes(); replay(appContext); GeoServerExtensionsHelper.init(appContext); }
public void mangleURL( StringBuilder baseURL, StringBuilder path, Map<String, String> kvp, URLType type) { // first check the system property, then fall back to configuration String proxyBase = (GeoServerExtensions.getProperty(Requests.PROXY_PARAM) != null) ? GeoServerExtensions.getProperty(Requests.PROXY_PARAM) : this.geoServer.getSettings().getProxyBaseUrl(); // Mangles the URL base in different ways based on a flag // (for two reasons: a) speed; b) to make the admin aware of // possible security liabilities) baseURL = (this.geoServer.getGlobal().isUseHeadersProxyURL() == true && proxyBase != null) ? this.mangleURLHeaders(baseURL, proxyBase) : this.mangleURLFixedURL(baseURL, proxyBase); }
private void assertPrefixInclusion( boolean includePrefix, boolean setLocalWorkspace, boolean createGeoServer) { if (createGeoServer) { SettingsInfo settings = createNiceMock(SettingsInfo.class); expect(settings.isLocalWorkspaceIncludesPrefix()).andReturn(includePrefix).anyTimes(); replay(settings); GeoServer geoServer = createNiceMock(GeoServer.class); expect(geoServer.getSettings()).andReturn(settings).anyTimes(); replay(geoServer); catalog.setGeoServer(geoServer); } if (setLocalWorkspace) { WorkspaceInfo workspaceByName = catalog.getWorkspaceByName("ws1"); LocalWorkspace.set(workspaceByName); } checkLayerNamePrefixInclusion(includePrefix, catalog.getLayers().iterator()); checkLayerNamePrefixInclusion(includePrefix, catalog.list(LayerInfo.class, Filter.INCLUDE)); }
replay(settings); expect(geoServer.getSettings()).andReturn(settings).anyTimes(); replay(geoServer);
@Test public void testModifySettings() throws Exception { testAddSettings(); WorkspaceInfo ws = catalog.getWorkspaceByName("acme"); SettingsInfo settings = getGeoServer().getSettings(ws); settings.setTitle("FOO"); getGeoServer().save(settings); File f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml"); assertNotNull(f); Document dom = dom(f); assertXpathEvaluatesTo("FOO", "/settings/title", dom); }
@Test public void testRemoveSettings() throws Exception { testAddSettings(); WorkspaceInfo ws = catalog.getWorkspaceByName("acme"); File f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml"); assertNotNull(f); SettingsInfo settings = getGeoServer().getSettings(ws); getGeoServer().remove(settings); f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml"); assertNull(f); }
@Test public void testModifySettingsChangeWorkspace() throws Exception { testAddSettings(); WorkspaceInfo ws1 = catalog.getWorkspaceByName("acme"); WorkspaceInfo ws2 = catalog.getFactory().createWorkspace(); ws2.setName("foo"); catalog.add(ws2); SettingsInfo settings = getGeoServer().getSettings(ws1); settings.setWorkspace(ws2); getGeoServer().save(settings); File f = catalog.getResourceLoader().find("workspaces", ws1.getName(), "settings.xml"); assertNull(f); f = catalog.getResourceLoader().find("workspaces", ws2.getName(), "settings.xml"); assertNotNull(f); Document dom = dom(f); assertXpathEvaluatesTo(ws2.getId(), "/settings/workspace/id", dom); }
SettingsInfo settings = ws != null ? geoServer.getSettings(ws) : global.getSettings(); if (settings == null) { settings = geoServer.getFactory().createSettings();
private boolean allowExisting() { String workspace = getAttribute("workspace"); WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName(workspace); if (ws != null) { return geoServer.getSettings(ws) != null; } return geoServer.getSettings(ws) == null; }
@Override protected SettingsInfo load() { GeoServer gs = GeoServerApplication.get().getGeoServer(); return gs.getSettings(wsModel.getObject()); } }
public Charset getCharSet() { GeoServer geoServer2 = getGeoServer(); String charset = geoServer2.getSettings().getCharset(); return Charset.forName(charset); }
@DeleteMapping public void localSetingsDelete(@PathVariable String workspaceName) { if (workspaceName != null) { WorkspaceInfo workspaceInfo = geoServer.getCatalog().getWorkspaceByName(workspaceName); SettingsInfo settingsInfo = geoServer.getSettings(workspaceInfo); geoServer.remove(settingsInfo); } }
@Override public String getCharset() { return wms.getGeoServer().getSettings().getCharset(); } }
@Override public void handleObjectDelete() throws Exception { String workspace = getAttribute("workspace"); if (workspace != null) { WorkspaceInfo workspaceInfo = geoServer.getCatalog().getWorkspaceByName(workspace); SettingsInfo settingsInfo = geoServer.getSettings(workspaceInfo); geoServer.remove(settingsInfo); } }
void write1_1(LockFeatureResponseType lockResponse, OutputStream output, Operation operation) throws IOException { Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); LockFeatureType req = (LockFeatureType) operation.getParameters()[0]; encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, buildSchemaURL(req.getBaseUrl(), "schemas/wfs/1.1.0/wfs.xsd")); encoder.encode(lockResponse, org.geoserver.wfs.xml.v1_1_0.WFS.LOCKFEATURERESPONSE, output); output.flush(); } }
protected void doWrite( FeatureTypeInfo[] featureTypeInfos, OutputStream output, Operation describeFeatureType) throws IOException { // create the schema Object request = describeFeatureType.getParameters()[0]; DescribeFeatureTypeRequest req = DescribeFeatureTypeRequest.adapt(request); XSDSchema schema = schemaBuilder.build(featureTypeInfos, req.getBaseURL()); // serialize schema.updateElement(); final String encoding = gs.getSettings().getCharset(); XSDResourceImpl.serialize(output, schema.getElement(), encoding); }