/** * Create a {@value #TYPE} datastore encoder from a store read from server. * * @param store The existing store. * @throws IllegalArgumentException if store type or mandatory parameters are not valid */ GSAbstractDatastoreEncoder(RESTDataStore store) { this(store.getName()); // Match datastore type ensureValidType(store.getStoreType()); // Copy store parameters setDescription(store.getDescription()); setEnabled(store.isEnabled()); // Copy connection parameters - bulk Map<String, String> params = store.getConnectionParameters(); for (String key : params.keySet()) { connectionParameters.set(key, params.get(key)); } }
public static RESTDataStore build(String xml) { if (xml == null) { return null; } Element e = JDOMBuilder.buildElement(xml); if (e != null) { return new RESTDataStore(e); } else { return null; } }
public DBType getType() { return DBType.get(getConnectionParameter("dbtype")); } }
@CliCommand(value = "datastore get", help = "Get a data store.") public String get( @CliOption(key = "workspace", mandatory = true, help = "The workspace") String workspace, @CliOption(key = "name", mandatory = true, help = "The name") String name ) throws Exception { GeoServerRESTReader reader = new GeoServerRESTReader(geoserver.getUrl(), geoserver.getUser(), geoserver.getPassword()); RESTDataStore dataStore = reader.getDatastore(workspace, name); final String TAB = " "; StringBuilder builder = new StringBuilder(); builder.append(dataStore.getName()).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Enabled? ").append(dataStore.isEnabled()).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Description: ").append(dataStore.getDescription()).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Store Type: ").append(dataStore.getStoreType()).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Type: ").append(dataStore.getType()).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Workspace: ").append(dataStore.getWorkspaceName()).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Connection Parameters:").append(OsUtils.LINE_SEPARATOR); Map<String, String> params = dataStore.getConnectionParameters(); List<Map.Entry<String, String>> connectionParamList = new LinkedList<Map.Entry<String, String>>(params.entrySet()); Collections.sort(connectionParamList, new Comparator<Map.Entry<String,String>>() { @Override public int compare( Map.Entry<String,String> o1, Map.Entry<String,String> o2 ) { return (o1.getKey()).compareTo( o2.getKey()); } }); for (Map.Entry<String, String> param : connectionParamList) { builder.append(TAB).append(TAB).append(param.getKey()).append(": ").append(param.getValue()).append(OsUtils.LINE_SEPARATOR); } return builder.toString(); }
/** * Create an {@value #TYPE} datastore encoder from an existing store read from server. * * @param store The existing store. * @throws IllegalArgumentException if store type or mandatory parameters are not valid */ public GSArcSDEDatastoreEncoder(RESTDataStore store) { super(store); // Check mandatory parameter validity ensureValidServer(store.getConnectionParameters().get("server")); ensureValidUser(store.getConnectionParameters().get("user")); }
/** * Get detailed info about a given Datastore in a given Workspace. * * @param workspace The name of the workspace * @param dsName The name of the Datastore * @return DataStore details as a {@link RESTDataStore} */ public RESTDataStore getDatastore(String workspace, String dsName) { String url = "/rest/workspaces/" + workspace + "/datastores/" + dsName + ".xml"; if (LOGGER.isDebugEnabled()) { LOGGER.debug("### Retrieving DS from " + url); } String response = load(url); // System.out.println("DATASTORE " + workspace+":"+dsName+"\n"+response); return RESTDataStore.build(response); }
/** * Create an {@value #TYPE} datastore encoder from an existing store read from server. * * @param store The existing store. * @throws IllegalArgumentException if store type or mandatory parameters are not valid */ public GSOracleNGDatastoreEncoder(RESTDataStore store) { super(store); // Check mandatory parameter validity ensureValidDatabase(store.getConnectionParameters().get("database")); }
/** * Get detailed info about a FeatureType's Datastore. * * @param featureType the RESTFeatureType * @return DataStore details as a {@link RESTDataStore} */ public RESTDataStore getDatastore(RESTFeatureType featureType) { String url = featureType.getStoreUrl(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("### Retrieving DS from fullurl " + url); } String response = loadFullURL(url); return RESTDataStore.build(response); }
/** * Create a {@value #TYPE} datastore encoder from an existing store read from server. * * @param store The existing store. * @throws IllegalArgumentException if store type or mandatory parameters are not valid */ public GSShapefileDatastoreEncoder(RESTDataStore store) { super(store); // Check mandatory parameter validity try { ensureValidURL(new URL(store.getConnectionParameters().get("url"))); } catch (MalformedURLException e) { throw new IllegalArgumentException("Shapefile store URL is malformed", e); } }