All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.greenpepper.confluence.actions.server.ConfigurationAction Maven / Gradle / Ivy

There is a newer version: 4.2.4
Show newest version
package com.greenpepper.confluence.actions.server;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.atlassian.confluence.spaces.Space;
import com.atlassian.confluence.spaces.SpaceType;
import com.atlassian.confluence.spaces.SpacesQuery;
import com.atlassian.confluence.spaces.SpacesQuery.Builder;
import com.greenpepper.confluence.velocity.ConfluenceGreenPepper;
import com.greenpepper.server.GreenPepperServerException;
import com.greenpepper.server.domain.ClasspathSet;
import com.greenpepper.server.domain.EnvironmentType;
import com.greenpepper.server.domain.Runner;
import com.greenpepper.util.StringUtil;

/**
 * Action for the GreenPepper Server Properties.
 * 

* Copyright (c) 2006 Pyxis technologies inc. All Rights Reserved. * * @author JCHUET * @version $Id: $Id */ @SuppressWarnings("serial") public class ConfigurationAction extends GreenPepperServerAction { private static final String NONE_SELECTED = null; private List runners; private List envTypes; private Runner selectedRunner; private String selectedRunnerName; private String classpath; private String newRunnerName = ""; private String newCmdLineTemplate = ""; private String newMainClass; private String newServerName; private String newServerPort; private String newEnvType = ""; private boolean secured; private boolean addMode; private boolean editPropertiesMode; private boolean editClasspathsMode; /** *

getSpaces.

* * @return a {@link java.util.List} object. */ public List getSpaces() { Builder newQueryBuilder = SpacesQuery.newQuery(); newQueryBuilder.withSpaceType(SpaceType.GLOBAL); SpacesQuery globalSpaceQuery = newQueryBuilder.build(); return gpUtil.getSpaceManager().getAllSpaces(globalSpaceQuery); } /** *

getConfiguration.

* * @return a {@link java.lang.String} object. */ public String getConfiguration() { if (isServerReady()) doGetRunners(); return SUCCESS; } /** *

testConnection.

* * @return a {@link java.lang.String} object. */ public String testConnection() { return SUCCESS; } /** *

updateConfiguration.

* * @return a {@link java.lang.String} object. */ public String updateConfiguration() { if(isServerReady()) doGetRunners(); return SUCCESS; } /** *

verifyServerReady.

* * @return a {@link java.lang.String} object. */ public String verifyServerReady() { if (!isServerReady()) { addActionError(ConfluenceGreenPepper.SERVER_NOCONFIGURATION); } return SUCCESS; } /** *

doGetRunners.

* * @return a {@link java.lang.String} object. */ public String doGetRunners() { if (!isServerReady()) { addActionError(ConfluenceGreenPepper.SERVER_NOCONFIGURATION); return SUCCESS; } try { envTypes = getService().getAllEnvironmentTypes(); runners = getService().getAllRunners(); if(!StringUtil.isEmpty(selectedRunnerName)) { for(Runner runner : runners) { if(runner.getName().equals(selectedRunnerName)) { selectedRunner = runner; return SUCCESS; } } } editPropertiesMode = false; editClasspathsMode = false; selectedRunnerName = NONE_SELECTED; } catch (GreenPepperServerException e) { addActionError(e.getId()); } return SUCCESS; } /** *

doAddRunner.

* * @return a {@link java.lang.String} object. */ public String doAddRunner() { try { selectedRunner = Runner.newInstance(newRunnerName); selectedRunner.setCmdLineTemplate(newCmdLineTemplate); selectedRunner.setMainClass(newMainClass); selectedRunner.setServerName(newServerName); selectedRunner.setServerPort(newServerPort); selectedRunner.setEnvironmentType(EnvironmentType.newInstance(newEnvType)); selectedRunner.setSecured(secured); getService().createRunner(selectedRunner); successfullAction(); } catch (GreenPepperServerException e) { addActionError(e.getId()); } return doGetRunners(); } /** *

doUpdateRunner.

* * @return a {@link java.lang.String} object. */ public String doUpdateRunner() { try { selectedRunner = getService().getRunner(selectedRunnerName); selectedRunner.setName(newRunnerName); selectedRunner.setCmdLineTemplate(newCmdLineTemplate); selectedRunner.setMainClass(newMainClass); selectedRunner.setServerName(newServerName); selectedRunner.setServerPort(newServerPort); selectedRunner.setEnvironmentType(EnvironmentType.newInstance(newEnvType)); selectedRunner.setSecured(secured); getService().updateRunner(selectedRunnerName, selectedRunner); successfullAction(); return doGetRunners(); } catch (GreenPepperServerException e) { try { runners = getService().getAllRunners(); selectedRunner.setName(selectedRunnerName); } catch (GreenPepperServerException e1) { addActionError(e.getId()); } addActionError(e.getId()); } return SUCCESS; } /** *

doRemoveRunner.

* * @return a {@link java.lang.String} object. */ public String doRemoveRunner() { try { getService().removeRunner(selectedRunnerName); } catch (GreenPepperServerException e) { addActionError(e.getId()); } return doGetRunners(); } /** *

doEditClasspath.

* * @return a {@link java.lang.String} object. */ public String doEditClasspath() { try { selectedRunner = getService().getRunner(selectedRunnerName); selectedRunner.setClasspaths(ClasspathSet.parse(classpath)); getService().updateRunner(selectedRunnerName, selectedRunner); } catch (GreenPepperServerException e) { addActionError(e.getId()); } return doGetRunners(); } /** *

getClasspaths.

* * @return a {@link java.util.Set} object. */ public Set getClasspaths() { Set classpaths = selectedRunner.getClasspaths(); return classpaths == null ? new HashSet() : classpaths; } /** *

getClasspathsAsTextAreaContent.

* * @return a {@link java.lang.String} object. */ public String getClasspathsAsTextAreaContent() { StringBuilder sb = new StringBuilder(); for (String classpath : getClasspaths()) { sb.append(classpath); sb.append("\r"); } return sb.toString(); } /** *

getClasspathTitle.

* * @return a {@link java.lang.String} object. */ public String getClasspathTitle() { return getText("greenpepper.runners.classpath"); } /** *

Getter for the field runners.

* * @return a {@link java.util.List} object. */ public List getRunners() { return runners; } /** *

Getter for the field selectedRunnerName.

* * @return a {@link java.lang.String} object. */ public String getSelectedRunnerName() { return selectedRunnerName; } /** *

Setter for the field selectedRunnerName.

* * @param selectedRunnerName a {@link java.lang.String} object. */ public void setSelectedRunnerName(String selectedRunnerName) { this.selectedRunnerName = selectedRunnerName.equals("none") ? null : selectedRunnerName; } /** *

isAddMode.

* * @return a boolean. */ public boolean isAddMode() { return addMode; } /** *

Setter for the field addMode.

* * @param addMode a boolean. */ public void setAddMode(boolean addMode) { this.addMode = addMode; } /** *

isEditPropertiesMode.

* * @return a boolean. */ public boolean isEditPropertiesMode() { return editPropertiesMode; } /** *

Setter for the field editPropertiesMode.

* * @param editPropertiesMode a boolean. */ public void setEditPropertiesMode(boolean editPropertiesMode) { this.editPropertiesMode = editPropertiesMode; } /** *

isEditClasspathsMode.

* * @return a boolean. */ public boolean isEditClasspathsMode() { return editClasspathsMode; } /** *

Setter for the field editClasspathsMode.

* * @param editClasspathsMode a boolean. */ public void setEditClasspathsMode(boolean editClasspathsMode) { this.editClasspathsMode = editClasspathsMode; } /** *

Getter for the field selectedRunner.

* * @return a {@link com.greenpepper.server.domain.Runner} object. */ public Runner getSelectedRunner() { return selectedRunner; } /** *

Getter for the field classpath.

* * @return a {@link java.lang.String} object. */ public String getClasspath() { return classpath; } /** *

Setter for the field classpath.

* * @param classpath a {@link java.lang.String} object. */ public void setClasspath(String classpath) { this.classpath = classpath.trim(); } /** *

Getter for the field newMainClass.

* * @return a {@link java.lang.String} object. */ public String getNewMainClass() { return newMainClass; } /** *

Setter for the field newMainClass.

* * @param newMainClass a {@link java.lang.String} object. */ public void setNewMainClass(String newMainClass) { this.newMainClass = newMainClass.trim(); } /** *

Getter for the field newRunnerName.

* * @return a {@link java.lang.String} object. */ public String getNewRunnerName() { return newRunnerName; } /** *

Setter for the field newRunnerName.

* * @param newRunnerName a {@link java.lang.String} object. */ public void setNewRunnerName(String newRunnerName) { this.newRunnerName = newRunnerName.trim(); } /** *

Getter for the field newServerName.

* * @return a {@link java.lang.String} object. */ public String getNewServerName() { return newServerName; } /** *

Setter for the field newServerName.

* * @param newServerName a {@link java.lang.String} object. */ public void setNewServerName(String newServerName) { this.newServerName = newServerName.trim(); } /** *

Getter for the field newServerPort.

* * @return a {@link java.lang.String} object. */ public String getNewServerPort() { return newServerPort; } /** *

Setter for the field newServerPort.

* * @param newServerPort a {@link java.lang.String} object. */ public void setNewServerPort(String newServerPort) { this.newServerPort = newServerPort.trim(); } /** *

Getter for the field newEnvType.

* * @return a {@link java.lang.String} object. */ public String getNewEnvType() { return newEnvType; } /** *

Setter for the field newEnvType.

* * @param newEnvType a {@link java.lang.String} object. */ public void setNewEnvType(String newEnvType) { this.newEnvType = newEnvType; } /** *

Setter for the field runners.

* * @param runners a {@link java.util.List} object. */ public void setRunners(List runners) { this.runners = runners; } /** *

Getter for the field envTypes.

* * @return a {@link java.util.List} object. */ public List getEnvTypes() { return envTypes; } /** *

Setter for the field envTypes.

* * @param envTypes a {@link java.util.List} object. */ public void setEnvTypes(List envTypes) { this.envTypes = envTypes; } /** *

Getter for the field newCmdLineTemplate.

* * @return a {@link java.lang.String} object. */ public String getNewCmdLineTemplate() { return newCmdLineTemplate; } /** *

Setter for the field newCmdLineTemplate.

* * @param newCmdLineTemplate a {@link java.lang.String} object. */ public void setNewCmdLineTemplate(String newCmdLineTemplate) { this.newCmdLineTemplate = newCmdLineTemplate.trim(); } private void successfullAction() { addMode = false; editPropertiesMode = false; editClasspathsMode = false; secured = false; selectedRunnerName = newRunnerName; newRunnerName = ""; newServerName = ""; newServerPort = ""; newEnvType = ""; newCmdLineTemplate = ""; } /** *

isSecured.

* * @return a boolean. */ public boolean isSecured() { return secured; } /** *

Setter for the field secured.

* * @param secured a boolean. */ public void setSecured(boolean secured) { this.secured = secured; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy