use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class SchedulerClient method getJobResult.
@Override
public JobResult getJobResult(String jobId) throws NotConnectedException, PermissionException, UnknownJobException {
JobResult jobResult = null;
try {
JobResultData jobResultData = restApi().jobResult(sid, jobId);
jobResult = toJobResult(jobResultData);
} catch (Exception e) {
throwUJEOrNCEOrPE(e);
}
return jobResult;
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class SchedulerClient method getStatus.
@Override
public SchedulerStatus getStatus() throws NotConnectedException, PermissionException {
SchedulerStatus status = null;
try {
SchedulerStatusData schedulerStatus = restApi().getSchedulerStatus(sid);
status = SchedulerStatus.valueOf(schedulerStatus.name());
} catch (Exception e) {
throwNCEOrPE(e);
}
return status;
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class SchedulerClient method submit.
@Override
public JobId submit(Job job) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
JobIdData jobIdData = null;
try {
InputStream is = (new Job2XMLTransformer()).jobToxml((TaskFlowJob) job);
jobIdData = restApiClient().submitXml(sid, is);
} catch (Exception e) {
throwNCEOrPEOrSCEOrJCE(e);
}
return jobId(jobIdData);
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class DataSpaceClient method create.
@Override
public boolean create(IRemoteSource source) throws NotConnectedException, PermissionException {
if (log.isDebugEnabled()) {
log.debug("Trying to create file " + source);
}
StringBuffer uriTmpl = (new StringBuffer()).append(restDataspaceUrl).append(source.getDataspace().value());
ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine).build();
ResteasyWebTarget target = client.target(uriTmpl.toString()).path(source.getPath());
Response response = null;
try {
Invocation.Builder request = target.request();
request.header("sessionid", sessionId);
Form form = new Form();
form.param("mimetype", source.getType().getMimeType());
response = request.post(Entity.form(form));
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new NotConnectedException("User not authenticated or session timeout.");
} else {
throw new RuntimeException("Cannot create file(s). Status code:" + response.getStatus());
}
}
if (log.isDebugEnabled()) {
log.debug("File creation " + source + " performed with success");
}
return true;
} finally {
if (response != null) {
response.close();
}
}
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class DataSpaceClient method metadata.
@Override
public Map<String, String> metadata(IRemoteSource source) throws NotConnectedException, PermissionException {
StringBuffer uriTmpl = (new StringBuffer()).append(restDataspaceUrl).append(source.getDataspace().value());
ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine).build();
ResteasyWebTarget target = client.target(uriTmpl.toString()).path(source.getPath());
Response response = null;
try {
response = target.request().header("sessionid", sessionId).head();
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new NotConnectedException("User not authenticated or session timeout.");
} else {
throw new RuntimeException(String.format("Cannot get metadata from %s in '%s' dataspace.", source.getPath(), source.getDataspace()));
}
}
MultivaluedMap<String, Object> headers = response.getHeaders();
Map<String, String> metaMap = Maps.newHashMap();
if (headers.containsKey(HttpHeaders.LAST_MODIFIED)) {
metaMap.put(HttpHeaders.LAST_MODIFIED, String.valueOf(headers.getFirst(HttpHeaders.LAST_MODIFIED)));
}
return metaMap;
} finally {
if (response != null) {
response.close();
}
}
}
Aggregations