public void removeRepositoryFromOrganizationalUnit( final String jobId,
final String organizationalUnitName,
final String repositoryName ) {
logger.info( "-----JobRequestHelper:removeRepositoryFromOrganizationalUnit--- , OrganizationalUnit name:" + organizationalUnitName + ", repository name:" + repositoryName );
JobResult result = new JobResult();
result.setJobId( jobId );
if ( organizationalUnitName == null || repositoryName == null ) {
result.setStatus( JobStatus.BAD_REQUEST );
result.setResult( "OrganizationalUnit name and Repository name must be provided" );
jobResultEvent.fire( result );
return;
}
org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repositoryName );
if ( repositoryPath == null ) {
result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
result.setResult( "Repository [" + repositoryName + "] does not exist" );
jobResultEvent.fire( result );
return;
}
OrganizationalUnit organizationalUnit = new OrganizationalUnitImpl( organizationalUnitName, null );
GitRepository repo = new GitRepository( repositoryName );
try {
organizationalUnitService.removeRepository( organizationalUnit,
repo );
} catch ( IllegalArgumentException e ) {
result.setStatus( JobStatus.BAD_REQUEST );
result.setResult( "OrganizationalUnit " + organizationalUnit.getName() + " not found" );
jobResultEvent.fire( result );
return;
}
result.setStatus( JobStatus.SUCCESS );
jobResultEvent.fire( result );
}