Examples of DataStoreFactorySpi


Examples of org.geotools.data.DataStoreFactorySpi

     * @return
     */
    public static DataStoreFactorySpi aquireFactory(Map params) {
        for (Iterator i = DataStoreFinder.getAvailableDataStores();
                i.hasNext();) {
            DataStoreFactorySpi factory = (DataStoreFactorySpi) i.next();

            if (factory.canProcess(params)) {
                return factory;
            }
        }

        return null;
View Full Code Here

Examples of org.geotools.data.DataStoreFactorySpi

     * @return
     */
    public static DataStoreFactorySpi aquireFactory(String displayName) {
        for (Iterator i = DataStoreFinder.getAvailableDataStores();
                i.hasNext();) {
            DataStoreFactorySpi factory = (DataStoreFactorySpi) i.next();

            if (factory.getDisplayName().equals(displayName)) {
                return factory;
            }

            if (factory.getClass().toString().equals(displayName)) {
                return factory;
            }
        }

        return null;
View Full Code Here

Examples of org.geotools.data.DataStoreFactorySpi

    public static List listDataStoresDescriptions() {
        List list = new ArrayList();

        for (Iterator i = DataStoreFinder.getAvailableDataStores();
                i.hasNext();) {
            DataStoreFactorySpi factory = (DataStoreFactorySpi) i.next();
            list.add(factory.getDisplayName());
        }

        return list;
    }
View Full Code Here

Examples of org.geotools.data.DataStoreFactorySpi

        Map connectionParams = new HashMap(); // values used for connection
        Map paramTexts = new HashMap(); // values as stored

        Map params = dataStoresForm.getParams();

        DataStoreFactorySpi factory = config.getFactory();
        Param[] info = factory.getParametersInfo();

        // Convert Params into the kind of Map we actually need
        //
        for (Iterator i = params.keySet().iterator(); i.hasNext();) {
            String key = (String) i.next();

            Param param = DataStoreUtils.find(info, key);

            if (param == null) {

                ActionErrors errors = new ActionErrors();
                errors.add(ActionErrors.GLOBAL_ERROR,
                    new ActionError("error.cannotProcessConnectionParams"));
                saveErrors(request, errors);

                return mapping.findForward("config.data.store.editor");
            }

            Object value;

            try {
                value = param.lookUp(params);
            } catch (IOException erp) {

                ActionErrors errors = new ActionErrors();
                errors.add(ActionErrors.GLOBAL_ERROR,
                    new ActionError("error.cannotProcessConnectionParams"));
                saveErrors(request, errors);

                return mapping.findForward("config.data.store.editor");
            }

            if (value != null) {
                connectionParams.put(key, value);

                String text = param.text(value);
                paramTexts.put(key, text);
            }
        }

        // put magic namespace into the mix
        // not sure if we want to do this, as we want the full namespace, not
  //the id.  But getParams in DataStore may override this - ch
        connectionParams.put("namespace", dataStoresForm.getNamespaceId());
        paramTexts.put("namespace", dataStoresForm.getNamespaceId());
       
        //dump("editor", connectionParams );
        //dump("texts ",paramTexts );       
        if (!factory.canProcess(connectionParams)) {
            // We could not use these params!
            //
            ActionErrors errors = new ActionErrors();
            errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("error.cannotProcessConnectionParams"));
            saveErrors(request, errors);

            return mapping.findForward("config.data.store.editor");
        }

        try {
      ServletContext sc = request.getSession().getServletContext();
      Map niceParams = DataStoreUtils.getParams(connectionParams, sc);
            DataStore victim = factory.createDataStore(niceParams);

            if (victim == null) {
                // We *really* could not use these params!
                //
   
View Full Code Here

Examples of org.geotools.data.DataStoreFactorySpi

        if (namespaceId.equals("")) {
          namespaceId = config.getDefaultNameSpace().getPrefix();
        }

        //Retrieve connection params
        DataStoreFactorySpi factory = dsConfig.getFactory();
        Param[] params = factory.getParametersInfo();

        paramKeys = new ArrayList(params.length);
        paramValues = new ArrayList(params.length);
        paramTypes = new ArrayList(params.length);
        paramHelp = new ArrayList(params.length);
View Full Code Here

Examples of org.geotools.data.DataStoreFactorySpi

        //
        UserContainer user = Requests.getUserContainer( request );
        DataStoreConfig dsConfig = user.getDataStoreConfig();
        //
        // dsConfig is the only way to get a factory
        DataStoreFactorySpi factory = dsConfig.getFactory();
        Param[] info = factory.getParametersInfo();

        Map connectionParams = new HashMap();

        // Convert Params into the kind of Map we actually need
        //
        for (int i = 0; i < paramKeys.size(); i++) {
            String key = (String) getParamKey(i);

            Param param = DataStoreUtils.find(info, key);

            if (param == null) {
                errors.add("paramValue[" + i + "]",
                    new ActionError("error.dataStoreEditor.param.missing", key,
                        factory.getDescription()));

                continue;
            }

            //special case check for url
            if (URL.class.equals(param.type)) {
              String value = getParamValue(i);
              if (value != null && !"".equals(value)) {
                URL url = null;
                try {
                  // if this does not throw an exception then cool
                  url = new URL(value);
                }
                catch(MalformedURLException e) {
                  //check for special case of file
                  try {
              if (new File(value).exists())  {
                new URL("file://" + value);
                setParamValues(i,"file://" + value);
              }
            }
                  catch (MalformedURLException e1) {
                    //let this paramter die later
            }
                }
               
              }
            }
           
            Object value;

            try {
                value = param.lookUp(getParams());
                if(value instanceof String)
                  value = param.parse((String)value);
            } catch (IOException erp) {
                errors.add("paramValue[" + i + "]",
                    new ActionError("error.dataStoreEditor.param.parse", key,
                        param.type, erp));

                continue;
            }catch(Throwable t){//thrown by param.parse()
                errors.add("paramValue[" + i + "]",
                        new ActionError("error.dataStoreEditor.param.parse", key,
                            param.type, t));

                    continue;
            }

            if ((value == null) && param.required) {
                errors.add("paramValue[" + i + "]",
                    new ActionError("error.dataStoreEditor.param.required", key));

                continue;
            }

            if (value != null) {
                connectionParams.put(key, value);
            }
        }

        // put magic namespace into the mix
        //
        //connectionParams.put("namespace", getNamespaceId());

        dump("form", connectionParams );
        // Factory will provide even more stringent checking
        //
        if (!factory.canProcess( connectionParams )) {
            errors.add("paramValue",
                new ActionError("error.datastoreEditor.validation"));
        }

        return errors;
View Full Code Here

Examples of org.geotools.data.DataStoreFactorySpi

       
        if ( factoryClassName == null ) {
            throw new RestletException( "Unsupported format: " + format, Status.CLIENT_ERROR_BAD_REQUEST );
        }
       
        DataStoreFactorySpi factory;
        try {
            Class factoryClass = Class.forName( factoryClassName );
            factory = (DataStoreFactorySpi) factoryClass.newInstance();
        }
        catch ( Exception e ) {
View Full Code Here

Examples of org.geotools.data.DataStoreFactorySpi

           
            //TODO: should check if the store actually supports charset
            if (charset != null && charset.length() > 0) {
                info.getConnectionParameters().put("charset", charset);
            }
            DataStoreFactorySpi targetFactory = factory;
            if (!targetDataStoreFormat.equals(sourceDataStoreFormat)) {
                //target is different, we need to create it
                targetFactory = lookupDataStoreFactory(targetDataStoreFormat);
                if (targetFactory == null) {
                    throw new RestletException( "Unable to create data store of type "
                        + targetDataStoreFormat, Status.CLIENT_ERROR_BAD_REQUEST );
                }
               
                autoCreateParameters(info, namespace, targetFactory);
                canRemoveFiles = true;
            }
            else {
                updateParameters(info, namespace, targetFactory, uploadedFile);
            }
           
            info.setType(targetFactory.getDisplayName());
        }
        else {
            LOGGER.info("Using existing datastore: " + datastore);
           
            // look up the target data store factory
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.