Package org.vfny.geoserver.form.global

Examples of org.vfny.geoserver.form.global.GeoServerConfigurationForm


public class GeoServerConfigurationSubmit extends ConfigAction {
    public ActionForward execute(ActionMapping mapping,
            ActionForm incomingForm, UserContainer user, HttpServletRequest request,
            HttpServletResponse response) {
       
        GeoServerConfigurationForm form = (GeoServerConfigurationForm) incomingForm;
        int maxFeatures = form.getMaxFeatures();
       
        boolean verbose = form.isVerbose();
        if (form.isVerboseChecked() == false) {
             verbose = false;
        }
       
        int numDecimals = form.getNumDecimals();
        String stringCharset = form.getCharset();
  Charset charset;
  try {
      charset = Charset.forName(stringCharset);
  } catch (IllegalArgumentException uce) {
      ActionErrors errors = new ActionErrors();
      errors.add(ActionErrors.GLOBAL_ERROR,
           new ActionError("error.badCharSet"));
      saveErrors(request, errors);
      return mapping.findForward("config.server");
  }
        String baseURL = form.getBaseURL();
        String schemaBaseURL = form.getSchemaBaseURL();
        String stringLevel = form.getLoggingLevel();
        Level loggingLevel = Level.parse(stringLevel);
        String adminUserName = form.getAdminUserName();
        String adminPassword = form.getAdminPassword();
        boolean verboseExceptions = form.isVerboseExceptions();
    if (form.isVerboseExceptionsChecked() == false) {
      verboseExceptions = false;
    }
   
    boolean loggingToFile = form.isLoggingToFile();
    if (!form.isLoggingToFileChecked()) {
      loggingToFile = false;
    }
   
    String logLocation = form.getLogLocation();
    if (logLocation != null && "".equals(logLocation.trim()))
      logLocation = null;
   
    if (logLocation != null) {
      File f = null;
      try {
        f = GeoServer.getLogLocation(logLocation,getServlet().getServletContext());
      }
      catch (IOException e) {
        ActionErrors errors = new ActionErrors();
        ActionError error = new ActionError("error.couldNotCreateFile",f.getAbsolutePath(),e.getLocalizedMessage());
        errors.add(ActionErrors.GLOBAL_ERROR, error);
          saveErrors(request, errors);
          return mapping.findForward("config.server");
      }
     
      if (!f.canWrite()) {
        ActionErrors errors = new ActionErrors();
          errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.noWritePermission",logLocation));
          saveErrors(request, errors);
          return mapping.findForward("config.server");
      }
    }
   
    GlobalConfig globalConfig = getGlobalConfig();
        globalConfig.setMaxFeatures(maxFeatures);
        globalConfig.setVerbose(verbose);
        globalConfig.setNumDecimals(numDecimals);
        globalConfig.setBaseUrl(baseURL);
        globalConfig.setSchemaBaseUrl(schemaBaseURL);
        globalConfig.setCharSet(charset);
        globalConfig.setAdminUserName(adminUserName);
        globalConfig.setAdminPassword(adminPassword);
        globalConfig.setLoggingLevel(loggingLevel);
        globalConfig.setLoggingToFile(loggingToFile);
        globalConfig.setLogLocation(logLocation);
        globalConfig.setVerboseExceptions(verboseExceptions);
       
        ContactConfig contactConfig = globalConfig.getContact();
        contactConfig.setContactPerson( form.getContactPerson() );
        contactConfig.setContactOrganization( form.getContactOrganization() );
        contactConfig.setContactPosition( form.getContactPosition() );
        contactConfig.setAddressType( form.getAddressType() );
        contactConfig.setAddress( form.getAddress() );
        contactConfig.setAddressCity( form.getAddressCity() );
        contactConfig.setAddressCountry( form.getAddressCountry() );
        contactConfig.setAddressPostalCode( form.getAddressPostalCode() );
        contactConfig.setAddressState( form.getAddressState() );
        contactConfig.setContactVoice( form.getContactVoice() );
        contactConfig.setContactFacsimile( form.getContactFacsimile() );
        contactConfig.setContactEmail( form.getContactEmail() );
        globalConfig.setContact(contactConfig);
        getApplicationState().notifyConfigChanged();
       
       
        getServlet().getServletContext().setAttribute(GlobalConfig.CONFIG_KEY, globalConfig);
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.form.global.GeoServerConfigurationForm

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.