Refine search
/** * Locate the specified grid file. * * <p>It will look in GEOSERVER_DATA_DIR/user_projections * * @param grid the grid name/location * @return the fully resolved URL of the grid or null, if the resource cannot be located. */ @Override public URL locateGrid(String grid) { if (grid == null) return null; GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); if (loader == null) { return null; // must be test case still loading } Resource gridfile = loader.get("user_projections/" + grid); if (gridfile.getType() == Type.RESOURCE) { return URLs.fileToUrl(gridfile.file()); } else { return null; } } }
/** Returns all registered style handlers. */ public static List<StyleHandler> handlers() { return GeoServerExtensions.extensions(StyleHandler.class); } }
/** * Looks up for a named string property in the order defined by {@link #getProperty(String, * ApplicationContext)} using the internally cached spring application context. * * <p>Care should be taken when using this method. It should not be called during startup or * from tests cases as the internal context will not have been set. * * @param propertyName The property name to lookup. * @return The property value, or null if not found */ public static String getProperty(String propertyName) { return getProperty(propertyName, context); }
Class<T> serviceClass, String workspace, GeoServer geoServer) { Catalog catalog = geoServer.getCatalog(); GeoServerExtensions.extensions(XStreamServiceLoader.class); for (XStreamServiceLoader loader : loaders) { if (serviceClass.equals(loader.getServiceClass())) { WorkspaceInfo ws = null; if (workspace != null) { ws = catalog.getWorkspaceByName(workspace); old = geoServer.getService(ws, serviceClass); } else { old = geoServer.getService(serviceClass);
protected void readConfiguration(GeoServer geoServer, XStreamPersister xp) throws Exception { Resource f = resourceLoader.get("services.xml"); if (!Resources.exists(f)) { f = resourceLoader.get("global.xml"); if (Resources.exists(f)) { try { GeoServerInfo global = depersist(xp, f, GeoServerInfo.class); geoServer.setGlobal(global); } catch (Exception e) { LOGGER.log( Level.WARNING, "Failed to load global configuration file '" + f.name() + "'", e); for (Resource dir : workspaces.list()) { try { SettingsInfo settings = depersist(xp, f, SettingsInfo.class); geoServer.add(settings); } catch (Exception e) { LOGGER.log( GeoServerExtensions.extensions(XStreamServiceLoader.class);
public Catalog getCatalog() { // have to look this up dynamically on demand on avoid circular dependency on application // context startup return (Catalog) GeoServerExtensions.bean("catalog"); }
private Resource findUserProperties() throws IOException { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); Resource propFile = loader.get("security/users.properties"); if (propFile.getType() == Type.RESOURCE) { GeoServerInfo global = GeoServerExtensions.bean(GeoServer.class).getGlobal(); if ((global != null) && (global.getAdminUsername() != null) os = propFile.out(); p.store(os, "Format: name=password,ROLE1,...,ROLEN"); os.close(); Resource serviceFile = loader.get("security/service.properties"); os = serviceFile.out(); is = GeoServerUserDao.class.getResourceAsStream("serviceTemplate.properties"); byte[] buffer = new byte[1024];
GeoServerExtensions.bean(GeoServerEnvironment.class); DataStoreInfo ds = getCatalog().getFactory().createDataStore(); ds.getConnectionParameters().put("host", "${jdbc.host}"); ds.getConnectionParameters().put("port", "${jdbc.port}"); ds.setName(dsName); getCatalog().save(ds); ds = getCatalog().getDataStoreByName(dsName); DataStoreInfo expandedDs = getCatalog().getResourcePool().clone(ds, true);
public void writeTo(Object value, String mimeType, OutputStream os) throws IOException { CoveragesData data = (CoveragesData) value; final WCSInfo wcs = ((GeoServer) GeoServerExtensions.bean("geoServer")).getService(WCSInfo.class); CoveragesTransformer ct = new CoveragesTransformer(wcs, data.request); try { ct.transform(data.info, os); } catch (TransformerException e) { IOException io = new IOException("Error occurred during wcs:coverage encoding"); io.initCause(e); throw io; } }
target = catalog.getFactory().createDataStore(); target.setEnabled(source.isEnabled()); target.setName(source.getName()); GeoServerExtensions.bean(GeoServerEnvironment.class);
public ServiceSettingsResource(Context context, Request request, Response response, Class clazz, GeoServer geoServer) { super(context, request, response, clazz, geoServer.getCatalog()); this.clazz = clazz; this.geoServer = geoServer; if (clazz.equals(WCSInfo.class)) { serviceXmlFileName = "wcs.xml"; } else if (clazz.equals(WMSInfo.class)) { serviceXmlFileName = "wms.xml"; } else if (clazz.equals(WFSInfo.class)) { serviceXmlFileName = "wfs.xml"; } loaders = GeoServerExtensions.extensions(XStreamServiceLoader.class); resourceLoader = GeoServerExtensions.bean(GeoServerResourceLoader.class); }
public List validateGETMAP(InputSource xml, ServletContext servContext) { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); Resource schema = loader.get("data/capabilities/sld/GetMap.xsd"); File schemaFile = schema.file(); // File schemaFile = new File(GeoserverDataDirectory.getGeoserverDataDirectory(), // "/data/capabilities/sld/GetMap.xsd"); try { return validateGETMAP(xml, URLs.fileToUrl(schemaFile)); } catch (Exception e) { ArrayList al = new ArrayList(); al.add(new SAXException(e)); return al; } }
@Override public void saveConfiguration(GeoServerResourceLoader resourceLoader) throws IOException { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); for (Resource controlflow : getFileLocations()) { Resource targetDir = Files.asResource( resourceLoader.findOrCreateDirectory( Paths.convert( loader.getBaseDirectory(), controlflow.parent().dir()))); Resources.copy(controlflow.file(), targetDir); } }
public void reload(Catalog newCatalog) throws Exception { GeoServerExtensions.extensions(GeoServerLifecycleHandler.class); for (GeoServerLifecycleHandler handler : handlers) { try { GeoServerLoaderProxy loader = GeoServerExtensions.bean(GeoServerLoaderProxy.class); synchronized (org.geoserver.config.GeoServer.CONFIGURATION_LOCK) { getCatalog().getResourcePool().dispose();
@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testExtensionProvider() { ApplicationContext appContext = createMock(ApplicationContext.class); GeoServerExtensions gse = new GeoServerExtensions(); gse.setApplicationContext(appContext); expect(appContext.getBeanNamesForType(ExtensionFilter.class)).andReturn(new String[0]); expect(appContext.getBeanNamesForType(GeoServerExtensionsTest.class)) .andReturn(new String[0]); expect(appContext.getBeanNamesForType(ExtensionProvider.class)) .andReturn(new String[] {"testKey2"}); ExtensionProvider xp = createMock(ExtensionProvider.class); expect(xp.getExtensionPoint()).andReturn(GeoServerExtensionsTest.class); expect(xp.getExtensions(GeoServerExtensionsTest.class)).andReturn(Arrays.asList(this)); expect(appContext.getBean("testKey2")).andReturn(xp); expect(appContext.isSingleton((String) anyObject())).andReturn(true).anyTimes(); replay(xp); replay(appContext); assertEquals(1, GeoServerExtensions.extensions(GeoServerExtensionsTest.class).size()); verify(xp); verify(appContext); }
Resource masterPasswordInfo = security().get(MASTER_PASSWD_INFO_FILENAME); if (masterPasswordInfo.getType() != Type.UNDEFINED) { LOGGER.warning( masterPasswordInfo.path() + " is a security risk. Please read this file and remove it afterward"); GeoServerExtensions.extensions(GeoServerSecurityProvider.class)) { securityProvider.init(this);
@Test public void testWmsCascadeEntityExpansion() throws Exception { GeoServerExtensions.extensions(ResourcePoolInitializer.class) .get(0) .initialize(getGeoServer()); ResourcePool rp = getCatalog().getResourcePool(); WMSStoreInfo info = getCatalog().getFactory().createWebMapServer(); URL url = getClass().getResource("1.3.0Capabilities-xxe.xml"); info.setCapabilitiesURL(url.toExternalForm()); getGeoServer().reload(); rp = getCatalog().getResourcePool();
/** * This method is used for extracting the metadata map from the selected workspace * * @param workspaceName * @param catalog */ public static MetadataMap loadMapfromWorkSpace(String workspaceName, Catalog catalog) { WorkspaceInfo wsInfo = catalog.getWorkspaceByName(workspaceName); // If the WorkSpace is present, then the associated MetadataMap is selected if (wsInfo != null) { GeoServer gs = GeoServerExtensions.bean(GeoServer.class); SettingsInfo info = gs.getSettings(wsInfo); return info != null ? info.getMetadata() : null; } return null; }
@Test public void testAddFilePathWithSpaces() throws Exception { // Other tests mess with or reset the resourcePool, so lets make it is initialised properly GeoServerExtensions.extensions(ResourcePoolInitializer.class) .get(0) .initialize(getGeoServer()); ResourcePool rp = getCatalog().getResourcePool(); CoverageStoreInfo info = getCatalog().getFactory().createCoverageStore(); info.setName("spaces"); info.setType("ImagePyramid"); info.setEnabled(true); info.setURL( "file://./src/test/resources/data_dir/nested_layer_groups/data/pyramid with space"); try { rp.getGridCoverageReader(info, null); } catch (Exception e) { e.printStackTrace(); fail("Unable to add an imagepyramid with a space in it's name"); } rp.dispose(); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { // create the test workspace if it doesn't exsist workspace = new WorkspaceInfoImpl(); workspace.setId("test-workspace"); workspace.setName("test-workspace"); getCatalog().add(workspace); // initiate the handlers related with services serviceHandler = GeoServerExtensions.bean(JMSServiceHandlerSPI.class).createHandler(); }