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

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

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

import java.util.ArrayList;
import java.util.List;
import java.util.LinkedList;

import com.greenpepper.server.GreenPepperServerException;
import com.greenpepper.server.domain.Project;
import com.greenpepper.server.domain.Repository;
import com.greenpepper.server.domain.RepositoryType;
import com.greenpepper.server.domain.component.ContentType;
import com.greenpepper.confluence.velocity.ConfluenceGreenPepper;

/**
 * 

FileSystemRegistration class.

* * @author oaouattara * @version $Id: $Id */ @SuppressWarnings("serial") public class FileSystemRegistration extends GreenPepperServerAction { private static RepositoryType FILE = RepositoryType.newInstance("FILE"); private List fileRepositories; private Repository newRepository; private String repositoryUid; private String newName; private String newBaseTestUrl; private String newProjectName; private boolean editMode; private LinkedList projects; /** *

doGetFileSystemRegistration.

* * @return a {@link java.lang.String} object. */ public String doGetFileSystemRegistration() { if (!isServerReady()) { addActionError(ConfluenceGreenPepper.SERVER_NOCONFIGURATION); return SUCCESS; } try { setFileRepositories(getService().getAllSpecificationRepositories()); } catch (GreenPepperServerException e) { addActionError(e.getId()); } return SUCCESS; } /** *

doAddFileSystem.

* * @return a {@link java.lang.String} object. */ public String doAddFileSystem() { try { setFileRepositories(getService().getAllSpecificationRepositories()); if(!pathAlreadyExists()) { getNewRepository().setProject(Project.newInstance(newProjectName)); newRepository.setType(FILE); newRepository.setName(newName); newRepository.setContentType(ContentType.TEST); newRepository.setBaseUrl(newBaseTestUrl); newRepository.setBaseRepositoryUrl(newBaseTestUrl); newRepository.setBaseTestUrl(newBaseTestUrl); getService().registerRepository(newRepository); newRepository = null; } } catch (GreenPepperServerException e) { addActionError(e.getId()); } return doGetFileSystemRegistration(); } /** *

doRemoveFileSystem.

* * @return a {@link java.lang.String} object. */ public String doRemoveFileSystem() { try { getService().removeRepository(repositoryUid); } catch (GreenPepperServerException e) { addActionError(e.getId()); } return doGetFileSystemRegistration(); } /** *

Getter for the field fileRepositories.

* * @return a {@link java.util.List} object. */ public List getFileRepositories() { if(fileRepositories != null) { try { setFileRepositories(getService().getAllSpecificationRepositories()); } catch (GreenPepperServerException e) { addActionError(e.getId()); } } return fileRepositories; } /** *

Setter for the field fileRepositories.

* * @param repositories a {@link java.util.List} object. */ public void setFileRepositories(List repositories) { fileRepositories = new ArrayList(); for(Repository repository : repositories) if(repository.getType().equals(FILE)) fileRepositories.add(repository); } /** *

Getter for the field repositoryUid.

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

Setter for the field repositoryUid.

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

isEditMode.

* * @return a boolean. */ public boolean isEditMode() { return editMode; } /** *

Setter for the field editMode.

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

Getter for the field newBaseTestUrl.

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

Setter for the field newBaseTestUrl.

* * @param newBaseTestUrl a {@link java.lang.String} object. */ public void setNewBaseTestUrl(String newBaseTestUrl) { newBaseTestUrl = newBaseTestUrl.trim(); if(!newBaseTestUrl.endsWith("/")) newBaseTestUrl += "/"; this.newBaseTestUrl = newBaseTestUrl; } /** *

Getter for the field newName.

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

Setter for the field newName.

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

getProjectName.

* * @return a {@link java.lang.String} object. */ public String getProjectName() { return newProjectName; } /** {@inheritDoc} */ public void setProjectName(String projectName) { this.newProjectName = projectName; } /** *

Getter for the field newRepository.

* * @return a {@link com.greenpepper.server.domain.Repository} object. */ public Repository getNewRepository() { if(newRepository != null) return newRepository; String uid = gpUtil.getSettingsManager().getGlobalSettings().getSiteTitle() + "-" + getProjectName() + "-F"+fileRepositories.size(); newRepository = Repository.newInstance(uid); return newRepository; } private boolean pathAlreadyExists() throws GreenPepperServerException { if(fileRepositories == null) { setFileRepositories(getService().getAllSpecificationRepositories()); } for(Repository repo : fileRepositories) { if(repo.getBaseTestUrl().equals(newBaseTestUrl)) { return true; } } return false; } /** *

Getter for the field projects.

* * @return a {@link java.util.LinkedList} object. */ @SuppressWarnings("unchecked") public LinkedList getProjects() { if(projects != null) return projects; try { projects = new LinkedList(getService().getAllProjects()); } catch (GreenPepperServerException e) { addActionError(e.getId()); } return projects; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy