Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to Marvelution under one or more contributor license 
   * agreements.  See the NOTICE file distributed with this work 
   * for additional information regarding copyright ownership.
   * Marvelution licenses this file to you under the Apache License,
   * Version 2.0 (the "License"); you may not use this file except
   * in compliance with the License.
   * You may obtain a copy of the License at
   *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 
 package com.marvelution.bamboo.plugins.sonar.ww2.actions.admin.sonar;
 
 
 
 import  com.atlassian.bamboo.configuration.GlobalAdminAction;
 import  com.atlassian.bandana.BandanaManager;
WebAction to view all the configured Sonar Servers

Author(s):
Mark Rekveld
 
 public class ConfigureSonarServers extends GlobalAdminAction {
 
 	private static final long serialVersionUID = 1L;
 
 	public static final String ADD = "add";
 
 	public static final String EDIT = "edit";
 
 	private BandanaManager bandanaManager;
 
 
 	private BandanaUtils bandanaUtils = new BandanaUtils();
 
 	private String mode;

Constructor
 
 	public ConfigureSonarServers() {
 		 = new SonarServer();
 	}

 
 	public String doDefault() throws Exception {
 		return INPUT;
 	}

Add a SonarServer

Returns:
the view to show when the SonarServer is added
Throws:
Exception in case of errors when adding the server
 
 	public String doAdd() throws Exception {
 		return INPUT;
 	}

Create a SonarServer

Returns:
the view to show when the SonarServer is created
Throws:
Exception in case of errors when creating the server
 
 	public String doCreate() throws Exception {
 		return execute();
 	}

Edit a SonarServer

Returns:
the view to show when the SonarServer is added
Throws:
Exception in case of errors when adding the server
 
 	public String doEdit() throws Exception {
		if (getServerId() > 0) {
else {
			addActionError(getText("sonar.global.errors.no.server.id""update"));
		}
		return INPUT;
	}

Update a SonarServer

Returns:
the view to show when the SonarServer is updated
Throws:
Exception in case of errors when updating the server
	public String doUpdate() throws Exception {
		return execute();
	}

Delete a SonarServer

Returns:
the view to show when the SonarServer is deleted
Throws:
Exception in case of errors when deleting the server
	public String doDelete() throws Exception {
		if (getServerId() > 0) {
			addActionMessage(getText("sonar.global.messages.server.action""remove".getName()));
else {
			addActionError(getText("sonar.global.errors.no.server.id""remove"));
			return ERROR;
		}
		return SUCCESS;
	}

Enable a SonarServer

Returns:
the view to show when the SonarServer is enabled
Throws:
Exception in case of errors when enabling the server
	public String doEnable() throws Exception {
		if (getServerId() > 0) {
			addActionMessage(getText("sonar.global.messages.server.action""enable".getName()));
else {
			addActionError(getText("sonar.global.errors.no.server.id""enable"));
			return ERROR;
		}
		return SUCCESS;
	}

Disable a SonarServer

Returns:
the view to show when the SonarServer is disabled
Throws:
Exception in case of errors when disabling the server
	public String doDisable() throws Exception {
		if (getServerId() > 0) {
			addActionMessage(getText("sonar.global.messages.server.action""disable".getName()));
else {
			addActionError(getText("sonar.global.errors.no.server.id""disable"));
			return ERROR;
		}
		return SUCCESS;
	}

	public String execute() throws Exception {
		if (StringUtils.isNotBlank(getServerName())) {
				if (getServerName().equals(server.getName())
					&& getServerId() != server.getServerId()) {
					addFieldError("serverName"getText("sonar.server.name.no.duplicates"));
				}
			}
		}
		if (StringUtils.isBlank(getServerName())) {
			addFieldError("serverName"getText("sonar.server.name.required"));
		}
		if (StringUtils.isBlank(getServerHost())) {
			addFieldError("serverHost"getText("sonar.host.url.required"));
else {
			if (!getServerHost().startsWith("http://") && !getServerHost().startsWith("https://")) {
				addFieldError("serverHost"getText("sonar.host.url.invalid"));
			}
		}
			return ERROR;
else {
		}
		if (.equals()) {
			addActionMessage(getText("sonar.global.messages.server.action""updated".getName()));
else {
			addActionMessage(getText("sonar.global.messages.server.action""added".getName()));
		}
		return SUCCESS;
	}

Returns:
the mode
	public String getMode() {
		return ;
	}

Parameters:
mode the mode to set
	public void setMode(String mode) {
		this. = mode;
	}

Returns:
the serverId
	public int getServerId() {
	}

Parameters:
serverId the serverId to set
	public void setServerId(int serverId) {
	}

Returns:
the name
	public String getServerName() {
	}

Parameters:
serverName the name to set
	public void setServerName(String serverName) {
		.setName(serverName);
	}

Returns:
the serverDescription
	}

Parameters:
serverDescription the description to set
	public void setServerDescription(String serverDescription) {
		.setDescription(serverDescription);
	}

Returns:
the serverHost
	public String getServerHost() {
	}

Parameters:
serverHost the host to set
	public void setServerHost(String serverHost) {
		.setHost(serverHost);
	}

Returns:
the databaseUrl
	public String getDatabaseUrl() {
	}

Parameters:
databaseUrl the databaseUrl to set
	public void setDatabaseUrl(String databaseUrl) {
	}


Returns:
the databaseDriver
	}


Parameters:
databaseDriver the databaseDriver to set
	public void setDatabaseDriver(String databaseDriver) {
	}

Returns:
the databaseUsername
	}

Parameters:
databaseUsername the databaseUsername to set
	public void setDatabaseUsername(String databaseUsername) {
	}

Returns:
the databasePassword
	}

Parameters:
databasePassword the databasePassword to set
	public void setDatabasePassword(String databasePassword) {
	}

Returns:
the additionalArguments
	}

Parameters:
additionalArguments the additionalArguments to set
	public void setAdditionalArguments(String additionalArguments) {
		.setAdditionalArguments(additionalArguments);
	}

Returns:
the disabled
	public boolean isServerDisabled() {
	}

Parameters:
disabled the disabled to set
	public void setServerDisabled(boolean disabled) {
	}

Get the BandanaManager

Parameters:
bandanaManager the BandanaManager
	public void setBandanaManager(BandanaManager bandanaManager) {
		this. = bandanaManager;
	}

Get a list of the Sonar Servers configured

Returns:
the Collection of SonarServers
		Arrays.sort(servers);
		return Arrays.asList(servers);
	}
New to GrepCode? Check out our FAQ X