/** * Adds a service configuration to the test setup. If the service object already exists it is * simply reverted to its original state. * * @param serviceClass The class of the service * @param workspace The optional workspace for the service, may be <code>null</code> * @param geoServer The GeoServer configuration object. */ public <T extends ServiceInfo> void addService( Class<T> serviceClass, String workspace, GeoServer geoServer) { Catalog catalog = geoServer.getCatalog(); List<XStreamServiceLoader> loaders = GeoServerExtensions.extensions(XStreamServiceLoader.class); for (XStreamServiceLoader loader : loaders) { if (serviceClass.equals(loader.getServiceClass())) { // create a new one T created = (T) loader.create(geoServer); // grab the old one, if it exists T old = null; WorkspaceInfo ws = null; if (workspace != null) { ws = catalog.getWorkspaceByName(workspace); old = geoServer.getService(ws, serviceClass); } else { old = geoServer.getService(serviceClass); } if (old != null) { // update the old copy OwsUtils.copy(created, old, serviceClass); geoServer.save(old); } else { // add the new one created.setWorkspace(ws); geoServer.add(created); } break; } } }
/** Creates a new WFSCapsTransformer object. */ public Wcs10CapsTransformer(GeoServer geoServer) { super(); this.geoServer = geoServer; this.wcs = geoServer.getService(WCSInfo.class); this.catalog = geoServer.getCatalog(); setNamespaceDeclarationEnabled(false); }
@Test public void testCreateAsJSON() throws Exception { GeoServer geoServer = getGeoServer(); geoServer.remove(geoServer.getSettings(geoServer.getCatalog().getWorkspaceByName("sf"))); String json = "{'settings':{'workspace':{'name':'sf'}," + "'contact':{'addressCity':'Alexandria','addressCountry':'Egypt','addressType':'Work'," + "'contactEmail':'*****@*****.**','contactOrganization':'The ancient geographes INC'," + "'contactPerson':'Claudius Ptolomaeus','contactPosition':'Chief geographer'}," + "'charset':'UTF-8','numDecimals':10,'onlineResource':'http://geoserver.org'," + "'proxyBaseUrl':'http://proxy.url','verbose':false,'verboseExceptions':'true'}}"; MockHttpServletResponse response = putAsServletResponse("/rest/workspaces/sf/settings", json, "text/json"); assertEquals(200, response.getStatusCode()); JSON jsonMod = getAsJSON("/rest/workspaces/sf/settings.json"); JSONObject jsonObject = (JSONObject) jsonMod; assertNotNull(jsonObject); JSONObject settings = jsonObject.getJSONObject("settings"); assertNotNull(settings); JSONObject workspace = settings.getJSONObject("workspace"); assertNotNull(workspace); assertEquals("sf", workspace.get("name")); assertEquals("10", settings.get("numDecimals").toString().trim()); assertEquals("http://geoserver.org", settings.get("onlineResource")); assertEquals("http://proxy.url", settings.get("proxyBaseUrl")); JSONObject contact = settings.getJSONObject("contact"); assertEquals("Claudius Ptolomaeus", contact.get("contactPerson")); assertEquals("The ancient geographes INC", contact.get("contactOrganization")); assertEquals("Work", contact.get("addressType")); assertEquals("*****@*****.**", contact.get("contactEmail")); }
@Override protected void setUpInternal() throws Exception { // configure the GSS service GeoServer gs = getGeoServer(); GSSInfo gssInfo = gs.getService(GSSInfo.class); gssInfo.setMode(GSSMode.Central); gssInfo.setVersioningDataStore(getCatalog().getDataStoreByName("synch")); gs.save(gssInfo); // initialize the GSS service Map gssBeans = applicationContext.getBeansOfType(DefaultGeoServerSynchronizationService.class); gss = (DefaultGeoServerSynchronizationService) gssBeans.values().iterator().next(); gss.core.ensureCentralEnabled(); // grab the synch manager synch = (SynchronizationManager) applicationContext .getBeansOfType(SynchronizationManager.class) .values() .iterator() .next(); // disable automated scheduling, we control how does what here Timer timer = (Timer) applicationContext.getBean("gssTimerFactory"); timer.cancel(); // make some tables synchronised synchStore = (VersioningDataStore) getCatalog().getDataStoreByName("synch").getDataStore(null); FeatureStore<SimpleFeatureType, SimpleFeature> fs = (FeatureStore<SimpleFeatureType, SimpleFeature>) synchStore.getFeatureSource(SYNCH_TABLES); long restrectedId = addFeature(fs, "restricted", "2"); long roadsId = addFeature(fs, "roads", "2"); synchStore.setVersioned("restricted", true, null, null); synchStore.setVersioned("roads", true, null, null); // add some units fsUnits = (FeatureStore<SimpleFeatureType, SimpleFeature>) synchStore.getFeatureSource(SYNCH_UNITS); long mangoId = addFeature( fsUnits, "unit1", "http://localhost:8081/geoserver/ows", null, null, null, null, 60, 10, false); // link units and tables fsUnitTables = (FeatureStore<SimpleFeatureType, SimpleFeature>) synchStore.getFeatureSource(SYNCH_UNIT_TABLES); addFeature(fsUnitTables, mangoId, restrectedId, null, null, null, null); // addFeature(fsUnitTables, mangoId, roadsId, null, null, null, null); }
@Test public void testDefaultLocation() { GeoServer gs = getGeoServerApplication().getGeoServer(); LoggingInfo logging = gs.getLogging(); logging.setLocation("logs/geoserver.log"); gs.save(logging); login(); tester.startPage(LogPage.class); tester.assertRenderedPage(LogPage.class); }
@BeforeClass public static void setUpData() throws Exception { MonitorDAO dao = new MemoryMonitorDAO(); new MonitorTestData(dao).setup(); MonitorConfig mc = new MonitorConfig() { @Override public MonitorDAO createDAO() { MonitorDAO dao = new MemoryMonitorDAO(); try { new MonitorTestData(dao).setup(); return dao; } catch (java.text.ParseException e) { throw new RuntimeException(e); } } @Override public BboxMode getBboxMode() { return BboxMode.FULL; } }; GeoServer gs = createMock(GeoServer.class); monitor = new Monitor(mc); monitor.setServer(gs); catalog = new CatalogImpl(); expect(gs.getCatalog()).andStubReturn(catalog); replay(gs); NamespaceInfo ns = catalog.getFactory().createNamespace(); ns.setPrefix("acme"); ns.setURI("http://acme.org"); catalog.add(ns); DataStoreInfo ds = catalog.getFactory().createDataStore(); FeatureTypeInfo ftFoo = catalog.getFactory().createFeatureType(); ftFoo.setName("foo"); ftFoo.setSRS("EPSG:4326"); ftFoo.setNamespace(ns); ftFoo.setStore(ds); catalog.add(ftFoo); FeatureTypeInfo ftBar = catalog.getFactory().createFeatureType(); ftBar.setName("bar"); ftBar.setSRS("EPSG:3348"); ftBar.setNamespace(ns); ftBar.setStore(ds); catalog.add(ftBar); }
@Test public void testConfigureFeatureTypeCacheSize() { GeoServer gs = getGeoServer(); GeoServerInfo global = gs.getGlobal(); global.setFeatureTypeCacheSize(200); gs.save(global); Catalog catalog = getCatalog(); // we actually keep two versions of the feature type in the cache, so we need it // twice as big assertEquals( 400, ((SoftValueHashMap) catalog.getResourcePool().getFeatureTypeCache()) .getHardReferencesCount()); }
public Data getRawData() { Catalog catalog = gs.getCatalog(); if (catalog instanceof Wrapper && ((Wrapper) catalog).isWrapperFor(Catalog.class)) { catalog = ((Wrapper) catalog).unwrap(Catalog.class); } return new Data(gs, catalog); }
public void onPostLoad(PostLoadEvent event) { if (!active) return; Object entity = event.getEntity(); if (entity instanceof StoreInfoImpl) { ((StoreInfoImpl) entity).setCatalog(catalog); } else if (entity instanceof ResourceInfoImpl) { ((ResourceInfoImpl) entity).setCatalog(catalog); } else if (entity instanceof StyleInfoImpl) { ((StyleInfoImpl) entity).setCatalog(catalog); } else if (entity instanceof LayerGroupInfoImpl) { // hack to get around default styles being represented by null // TODO: see if we can coax the hibernate mappings into doing this for us LayerGroupInfoImpl lg = (LayerGroupInfoImpl) entity; if (lg.getStyles().isEmpty()) { for (LayerInfo l : lg.getLayers()) { lg.getStyles().add(null); } } } else if (entity instanceof ServiceInfoImpl) { ((ServiceInfoImpl) entity).setGeoServer(geoServer); } else if (entity instanceof GeoServerInfoImpl) { // contact is mapped as a component... and hibernate assumes that all null values // means a null object... i don't think this is configurable but coudl be wrong GeoServerInfoImpl global = (GeoServerInfoImpl) entity; if (global.getContact() == null) { global.setContact(geoServer.getFactory().createContact()); } } }
/** * Reads all the common attributes from the service info class. * * <p>This method is intended to be called by subclasses after creating an instance of * ServiceInfo. Example: * * <pre> * // read properties * Map<String,Object> props = reader.wfs(); * * // create config object * WFSInfo wfs = new WFSInfoImpl(); * * //load common properties * load( wfs, reader ); * * //load wfs specific properties * wfs.setServiceLevel( map.get( "serviceLevel") ); * ... * </pre> */ protected void readCommon(ServiceInfo service, Map<String, Object> properties, GeoServer gs) throws Exception { service.setEnabled((Boolean) properties.get("enabled")); service.setName((String) properties.get("name")); service.setTitle((String) properties.get("title")); service.setAbstract((String) properties.get("abstract")); Map metadataLink = (Map) properties.get("metadataLink"); if (metadataLink != null) { MetadataLinkInfo ml = gs.getCatalog().getFactory().createMetadataLink(); ml.setAbout((String) metadataLink.get("about")); ml.setMetadataType((String) metadataLink.get("metadataType")); ml.setType((String) metadataLink.get("type")); service.setMetadataLink(ml); } List<String> keywords = (List<String>) properties.get("keywords"); if (keywords != null) { for (String kw : keywords) { service.getKeywords().add(new Keyword(kw)); } } service.setOnlineResource((String) properties.get("onlineResource")); service.setFees((String) properties.get("fees")); service.setAccessConstraints((String) properties.get("accessConstraints")); service.setCiteCompliant((Boolean) properties.get("citeConformanceHacks")); service.setMaintainer((String) properties.get("maintainer")); service.setSchemaBaseURL((String) properties.get("SchemaBaseUrl")); }
/** * Looks up a {@link LayerInfo} or {@link LayerGroupInfo} named after the {@code <layer>} in the * requested resource {@code <layer>.kml} name * * @see org.restlet.Finder#findTarget(org.restlet.data.Request, org.restlet.data.Response) */ @Override public Resource findTarget(final Request request, Response response) { if (!Method.GET.equals(request.getMethod())) { response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); return null; } final String name = RESTUtils.getAttribute(request, "layer"); if (name == null) { throw new RestletException("No layer name specified", Status.CLIENT_ERROR_BAD_REQUEST); } final Catalog catalog = geoserver.getCatalog(); CatalogInfo layer = catalog.getLayerByName(name); MetadataMap mdmap; if (layer == null) { layer = catalog.getLayerGroupByName(name); if (layer == null) { throw new RestletException("Layer " + name + " not found", Status.CLIENT_ERROR_NOT_FOUND); } mdmap = ((LayerGroupInfo) layer).getMetadata(); } else { mdmap = ((LayerInfo) layer).getMetadata(); } Boolean enabled = mdmap.get(Properties.INDEXING_ENABLED, Boolean.class); if (enabled == null || !enabled.booleanValue()) { throw new RestletException("Layer " + name + " not found", Status.CLIENT_ERROR_NOT_FOUND); } final Context context = getContext(); return new GeoSearchLayer(context, request, response, layer, geoserver); }
/** * Before using {@code gwc-gs.xml} to hold the integrated GWC configuration, the only property * configured was whether the direct WMS integration option was enabled, and it was saved as part * of the {@link WMSInfo} metadata map under the {@code GWC_WMS_Integration} key. This method * removes that key from WMSInfo if present and sets its value to the {@code gwcConfig} instead. */ private void upgradeWMSIntegrationConfig(final GeoServer geoServer, final GWCConfig gwcConfig) throws IOException { // Check whether we're using the old way of storing this information, and get rid of it WMSInfo service = geoServer.getService(WMSInfo.class); if (service != null) { MetadataMap metadata = service.getMetadata(); if (service != null && metadata != null) { Boolean storedValue = metadata.get(WMS_INTEGRATION_ENABLED_KEY, Boolean.class); if (storedValue != null) { boolean enabled = storedValue.booleanValue(); gwcConfig.setDirectWMSIntegrationEnabled(enabled); metadata.remove(WMS_INTEGRATION_ENABLED_KEY); geoServer.save(service); } } } }
/** * Adds a settings configuration to the test setup. If the settings object already exists it is * simply reverted to its original state. * * @param workspace The optional workspace for the settings, may be <code>null</code> * @param geoServer The GeoServer configuration object. */ public void addSettings(String workspace, GeoServer geoServer) { WorkspaceInfo ws = workspace != null ? geoServer.getCatalog().getWorkspaceByName(workspace) : null; GeoServerInfo global = geoServer.getGlobal(); SettingsInfo settings = ws != null ? geoServer.getSettings(ws) : global.getSettings(); if (settings == null) { settings = geoServer.getFactory().createSettings(); } settings.setWorkspace(ws); settings.getContact().setContactPerson("Andrea Aime"); settings.setNumDecimals(8); settings.setOnlineResource("http://geoserver.org"); settings.setVerbose(false); settings.setVerboseExceptions(false); settings.setLocalWorkspaceIncludesPrefix(false); if (ws != null) { if (settings.getId() != null) { geoServer.save(settings); } else { geoServer.add(settings); } } else { // global geoServer.save(global); } }
public void initialize(GeoServer geoServer) throws Exception { this.geoServer = geoServer; // we need the original catalog, not a wrapper Catalog catalog = geoServer.getCatalog(); if (catalog instanceof Wrapper) { catalog = ((Wrapper) catalog).unwrap(Catalog.class); } this.catalog = catalog; active = true; }
@Test public void testCreateAsXML() throws Exception { GeoServer geoServer = getGeoServer(); geoServer.remove(geoServer.getSettings(geoServer.getCatalog().getWorkspaceByName("sf"))); String xml = "<settings>" + "<workspace><name>sf</name></workspace>" + "<contact>" + "<addressCity>Alexandria</addressCity>" + "<addressCountry>Egypt</addressCountry>" + "<addressType>Work</addressType>" + "<contactEmail>[email protected]</contactEmail>" + "<contactOrganization>The ancient geographes INC</contactOrganization>" + "<contactPerson>Claudius Ptolomaeus</contactPerson>" + "<contactPosition>Chief geographer</contactPosition>" + "</contact>" + "<charset>UTF-8</charset>" + "<numDecimals>8</numDecimals>" + "<onlineResource>http://geoserver.org</onlineResource>" + "<proxyBaseUrl>http://proxy.url</proxyBaseUrl>" + "<verbose>false</verbose>" + "<verboseExceptions>false</verboseExceptions>" + "</settings>"; MockHttpServletResponse response = putAsServletResponse("/rest/workspaces/sf/settings", xml, "text/xml"); assertEquals(200, response.getStatusCode()); Document dom = getAsDOM("/rest/workspaces/sf/settings.xml"); assertEquals("settings", dom.getDocumentElement().getLocalName()); assertXpathEvaluatesTo("sf", "/settings/workspace/name", dom); assertXpathEvaluatesTo("false", "/settings/verbose", dom); assertXpathEvaluatesTo("false", "/settings/verboseExceptions", dom); assertXpathEvaluatesTo("http://geoserver.org", "/settings/onlineResource", dom); assertXpathEvaluatesTo("http://proxy.url", "/settings/proxyBaseUrl", dom); assertXpathEvaluatesTo("Claudius Ptolomaeus", "/settings/contact/contactPerson", dom); assertXpathEvaluatesTo("*****@*****.**", "/settings/contact/contactEmail", dom); assertXpathEvaluatesTo("Chief geographer", "/settings/contact/contactPosition", dom); assertXpathEvaluatesTo( "The ancient geographes INC", "/settings/contact/contactOrganization", dom); assertXpathEvaluatesTo("Egypt", "/settings/contact/addressCountry", dom); }
/** Encodes the service metadata section of a WMS capabilities document. */ private void handleService() { start("Service"); final WMSInfo serviceInfo = wmsConfig.getServiceInfo(); element("Name", "OGC:WMS"); element("Title", serviceInfo.getTitle()); element("Abstract", serviceInfo.getAbstract()); handleKeywordList(serviceInfo.getKeywords()); AttributesImpl orAtts = new AttributesImpl(); orAtts.addAttribute("", "xmlns:xlink", "xmlns:xlink", "", XLINK_NS); orAtts.addAttribute(XLINK_NS, "xlink:type", "xlink:type", "", "simple"); String onlineResource = serviceInfo.getOnlineResource(); if (onlineResource == null || onlineResource.trim().length() == 0) { String requestBaseUrl = request.getBaseUrl(); onlineResource = buildURL(requestBaseUrl, null, null, URLType.SERVICE); } else { try { new URL(onlineResource); } catch (MalformedURLException e) { LOGGER.log( Level.WARNING, "WMS online resource seems to be an invalid URL: '" + onlineResource + "'"); } } orAtts.addAttribute("", "xlink:href", "xlink:href", "", onlineResource); element("OnlineResource", null, orAtts); GeoServer geoServer = wmsConfig.getGeoServer(); ContactInfo contact = geoServer.getGlobal().getContact(); handleContactInfo(contact); element("Fees", serviceInfo.getFees()); element("AccessConstraints", serviceInfo.getAccessConstraints()); end("Service"); }
/** See https://osgeo-org.atlassian.net/browse/GEOS-3965 */ @Test public void testProxyBaseURL() throws Exception { GeoServer gs = getGeoServer(); try { GeoServerInfo info = gs.getGlobal(); info.getSettings().setProxyBaseUrl("http://myhost:9999/gs"); gs.save(info); final String requestUrl = "wms/kml?layers=" + getLayerId(MockData.BRIDGES) + "&styles=Bridge&mode=download"; Document dom = getAsDOM(requestUrl); // make sure we are using the proxy base URL XMLAssert.assertXpathEvaluatesTo( "http://myhost:9999/gs/styles/bridge.png", "//kml:Style/kml:IconStyle/kml:Icon/kml:href", dom); } finally { GeoServerInfo info = gs.getGlobal(); info.getSettings().setProxyBaseUrl(null); gs.save(info); } }
public void mangleURL( StringBuilder baseURL, StringBuilder path, Map<String, String> kvp, URLType type) { // first check the system property String proxyBase = GeoServerExtensions.getProperty("PROXY_BASE_URL"); if (proxyBase == null) { // if no system property fall back to configuration proxyBase = geoServer.getGlobal().getProxyBaseUrl(); } // perform the replacement if the proxy base is set if (proxyBase != null && proxyBase.trim().length() > 0) { baseURL.setLength(0); baseURL.append(proxyBase); } }
@SuppressWarnings("deprecation") @Before public void setUp() { WFSURIHandler.ADDITIONAL_HOSTNAMES.clear(); WFSURIHandler.ADDRESSES.clear(); // Suppress the network interface interrogation so it doesn't interfere with other tests strategy = new InitStrategy() { public Collection<NetworkInterface> getNetworkInterfaces() { return Collections.emptyList(); } }; gs = EasyMock.createMock(GeoServer.class); config = EasyMock.createMock(GeoServerInfo.class); expect(gs.getGlobal()).andStubReturn(config); expect(config.getProxyBaseUrl()).andStubReturn(null); replay(gs, config); }
public QuickTileCache(GeoServer geoServer) { geoServer.addListener( new ConfigurationListenerAdapter() { public void handleGlobalChange( GeoServerInfo global, List<String> propertyNames, List<Object> oldValues, List<Object> newValues) { tileCache.clear(); } public void handleServiceChange( ServiceInfo service, List<String> propertyNames, List<Object> oldValues, List<Object> newValues) { tileCache.clear(); } public void reloaded() { tileCache.clear(); } }); }
/** * Handles contacts. * * @param config the service. */ private void handleContact() { final GeoServer gs = wcs.getGeoServer(); String tmp = ""; SettingsInfo settings = gs.getSettings(); ContactInfo contact = settings.getContact(); if (((contact != null) && (contact.getContactPerson() != "")) || ((contact.getContactOrganization() != null) && (contact.getContactOrganization() != ""))) { start("wcs:responsibleParty"); tmp = contact.getContactPerson(); if ((tmp != null) && (tmp != "")) { element("wcs:individualName", tmp); } else { // not optional element("wcs:individualName", ""); } tmp = contact.getContactOrganization(); if ((tmp != null) && (tmp != "")) { element("wcs:organisationName", tmp); } tmp = contact.getContactPosition(); if ((tmp != null) && (tmp != "")) { element("wcs:positionName", tmp); } start("wcs:contactInfo"); start("wcs:phone"); tmp = contact.getContactVoice(); if ((tmp != null) && (tmp != "")) { element("wcs:voice", tmp); } tmp = contact.getContactFacsimile(); if ((tmp != null) && (tmp != "")) { element("wcs:facsimile", tmp); } end("wcs:phone"); start("wcs:address"); tmp = contact.getAddressType(); if ((tmp != null) && (tmp != "")) { String addr = ""; addr = contact.getAddress(); if ((addr != null) && (addr != "")) { element("wcs:deliveryPoint", tmp + " " + addr); } } else { tmp = contact.getAddress(); if ((tmp != null) && (tmp != "")) { element("wcs:deliveryPoint", tmp); } } tmp = contact.getAddressCity(); if ((tmp != null) && (tmp != "")) { element("wcs:city", tmp); } tmp = contact.getAddressState(); if ((tmp != null) && (tmp != "")) { element("wcs:administrativeArea", tmp); } tmp = contact.getAddressPostalCode(); if ((tmp != null) && (tmp != "")) { element("wcs:postalCode", tmp); } tmp = contact.getAddressCountry(); if ((tmp != null) && (tmp != "")) { element("wcs:country", tmp); } tmp = contact.getContactEmail(); if ((tmp != null) && (tmp != "")) { element("wcs:electronicMailAddress", tmp); } end("wcs:address"); tmp = contact.getOnlineResource(); if ((tmp != null) && (tmp != "")) { AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute("", "xlink:href", "xlink:href", "", tmp); start("wcs:onlineResource", attributes); end("wcs:onlineResource"); } end("wcs:contactInfo"); end("wcs:responsibleParty"); } }
public WMSInfo getServiceInfo() { return geoserver.getService(WMSInfo.class); }
public String getProxyBaseUrl() { GeoServer geoServer = getGeoServer(); return geoServer.getSettings().getProxyBaseUrl(); }
public Catalog getCatalog() { return geoserver.getCatalog(); }
@SuppressWarnings({"rawtypes", "unchecked"}) public GeoServerHomePage() { GeoServer gs = getGeoServer(); ContactInfo contact = gs.getGlobal().getSettings().getContact(); // add some contact info add( new ExternalLink("contactURL", contact.getOnlineResource()) .add(new Label("contactName", contact.getContactOrganization()))); { String version = String.valueOf(new ResourceModel("version").getObject()); String contactEmail = contact.getContactEmail(); HashMap<String, String> params = new HashMap<String, String>(); params.put("version", version); params.put("contactEmail", (contactEmail == null ? "*****@*****.**" : contactEmail)); Label label = new Label( "footerMessage", new StringResourceModel("GeoServerHomePage.footer", this, new Model(params))); label.setEscapeModelStrings(false); add(label); } Authentication auth = getSession().getAuthentication(); if (isAdmin(auth)) { Stopwatch sw = Stopwatch.createStarted(); Fragment f = new Fragment("catalogLinks", "catalogLinksFragment", this); Catalog catalog = getCatalog(); NumberFormat numberFormat = NumberFormat.getIntegerInstance(getLocale()); numberFormat.setGroupingUsed(true); final Filter allLayers = acceptAll(); final Filter allStores = acceptAll(); final Filter allWorkspaces = acceptAll(); final int layerCount = catalog.count(LayerInfo.class, allLayers); final int storesCount = catalog.count(StoreInfo.class, allStores); final int wsCount = catalog.count(WorkspaceInfo.class, allWorkspaces); f.add( new BookmarkablePageLink("layersLink", LayerPage.class) .add(new Label("nlayers", numberFormat.format(layerCount)))); f.add(new BookmarkablePageLink("addLayerLink", NewLayerPage.class)); f.add( new BookmarkablePageLink("storesLink", StorePage.class) .add(new Label("nstores", numberFormat.format(storesCount)))); f.add(new BookmarkablePageLink("addStoreLink", NewDataPage.class)); f.add( new BookmarkablePageLink("workspacesLink", WorkspacePage.class) .add(new Label("nworkspaces", numberFormat.format(wsCount)))); f.add(new BookmarkablePageLink("addWorkspaceLink", WorkspaceNewPage.class)); add(f); sw.stop(); } else { Label placeHolder = new Label("catalogLinks"); placeHolder.setVisible(false); add(placeHolder); } final IModel<List<GeoServerHomePageContentProvider>> contentProviders; contentProviders = getContentProviders(GeoServerHomePageContentProvider.class); ListView<GeoServerHomePageContentProvider> contentView = new ListView<GeoServerHomePageContentProvider>("contributedContent", contentProviders) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<GeoServerHomePageContentProvider> item) { GeoServerHomePageContentProvider provider = item.getModelObject(); Component extraContent = provider.getPageBodyComponent("contentList"); if (null == extraContent) { Label placeHolder = new Label("contentList"); placeHolder.setVisible(false); extraContent = placeHolder; } item.add(extraContent); } }; add(contentView); final IModel<List<CapabilitiesHomePageLinkProvider>> capsProviders; capsProviders = getContentProviders(CapabilitiesHomePageLinkProvider.class); ListView<CapabilitiesHomePageLinkProvider> capsView = new ListView<CapabilitiesHomePageLinkProvider>("providedCaps", capsProviders) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<CapabilitiesHomePageLinkProvider> item) { CapabilitiesHomePageLinkProvider provider = item.getModelObject(); Component capsList = provider.getCapabilitiesComponent("capsList"); item.add(capsList); } }; add(capsView); }
public void write(Object value, OutputStream output, Operation operation) throws IOException, ServiceException { final FeatureDiffReader[] diffReaders = (FeatureDiffReader[]) value; // create a new feature collcetion type with just the numbers VersioningTransactionConverter converter = new VersioningTransactionConverter(); final TransactionType transaction = converter.convert(diffReaders, TransactionType.class); // declare wfs schema location BaseRequestType gft = (BaseRequestType) operation.getParameters()[0]; Encoder encoder = new Encoder(configuration, configuration.schema()); encodeWfsSchemaLocation(encoder, gft.getBaseUrl()); encoder.setIndenting(true); encoder.setEncoding(Charset.forName(geoServer.getSettings().getCharset())); // set up schema locations // round up the info objects for each feature collection HashMap /* <String,Set> */ ns2metas = new HashMap(); for (int i = 0; i < diffReaders.length; i++) { final FeatureDiffReader diffReader = diffReaders[i]; final SimpleFeatureType featureType = diffReader.getSchema(); // load the metadata for the feature type String namespaceURI = featureType.getName().getNamespaceURI(); FeatureTypeInfo meta = geoServer .getCatalog() .getFeatureTypeByName(namespaceURI, featureType.getName().getLocalPart()); // add it to the map Set metas = (Set) ns2metas.get(namespaceURI); if (metas == null) { metas = new HashSet(); ns2metas.put(namespaceURI, metas); } metas.add(meta); } // declare application schema namespaces for (Iterator i = ns2metas.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); String namespaceURI = (String) entry.getKey(); Set metas = (Set) entry.getValue(); StringBuffer typeNames = new StringBuffer(); for (Iterator m = metas.iterator(); m.hasNext(); ) { FeatureTypeInfo meta = (FeatureTypeInfo) m.next(); typeNames.append(meta.getName()); if (m.hasNext()) { typeNames.append(","); } } // set the schema location encodeTypeSchemaLocation(encoder, gft.getBaseUrl(), namespaceURI, typeNames); } try { encoder.encode(transaction, element, output); } finally { for (int i = 0; i < diffReaders.length; i++) { diffReaders[i].close(); } } }
/** * @param readLimits * @param writeLimits * @param hardOutputLimit * @param geoserver */ public DownloadEstimatorProcess( DownloadServiceConfigurationGenerator downloadServiceConfigurationGenerator, GeoServer geoserver) { this.catalog = geoserver.getCatalog(); this.downloadServiceConfigurationGenerator = downloadServiceConfigurationGenerator; }
private JAIInfo getJaiInfo() { GeoServer geoServer = getGeoServer(); GeoServerInfo global = geoServer.getGlobal(); return global.getJAI(); }
private void setOutputLimit(int kbytes) { GeoServer gs = getGeoServer(); WCSInfo info = gs.getService(WCSInfo.class); info.setMaxOutputMemory(kbytes); gs.save(info); }
public Charset getCharSet() { GeoServer geoServer2 = getGeoServer(); String charset = geoServer2.getSettings().getCharset(); return Charset.forName(charset); }