Search in sources :

Example 1 with ServiceRuntimeException

use of org.hudsonci.service.ServiceRuntimeException 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 ServiceRuntimeException

use of org.hudsonci.service.ServiceRuntimeException 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)

Example 3 with ServiceRuntimeException

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

the class BuildServiceImpl method stopBuild.

public void stopBuild(final AbstractProject<?, ?> project, final int buildNumber) {
    AbstractBuild<?, ?> build = getBuild(project, buildNumber);
    log.debug("Stopping build: {} #{}", project.getName(), buildNumber);
    try {
        // Security: doStop eventually checks to see if the task owner has permission to abort the build
        build.doStop(DummyStaplerRequest.INSTANCE, DummyStaplerResponse.INSTANCE);
    } catch (IOException e) {
        throw new ServiceRuntimeException("Stop failed for " + project.getName() + " #" + buildNumber, e);
    } catch (ServletException e) {
        throw new ServiceRuntimeException("Stop failed for " + project.getName() + " #" + buildNumber, e);
    }
}
Also used : ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ServiceRuntimeException(org.hudsonci.service.ServiceRuntimeException)

Example 4 with ServiceRuntimeException

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

the class BuildServiceImpl method deleteBuild.

public void deleteBuild(final AbstractProject<?, ?> project, final int buildNumber) {
    AbstractBuild<?, ?> build = getBuild(project, buildNumber);
    this.security.checkPermission(build, Run.DELETE);
    log.debug("Deleting build: {} #{}", project.getName(), buildNumber);
    try {
        build.delete();
    } catch (IOException e) {
        throw new ServiceRuntimeException("Delete failed for build " + project.getName() + " #" + buildNumber, e);
    }
}
Also used : IOException(java.io.IOException) ServiceRuntimeException(org.hudsonci.service.ServiceRuntimeException)

Example 5 with ServiceRuntimeException

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

the class BuildServiceImpl method keepBuild.

public void keepBuild(final AbstractProject<?, ?> project, final int buildNumber, final boolean release) {
    AbstractBuild<?, ?> build = getBuild(project, buildNumber);
    this.security.checkPermission(build, Run.UPDATE);
    log.debug("{} build: {} #{}", $(release ? "Releasing" : "Keeping", project.getName(), buildNumber));
    try {
        build.keepLog(!release);
    } catch (IOException e) {
        throw new ServiceRuntimeException((release ? "Releasing failed for build #" : "Keeping failed for build ") + project.getName() + " #" + buildNumber);
    }
}
Also used : IOException(java.io.IOException) ServiceRuntimeException(org.hudsonci.service.ServiceRuntimeException)

Aggregations

ServiceRuntimeException (org.hudsonci.service.ServiceRuntimeException)6 IOException (java.io.IOException)5 SystemIntegrityViolationException (org.hudsonci.service.SystemIntegrityViolationException)2 RestartNotSupportedException (hudson.lifecycle.RestartNotSupportedException)1 ServletException (javax.servlet.ServletException)1