Search in sources :

Example 1 with SystemIntegrityViolationException

use of org.hudsonci.service.SystemIntegrityViolationException in project hudson-2.x by hudson.

the class ProjectServiceImpl method copyProject.

public <T extends AbstractProject<?, ?>> T copyProject(final T src, final String targetProjectName) throws ServiceRuntimeException {
    checkNotNull(src, AbstractProject.class);
    checkProjectName(targetProjectName);
    this.securityService.checkPermission(Item.CREATE);
    this.securityService.checkPermission(src, Item.EXTENDED_READ);
    // TODO should this check really be performed here?
    if (projectExists(targetProjectName)) {
        throw new SystemIntegrityViolationException(String.format("Project %s already exists.", targetProjectName));
    }
    try {
        return getHudson().copy(src, targetProjectName);
    } catch (IOException ex) {
        throw new ServiceRuntimeException(String.format("Project copy failed from %s to %s", src.getName(), targetProjectName), ex);
    }
}
Also used : SystemIntegrityViolationException(org.hudsonci.service.SystemIntegrityViolationException) IOException(java.io.IOException) ServiceRuntimeException(org.hudsonci.service.ServiceRuntimeException)

Example 2 with SystemIntegrityViolationException

use of org.hudsonci.service.SystemIntegrityViolationException in project hudson-2.x by hudson.

the class ProjectServiceImpl method createProjectFromXML.

public TopLevelItem createProjectFromXML(final String projectName, final InputStream xml) {
    checkProjectName(projectName);
    checkNotNull(xml, InputStream.class);
    this.securityService.checkPermission(Item.CREATE);
    // TODO should this check really be performed here?
    if (projectExists(projectName)) {
        throw new SystemIntegrityViolationException(String.format("Project %s already exists.", projectName));
    }
    try {
        return getHudson().createProjectFromXML(projectName, xml);
    } catch (IOException ex) {
        throw new ServiceRuntimeException(String.format("Project creation failed for %s", projectName), ex);
    }
}
Also used : SystemIntegrityViolationException(org.hudsonci.service.SystemIntegrityViolationException) IOException(java.io.IOException) ServiceRuntimeException(org.hudsonci.service.ServiceRuntimeException)

Aggregations

IOException (java.io.IOException)2 ServiceRuntimeException (org.hudsonci.service.ServiceRuntimeException)2 SystemIntegrityViolationException (org.hudsonci.service.SystemIntegrityViolationException)2