Package org.vfny.geoserver.config

Examples of org.vfny.geoserver.config.DataStoreConfig


          List stores =  dataConfig.getDataStoreIds();
         
          Iterator it = stores.iterator();
          while (it.hasNext())
          {
              DataStoreConfig dsc = dataConfig.getDataStore( (String) it.next() );
              if (dsc.getNameSpaceId().equals(nsSelected) )
                return true;             
          }
          return false;
  }
View Full Code Here


        DataDataStoresSelectForm form = (DataDataStoresSelectForm) incomingForm;

        String buttonAction = form.getButtonAction();

        DataConfig dataConfig = (DataConfig) getDataConfig();
        DataStoreConfig dsConfig = null;
       
        Locale locale = (Locale) request.getLocale();
        MessageResources messages = servlet.getResources();

        String editLabel = messages.getMessage(locale, "label.edit");
View Full Code Here

     */
    private ActionForward executeBBox(ActionMapping mapping,
        TypesEditorForm typeForm, UserContainer user, HttpServletRequest request)
        throws IOException, ServletException {
        DataConfig dataConfig = getDataConfig();
        DataStoreConfig dsConfig = dataConfig.getDataStore(typeForm
                .getDataStoreId());
        DataStore dataStore = dsConfig.findDataStore(request.getSession()
                                                            .getServletContext());
        FeatureType featureType = dataStore.getSchema(typeForm.getTypeName());
        FeatureSource fs = dataStore.getFeatureSource(featureType.getTypeName());
       
        LOGGER.fine("calculating bbox for their dataset" );
View Full Code Here

               HttpServletRequest request) {
  FeatureType featureType = null;

        try {
            DataConfig config = ConfigRequests.getDataConfig(request);
            DataStoreConfig dataStoreConfig = config.getDataStore(form
                    .getDataStoreId());
            DataStore dataStore = dataStoreConfig.findDataStore(getServlet()
                                                                    .getServletContext());
            featureType = dataStore.getSchema(form.getTypeName());
        } catch (IOException e) {
            // DataStore unavailable!
        }
View Full Code Here

        return keywords;
    }

    DataStore aquireDataStore(String dataStoreID) throws IOException {
        DataConfig dataConfig = getDataConfig();
        DataStoreConfig dataStoreConfig = dataConfig.getDataStore(dataStoreID);

        Map params = dataStoreConfig.getConnectionParams();

        return DataStoreFinder.getDataStore(params);
    }
View Full Code Here

        String dataStoreID = dataStoresForm.getDataStoreId();
        String namespace = dataStoresForm.getNamespaceId();
        String description = dataStoresForm.getDescription();

        DataConfig dataConfig = (DataConfig) getDataConfig();
        DataStoreConfig config = null;

        config = (DataStoreConfig) dataConfig.getDataStore(dataStoreID);

        if( config == null ) {
          // we are creating a new one.
            dataConfig.addDataStore(getUserContainer(request).getDataStoreConfig());
            config = (DataStoreConfig) dataConfig.getDataStore(dataStoreID);           
        }
       
        // After extracting params into a map
        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!
                //
   
                ActionErrors errors = new ActionErrors();
                errors.add(ActionErrors.GLOBAL_ERROR,
                    new ActionError("error.invalidConnectionParams"));
                saveErrors(request, errors);

                return mapping.findForward("config.data.store.editor");
            }
            String typeNames[] = victim.getTypeNames();
            dump( "typeNames", typeNames );
        } catch (Throwable throwable) {
            throwable.printStackTrace();

            ActionErrors errors = new ActionErrors();
            errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("error.exception", throwable.getMessage()));

            saveErrors(request, errors);

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

        boolean enabled = dataStoresForm.isEnabled();

        if (dataStoresForm.isEnabledChecked() == false) {
            enabled = false;
        }

        config.setEnabled(enabled);
        config.setNameSpaceId(namespace);
        config.setAbstract(description);
        config.setConnectionParams(paramTexts);

        dataConfig.addDataStore(config);

        getUserContainer(request).setDataStoreConfig(null);
        getApplicationState().notifyConfigChanged();
View Full Code Here

        ServletContext context = getServlet().getServletContext();
        DataConfig config = (DataConfig) context.getAttribute(DataConfig.CONFIG_KEY);

        namespaces = new TreeSet(config.getNameSpaces().keySet());

        DataStoreConfig dsConfig = Requests.getUserContainer(request).getDataStoreConfig();

        if (dsConfig == null) {
            // something is horribly wrong no DataStoreID selected!
            // The JSP needs to not include us if there is no
            // selected DataStore
            //
            throw new RuntimeException(
                "selectedDataStoreId required in Session");
        }

        dataStoreId = dsConfig.getId();
        description = dsConfig.getAbstract();
        enabled = dsConfig.isEnabled();
        namespaceId = dsConfig.getNameSpaceId();
        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);
        paramRequired = new ArrayList(params.length);

        for (int i = 0; i < params.length; i++) {
            Param param = params[i];
            String key = param.key;

            if ("namespace".equals(key)) {
                // skip namespace as it is *magic* and
                // appears to be an entry used in all datastores?
                //
                continue;
            }

            Object value = dsConfig.getConnectionParams().get(key);
            String text;

            if (value == null) {
                text = null;
            } else if (value instanceof String) {
View Full Code Here

        ActionErrors errors = new ActionErrors();
       
        // Selected DataStoreConfig is in session
        //
        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
View Full Code Here

        System.out.println("rest based on schemaBase: " + type.getSchemaBase());

        // Generate ReadOnly list of Attributes
        //
        DataStoreConfig dataStoreConfig = config.getDataStore(dataStoreId);
        FeatureType featureType = null;

        try {
            DataStore dataStore = dataStoreConfig.findDataStore(getServlet()
                                                                    .getServletContext());
            featureType = dataStore.getSchema(typeName);
        } catch (IOException e) {
            // DataStore unavailable!
        }
View Full Code Here

    //TODO: we only get one datastore here when we may need more than that
    // do another pass through it and get those typesNames
        while (i.hasNext()) {
            Map sources = new HashMap();
            String key = i.next().toString();
            DataStoreConfig dsc = (DataStoreConfig) dsm.get(key);
            try {
              DataStore ds = dsc.findDataStore(sc);
              String[] ss = ds.getTypeNames();
              for (int j = 0; j < ss.length; j++) {
                    FeatureSource fs = ds.getFeatureSource(ss[j]);
                    sources.put(dsc.getId() +":"+ss[j], fs);

                    //v.runFeatureTests(dsc.getId(),fs.getSchema(),
                    //    fs.getFeatures().collection(), (ValidationResults) vr);
                    System.out.println("Feature Test Results for " + key + ":"
                        + ss[j]);
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.config.DataStoreConfig

Copyright © 2018 www.massapicom. 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.