if (metadata != null && metadata.containsKey(CoverageView.COVERAGE_VIEW)) { CoverageView coverageView = (CoverageView) metadata.get(CoverageView.COVERAGE_VIEW); reader =
if (map.containsKey(CoverageView.COVERAGE_VIEW)) { CoverageView coverageView = (CoverageView) map.get(CoverageView.COVERAGE_VIEW); dimensions = new ArrayList<>();
public static boolean hasTileLayerDef(MetadataMap metadataMap) { return metadataMap.containsKey(CONFIG_KEY_ENABLED); }
public static boolean hasTileLayerDef(MetadataMap metadataMap) { return metadataMap.containsKey(CONFIG_KEY_ENABLED); }
private String[] getAttribute(final MetadataMap metadata, final String attributeName) { if (metadata != null && metadata.containsKey(attributeName)) { DimensionInfo dimension = metadata.get(attributeName, DimensionInfo.class); final String attribute = dimension.getAttribute(); final String endAttribute = dimension.getEndAttribute(); return new String[] {attribute, endAttribute}; } return new String[] {}; }
private static GeoServerTileLayerInfoImpl load(final MetadataMap metadataMap) { GeoServerTileLayerInfoImpl info = new GeoServerTileLayerInfoImpl(); // whether the config needs to be saved final boolean enabled = metadataMap.get(CONFIG_KEY_ENABLED, Boolean.class).booleanValue(); info.setEnabled(enabled); int gutter = metadataMap.get(CONFIG_KEY_GUTTER, Integer.class).intValue(); info.setGutter(gutter); String gridsets = metadataMap.get(CONFIG_KEY_GRIDSETS, String.class); Set<XMLGridSubset> gridSetIds = unmarshalGridSubsets(gridsets); info.getGridSubsets().addAll(gridSetIds); int metaTilingX = metadataMap.get(CONFIG_KEY_METATILING_X, Integer.class).intValue(); info.setMetaTilingX(metaTilingX); int metaTilingY = metadataMap.get(CONFIG_KEY_METATILING_Y, Integer.class).intValue(); info.setMetaTilingY(metaTilingY); if (metadataMap.containsKey(CONFIG_KEY_FORMATS)) { String mimeFormatsStr = metadataMap.get(CONFIG_KEY_FORMATS, String.class); Set<String> mimeFormats = unmarshalSet(mimeFormatsStr); info.getMimeFormats().addAll(mimeFormats); } if (metadataMap.containsKey(CONFIG_KEY_AUTO_CACHE_STYLES)) { boolean autoCacheStyles = metadataMap.get(CONFIG_KEY_AUTO_CACHE_STYLES, Boolean.class) .booleanValue(); info.setAutoCacheStyles(autoCacheStyles); } return info; }
private static GeoServerTileLayerInfoImpl load(final MetadataMap metadataMap) { GeoServerTileLayerInfoImpl info = new GeoServerTileLayerInfoImpl(); // whether the config needs to be saved final boolean enabled = metadataMap.get(CONFIG_KEY_ENABLED, Boolean.class).booleanValue(); info.setEnabled(enabled); int gutter = metadataMap.get(CONFIG_KEY_GUTTER, Integer.class).intValue(); info.setGutter(gutter); String gridsets = metadataMap.get(CONFIG_KEY_GRIDSETS, String.class); Set<XMLGridSubset> gridSetIds = unmarshalGridSubsets(gridsets); info.getGridSubsets().addAll(gridSetIds); int metaTilingX = metadataMap.get(CONFIG_KEY_METATILING_X, Integer.class).intValue(); info.setMetaTilingX(metaTilingX); int metaTilingY = metadataMap.get(CONFIG_KEY_METATILING_Y, Integer.class).intValue(); info.setMetaTilingY(metaTilingY); if (metadataMap.containsKey(CONFIG_KEY_FORMATS)) { String mimeFormatsStr = metadataMap.get(CONFIG_KEY_FORMATS, String.class); Set<String> mimeFormats = unmarshalSet(mimeFormatsStr); info.getMimeFormats().addAll(mimeFormats); } if (metadataMap.containsKey(CONFIG_KEY_AUTO_CACHE_STYLES)) { boolean autoCacheStyles = metadataMap.get(CONFIG_KEY_AUTO_CACHE_STYLES, Boolean.class).booleanValue(); info.setAutoCacheStyles(autoCacheStyles); } if (metadataMap.containsKey(CONFIG_KEY_IN_MEMORY_CACHED)) { boolean inMemoryCached = metadataMap.get(CONFIG_KEY_IN_MEMORY_CACHED, Boolean.class); info.setInMemoryCached(inMemoryCached); } return info; }
@Override public void initialize(GeoServer geoServer) throws Exception { // Add a new Element to the metadata map GeoServerInfo global = geoServer.getGlobal(); MetadataMap metadata = global.getSettings().getMetadata(); if(!metadata.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)){ metadata.put(NetCDFSettingsContainer.NETCDFOUT_KEY, new NetCDFSettingsContainer()); geoServer.save(global); } } }
@Override public void initialize(GeoServer geoServer) throws Exception { // Add a new Element to the metadata map GeoServerInfo global = geoServer.getGlobal(); MetadataMap metadata = global.getSettings().getMetadata(); if (!metadata.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)) { metadata.put(NetCDFSettingsContainer.NETCDFOUT_KEY, new NetCDFSettingsContainer()); geoServer.save(global); } } }
@SuppressWarnings("rawtypes") @Override public FeatureReader read(ImportData data, ImportTask task) throws IOException { File file = getFileFromData(data); // we need to get the feature type, to use for the particular parse through the file // since we put it on the metadata from the list method, we first check if that's still // available SimpleFeatureType ft = (SimpleFeatureType) task.getMetadata().get(FeatureType.class); if (ft == null) { // if the type is not available, we can generate one from the resource // we aren't able to ask for the feature type from the resource directly, // because we don't have a backing store FeatureTypeInfo fti = (FeatureTypeInfo) task.getLayer().getResource(); ft = buildFeatureTypeFromInfo(fti); MetadataMap metadata = fti.getMetadata(); if (metadata.containsKey("importschemanames")) { Map<Object, Object> userData = ft.getUserData(); userData.put("schemanames", metadata.get("importschemanames")); } } return read(ft, file); }
public void testUpgradeDirectWMSIntegrationFlag() throws Exception { // no gwc-gs.xml exists, so that initialization runs when(configPersister.findConfigFile()).thenReturn(null); // no catalog layers for this test List<LayerInfo> layers = ImmutableList.of(); List<LayerGroupInfo> groups = ImmutableList.of(); when(rawCatalog.getLayers()).thenReturn(layers); when(rawCatalog.getLayerGroups()).thenReturn(groups); WMSInfoImpl wmsInfo = new WMSInfoImpl(); // initialize wmsInfo with a value for the old direct wms integration flag wmsInfo.getMetadata().put(GWCInitializer.WMS_INTEGRATION_ENABLED_KEY, Boolean.TRUE); // make sure WMSInfo exists when(geoServer.getService(eq(WMSInfo.class))).thenReturn(wmsInfo); ArgumentCaptor<GWCConfig> captor = ArgumentCaptor.forClass(GWCConfig.class); // run layer initialization initializer.initialize(geoServer); verify(configPersister, times(2)).save(captor.capture()); assertTrue(captor.getAllValues().get(0).isDirectWMSIntegrationEnabled()); assertFalse(wmsInfo.getMetadata().containsKey(GWCInitializer.WMS_INTEGRATION_ENABLED_KEY)); verify(geoServer).save(same(wmsInfo)); }
CoverageInfo rebuilt = null; if (metadata != null && metadata.containsKey(CoverageView.COVERAGE_VIEW)) { GridCoverage2DReader reader = (GridCoverage2DReader)
/** * Extracts the NetCDF encoding settings from the coverage identifier * * @param coverageId * @return */ static NetCDFLayerSettingsContainer getSettings(String coverageId) { GeoServer geoserver = GeoServerExtensions.bean(GeoServer.class); MetadataMap map = null; if (geoserver != null) { Catalog gsCatalog = geoserver.getCatalog(); LayerInfo info = NCNameResourceCodec.getCoverage(gsCatalog, coverageId); if (info != null) { map = info.getResource().getMetadata(); } } if (map != null && !map.isEmpty() && map.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)) { NetCDFLayerSettingsContainer settings = (NetCDFLayerSettingsContainer) map.get( NetCDFSettingsContainer.NETCDFOUT_KEY, NetCDFLayerSettingsContainer.class); return settings; } return null; } }
@Before public void setUpInternal() throws Exception { // Creatign models LayerInfo layerInfo = getCatalog().getLayerByName(getLayerId(MockData.TASMANIA_DEM)); layerModel = new Model<LayerInfo>(layerInfo); ResourceInfo resource = layerInfo.getResource(); resourceModel = new Model<CoverageInfo>((CoverageInfo) resource); // Add Element to MetadataMap MetadataMap metadata = resource.getMetadata(); if (!metadata.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)) { metadata.put(NetCDFSettingsContainer.NETCDFOUT_KEY, new NetCDFLayerSettingsContainer()); } }
@Before public void setUpInternal() throws Exception { // Creatign models LayerInfo layerInfo = getCatalog().getLayerByName(getLayerId(MockData.TASMANIA_DEM)); layerModel = new Model<LayerInfo>(layerInfo); ResourceInfo resource = layerInfo.getResource(); resourceModel = new Model<ResourceInfo>(resource); // Add Element to MetadataMap MetadataMap metadata = resource.getMetadata(); if (!metadata.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)) { metadata.put(NetCDFSettingsContainer.NETCDFOUT_KEY, new NetCDFLayerSettingsContainer()); } }
@SuppressWarnings("rawtypes") @Override public FeatureReader read(ImportData data, ImportTask task) throws IOException { File file = getFileFromData(data); // we need to get the feature type, to use for the particular parse through the file // since we put it on the metadata from the list method, we first check if that's still available SimpleFeatureType ft = (SimpleFeatureType) task.getMetadata().get(FeatureType.class); if (ft == null) { // if the type is not available, we can generate one from the resource // we aren't able to ask for the feature type from the resource directly, // because we don't have a backing store FeatureTypeInfo fti = (FeatureTypeInfo) task.getLayer().getResource(); SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName(fti.getName()); List<AttributeTypeInfo> attributes = fti.getAttributes(); for (AttributeTypeInfo attr : attributes) { ftb.add(attr.getName(), attr.getBinding()); } ft = ftb.buildFeatureType(); MetadataMap metadata = fti.getMetadata(); if (metadata.containsKey("importschemanames")) { Map<Object, Object> userData = ft.getUserData(); userData.put("schemanames", metadata.get("importschemanames")); } } return read(ft, file); }
public static GeoServerTileLayerInfoImpl load(final LayerInfo layer) { MetadataMap metadataMap = layer.getMetadata(); if (!hasTileLayerDef(metadataMap)) { return null; } GeoServerTileLayerInfoImpl tileLayerInfo = load(metadataMap); if (metadataMap.containsKey(CONFIG_KEY_CACHED_STYLES)) { final String defaultStyle = layer.getDefaultStyle() == null ? "" : layer .getDefaultStyle().getName(); String cachedStylesStr = metadataMap.get(CONFIG_KEY_CACHED_STYLES, String.class); Set<String> cachedStyles = unmarshalSet(cachedStylesStr); TileLayerInfoUtil.setCachedStyles(tileLayerInfo, defaultStyle, cachedStyles); } else if (tileLayerInfo.isAutoCacheStyles()) { if (layer.getStyles() != null && layer.getStyles().size() > 0) { final String defaultStyle = layer.getDefaultStyle() == null ? "" : layer .getDefaultStyle().getName(); Set<String> cachedStyles = new HashSet<String>(); for (StyleInfo style : layer.getStyles()) { cachedStyles.add(style.getName()); } TileLayerInfoUtil.setCachedStyles(tileLayerInfo, defaultStyle, cachedStyles); } } tileLayerInfo.setName(tileLayerName(layer)); tileLayerInfo.setId(layer.getId()); return tileLayerInfo; }
public static GeoServerTileLayerInfoImpl load(final LayerInfo layer) { MetadataMap metadataMap = layer.getMetadata(); if (!hasTileLayerDef(metadataMap)) { return null; } GeoServerTileLayerInfoImpl tileLayerInfo = load(metadataMap); if (metadataMap.containsKey(CONFIG_KEY_CACHED_STYLES)) { final String defaultStyle = layer.getDefaultStyle() == null ? "" : layer.getDefaultStyle().prefixedName(); String cachedStylesStr = metadataMap.get(CONFIG_KEY_CACHED_STYLES, String.class); Set<String> cachedStyles = unmarshalSet(cachedStylesStr); TileLayerInfoUtil.setCachedStyles(tileLayerInfo, defaultStyle, cachedStyles); } TileLayerInfoUtil.checkAutomaticStyles(layer, tileLayerInfo); tileLayerInfo.setName(tileLayerName(layer)); tileLayerInfo.setId(layer.getId()); return tileLayerInfo; }
@Test public void testTimeMosaicAuto() throws Exception { Mosaic m = new Mosaic(unpack("mosaic/bm_time.zip")); m.setTimeMode(TimeMode.AUTO); ImportContext context = importer.createContext(m); assertEquals(1, context.getTasks().size()); importer.run(context); LayerInfo l = context.getTasks().get(0).getLayer(); ResourceInfo r = l.getResource(); assertTrue(r.getMetadata().containsKey("time")); DimensionInfo d = (DimensionInfo) r.getMetadata().get("time"); assertNotNull(d); runChecks(l.getName()); Document dom = getAsDOM( String.format( "/%s/%s/wms?request=getcapabilities", r.getStore().getWorkspace().getName(), l.getName())); XMLAssert.assertXpathExists( "//wms:Layer[wms:Name = '" + m.getName() + "']/wms:Dimension[@name = 'time']", dom); }
@Test public void testTimeMosaic() throws Exception { Mosaic m = new Mosaic(unpack("mosaic/bm_time.zip")); m.setTimeMode(TimeMode.FILENAME); FilenameTimeHandler th = (FilenameTimeHandler) m.getTimeHandler(); th.setFilenameRegex("(\\d){6}"); th.setTimeFormat("yyyyMM"); ImportContext context = importer.createContext(m); assertEquals(1, context.getTasks().size()); importer.run(context); LayerInfo l = context.getTasks().get(0).getLayer(); ResourceInfo r = l.getResource(); assertTrue(r.getMetadata().containsKey("time")); DimensionInfo d = (DimensionInfo) r.getMetadata().get("time"); assertNotNull(d); runChecks(l.getName()); Document dom = getAsDOM( String.format( "/%s/%s/wms?request=getcapabilities", r.getStore().getWorkspace().getName(), l.getName())); XMLAssert.assertXpathExists( "//wms:Layer[wms:Name = '" + m.getName() + "']/wms:Dimension[@name = 'time']", dom); }