use of org.opencastproject.workflow.api.WorkflowDatabaseException in project opencast by opencast.
the class WorkflowServiceSolrIndex method clear.
/**
* Clears the index of all workflow instances.
*/
public void clear() throws WorkflowDatabaseException {
try {
synchronized (solrServer) {
solrServer.deleteByQuery("*:*");
solrServer.commit();
}
} catch (Exception e) {
throw new WorkflowDatabaseException(e);
}
}
use of org.opencastproject.workflow.api.WorkflowDatabaseException in project opencast by opencast.
the class WorkflowServiceRemoteImpl method countWorkflowInstances.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowService#countWorkflowInstances(org.opencastproject.workflow.api.WorkflowInstance.WorkflowState,
* java.lang.String)
*/
@Override
public long countWorkflowInstances(WorkflowState state, String operation) throws WorkflowDatabaseException {
List<NameValuePair> queryStringParams = new ArrayList<NameValuePair>();
if (state != null)
queryStringParams.add(new BasicNameValuePair("state", state.toString()));
if (operation != null)
queryStringParams.add(new BasicNameValuePair("operation", operation));
StringBuilder url = new StringBuilder("/count");
if (queryStringParams.size() > 0) {
url.append("?");
url.append(URLEncodedUtils.format(queryStringParams, "UTF-8"));
}
HttpGet get = new HttpGet(url.toString());
HttpResponse response = getResponse(get);
try {
if (response != null) {
String body = null;
try {
body = EntityUtils.toString(response.getEntity());
return Long.parseLong(body);
} catch (NumberFormatException e) {
throw new WorkflowDatabaseException("Unable to parse the response body as a long: " + body);
}
}
} catch (ParseException e) {
throw new WorkflowDatabaseException("Unable to parse the response body");
} catch (IOException e) {
throw new WorkflowDatabaseException("Unable to parse the response body");
} finally {
closeConnection(response);
}
throw new WorkflowDatabaseException("Unable to count workflow instances");
}
use of org.opencastproject.workflow.api.WorkflowDatabaseException in project opencast by opencast.
the class WorkflowServiceRemoteImpl method getWorkflowDefinitionById.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowService#getWorkflowDefinitionById(java.lang.String)
*/
@Override
public WorkflowDefinition getWorkflowDefinitionById(String id) throws WorkflowDatabaseException, NotFoundException {
HttpGet get = new HttpGet("/definition/" + id + ".xml");
HttpResponse response = getResponse(get, SC_NOT_FOUND, SC_OK);
try {
if (response != null) {
if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
throw new NotFoundException("Workflow definition " + id + " does not exist.");
} else {
return WorkflowParser.parseWorkflowDefinition(response.getEntity().getContent());
}
}
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
throw new WorkflowDatabaseException(e);
} finally {
closeConnection(response);
}
throw new WorkflowDatabaseException("Unable to connect to a remote workflow service");
}
use of org.opencastproject.workflow.api.WorkflowDatabaseException in project opencast by opencast.
the class WorkflowServiceRemoteImpl method getWorkflowById.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowService#getWorkflowById(long)
*/
@Override
public WorkflowInstance getWorkflowById(long id) throws WorkflowDatabaseException, NotFoundException {
HttpGet get = new HttpGet("/instance/" + id + ".xml");
HttpResponse response = getResponse(get, SC_NOT_FOUND, SC_OK);
try {
if (response != null) {
if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
throw new NotFoundException("Workflow instance " + id + " does not exist.");
} else {
return WorkflowParser.parseWorkflowInstance(response.getEntity().getContent());
}
}
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
throw new WorkflowDatabaseException(e);
} finally {
closeConnection(response);
}
throw new WorkflowDatabaseException("Unable to connect to a remote workflow service");
}
use of org.opencastproject.workflow.api.WorkflowDatabaseException in project opencast by opencast.
the class WorkflowServiceRemoteImpl method getStatistics.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowService#getStatistics()
*/
@Override
public WorkflowStatistics getStatistics() throws WorkflowDatabaseException {
HttpGet get = new HttpGet("/statistics.xml");
HttpResponse response = getResponse(get);
try {
if (response != null)
return WorkflowParser.parseWorkflowStatistics(response.getEntity().getContent());
} catch (Exception e) {
throw new WorkflowDatabaseException("Unable to load workflow statistics", e);
} finally {
closeConnection(response);
}
throw new WorkflowDatabaseException("Unable to connect to a remote workflow service");
}
Aggregations