Search in sources :

Example 11 with WorkflowDatabaseException

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);
    }
}
Also used : WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) ServiceException(org.osgi.framework.ServiceException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) WorkflowException(org.opencastproject.workflow.api.WorkflowException) WorkflowParsingException(org.opencastproject.workflow.api.WorkflowParsingException) NotFoundException(org.opencastproject.util.NotFoundException) MalformedURLException(java.net.MalformedURLException) WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) IOException(java.io.IOException)

Example 12 with WorkflowDatabaseException

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");
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) HttpGet(org.apache.http.client.methods.HttpGet) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException)

Example 13 with WorkflowDatabaseException

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");
}
Also used : WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) NotFoundException(org.opencastproject.util.NotFoundException) ParseException(org.apache.http.ParseException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException) WorkflowException(org.opencastproject.workflow.api.WorkflowException) WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) IOException(java.io.IOException) WorkflowParsingException(org.opencastproject.workflow.api.WorkflowParsingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 14 with WorkflowDatabaseException

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");
}
Also used : WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) NotFoundException(org.opencastproject.util.NotFoundException) ParseException(org.apache.http.ParseException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException) WorkflowException(org.opencastproject.workflow.api.WorkflowException) WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) IOException(java.io.IOException) WorkflowParsingException(org.opencastproject.workflow.api.WorkflowParsingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 15 with WorkflowDatabaseException

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");
}
Also used : WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException) WorkflowException(org.opencastproject.workflow.api.WorkflowException) WorkflowDatabaseException(org.opencastproject.workflow.api.WorkflowDatabaseException) IOException(java.io.IOException) WorkflowParsingException(org.opencastproject.workflow.api.WorkflowParsingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

WorkflowDatabaseException (org.opencastproject.workflow.api.WorkflowDatabaseException)44 NotFoundException (org.opencastproject.util.NotFoundException)30 IOException (java.io.IOException)23 WorkflowParsingException (org.opencastproject.workflow.api.WorkflowParsingException)23 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)21 WorkflowException (org.opencastproject.workflow.api.WorkflowException)20 ArrayList (java.util.ArrayList)15 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)15 HttpResponse (org.apache.http.HttpResponse)14 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)11 ParseException (org.apache.http.ParseException)11 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)8 WorkflowQuery (org.opencastproject.workflow.api.WorkflowQuery)8 SolrServerException (org.apache.solr.client.solrj.SolrServerException)7 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)6 Job (org.opencastproject.job.api.Job)6 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)6 Collections.mkString (org.opencastproject.util.data.Collections.mkString)6 WorkflowDefinition (org.opencastproject.workflow.api.WorkflowDefinition)6