Package org.vfny.geoserver.config

Examples of org.vfny.geoserver.config.DataConfig


        if(styleId.endsWith("*")){
          styleId = styleId.substring(0,styleId.lastIndexOf("*"));
        }
        Locale locale = (Locale) request.getLocale();
       
        DataConfig config = getDataConfig();
        MessageResources messages = servlet.getResources();       
        // Need locale wording for edit and delete
        final String EDIT = HTMLEncoder.decode(messages.getMessage(locale, "label.edit"));
        final String DELETE = HTMLEncoder.decode(messages.getMessage(locale, "label.delete"));
        final String DEFAULT = HTMLEncoder.decode(messages.getMessage(locale, "label.default"));
       
        StyleConfig style = config.getStyle( styleId );
        if( style == null ){
            ActionErrors errors = new ActionErrors();
            errors.add("selectedStyle",
                new ActionError("error.style.invalid", styleId ));           
            request.setAttribute(Globals.ERROR_KEY, errors);           
            return mapping.findForward("config.data.style");
        }
        // Something is selected lets do the requested action
        //
        if (action.equals(DELETE)) {
            config.removeStyle( styleId );
            getApplicationState().notifyConfigChanged();
            selectForm.setSelectedStyle(null);
            selectForm.reset(mapping, request);
            return mapping.findForward("config.data.style");
        }
        if (action.equals(DEFAULT)) {
          Map m = config.getStyles();
          Iterator i = m.values().iterator();
          while(i.hasNext()){
            StyleConfig sc = (StyleConfig)i.next();
            if(sc.isDefault()){
              if(sc.getId()!=null && !sc.getId().equals(styleId)){
View Full Code Here


            UserContainer user, HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
        StylesNewForm newForm = (StylesNewForm) form;
        final String styleID = newForm.getStyleID();
       
        DataConfig config = getDataConfig();
        if( config.getStyles().containsKey( styleID ) ){
            ActionErrors errors = new ActionErrors();
            errors.add("selectedStyle",
                new ActionError("error.style.exists", styleID ));           
            request.setAttribute(Globals.ERROR_KEY, errors);           
            return mapping.findForward("config.data.style.new");
        }
        // Set up new StyleConfig
        StyleConfig style = new StyleConfig();
        style.setId( styleID );
        style.setDefault( config.getStyles().isEmpty() );
       
        // Pass style over to the Editor
        user.setStyle( style );       
        return mapping.findForward("config.data.style.editor");
    }
View Full Code Here

    throws IOException, ServletException {
        DataNamespacesSelectForm namespacesForm = (DataNamespacesSelectForm) form;

        String action = namespacesForm.getAction();

        DataConfig dataConfig = (DataConfig) getDataConfig();
        NameSpaceConfig config = null;
       
        Locale locale = (Locale) request.getLocale();
        MessageResources messages = servlet.getResources();
       
        String edit = HTMLEncoder.decode(messages.getMessage(locale, "label.edit"));
        String delete = HTMLEncoder.decode(messages.getMessage(locale, "label.delete"));
        String _default = HTMLEncoder.decode(messages.getMessage(locale, "label.default"));

        String nsSelected = namespacesForm.getSelectedNamespace();
        if(nsSelected.endsWith("*")){
          nsSelected = nsSelected.substring(0,nsSelected.lastIndexOf("*"));
        }
        config = (NameSpaceConfig) dataConfig.getNameSpace(nsSelected);
        if(config==null){
          throw new NullPointerException();
        }
        getUserContainer(request).setNamespaceConfig(config);
       
        if (action.equals(delete))
        {
          if (dataStoresUseNamespace(dataConfig,nsSelected))
          {
            //dont delete a namespace thats in use!
                ActionErrors errors = new ActionErrors();
                  errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.namespace.namespaceInUse" ));           
                  request.setAttribute(Globals.ERROR_KEY, errors);
                  return mapping.findForward("config.data.namespace");
          }
            dataConfig.removeNameSpace(nsSelected);
            getApplicationState().notifyConfigChanged();
           
            getUserContainer(request).setNamespaceConfig(null);
            namespacesForm.reset(mapping, request);
            return mapping.findForward("config.data.namespace");
        }
        if (action.equals(_default)) {
          if(!nsSelected
              .equals(dataConfig.getDefaultNameSpace().getPrefix())){
            dataConfig.setDefaultNameSpace(dataConfig.getNameSpace(nsSelected));
            getApplicationState().notifyConfigChanged();
          }
           
            getUserContainer(request).setNamespaceConfig(null);
            namespacesForm.reset(mapping, request);
View Full Code Here

        DataNamespacesEditorForm namespacesForm = (DataNamespacesEditorForm) form;

        String URI = namespacesForm.getURI();
        String prefix = namespacesForm.getPrefix();

        DataConfig dataConfig = (DataConfig) getDataConfig();
        NameSpaceConfig config = null;
       
        config = getUserContainer(request).getNamespaceConfig();
       
        config.setPrefix(prefix);
        config.setUri(URI);

        dataConfig.addNameSpace(prefix, config);
        getApplicationState().notifyConfigChanged();

        return mapping.findForward("config.data.namespace");
    }
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");
        String deleteLabel = messages.getMessage(locale, "label.delete");

    if (editLabel.equals(buttonAction)) {
            dsConfig = (DataStoreConfig) dataConfig.getDataStore(form
                    .getSelectedDataStoreId());
          
            getUserContainer(request).setDataStoreConfig(dsConfig);

            return mapping.findForward("config.data.store.editor");
        } else if (deleteLabel.equals(buttonAction)) {
            dataConfig.removeDataStore(form.getSelectedDataStoreId());
            getUserContainer(request).setDataStoreConfig(null);

            form.reset(mapping, request);

            return mapping.findForward("config.data.store");
View Full Code Here

     * @throws ServletException DOCUMENT ME!
     */
    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());
View Full Code Here

    private FeatureType getFeatureType(TypesEditorForm form,
               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) {
View Full Code Here

    private ActionForward executeSubmit(ActionMapping mapping,
        TypesEditorForm form, UserContainer user, HttpServletRequest request) {
        FeatureTypeConfig config = user.getFeatureTypeConfig();
        sync(form, config, request);

        DataConfig dataConfig = (DataConfig) getDataConfig();
        dataConfig.addFeatureType(config.getDataStoreId() + ":"
            + config.getName(), config);

        // Don't think reset is needed (as me have moved on to new page)
        // form.reset(mapping, request);
        getApplicationState().notifyConfigChanged();
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();

        return mapping.findForward("config.data.store");
View Full Code Here

TOP

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

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.