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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations