Search in sources :

Example 21 with IndexServiceException

use of org.opencastproject.index.service.exception.IndexServiceException in project opencast by opencast.

the class EventHttpServletRequest method updateFromHttpServletRequest.

/**
 * Load the details of updating an event.
 *
 * @param event
 *          The event to update.
 * @param request
 *          The multipart request that has the data to load the updated event.
 * @param eventCatalogUIAdapters
 *          The list of catalog ui adapters to use to load the event metadata.
 * @param startDatePattern
 *          The pattern to use to parse the start date from the request.
 * @param startTimePattern
 *          The pattern to use to parse the start time from the request.
 * @return The data for the event update
 * @throws IllegalArgumentException
 *           Thrown if the request to update the event is malformed.
 * @throws IndexServiceException
 *           Thrown if something is unable to load the event data.
 * @throws NotFoundException
 *           Thrown if unable to find a metadata catalog or field that matches an input catalog or field.
 */
public static EventHttpServletRequest updateFromHttpServletRequest(Event event, HttpServletRequest request, List<EventCatalogUIAdapter> eventCatalogUIAdapters, Opt<String> startDatePattern, Opt<String> startTimePattern) throws IllegalArgumentException, IndexServiceException, NotFoundException {
    EventHttpServletRequest eventHttpServletRequest = new EventHttpServletRequest();
    if (ServletFileUpload.isMultipartContent(request)) {
        try {
            for (FileItemIterator iter = new ServletFileUpload().getItemIterator(request); iter.hasNext(); ) {
                FileItemStream item = iter.next();
                String fieldName = item.getFieldName();
                if (item.isFormField()) {
                    setFormField(eventCatalogUIAdapters, eventHttpServletRequest, item, fieldName, startDatePattern, startTimePattern);
                }
            }
        } catch (IOException e) {
            throw new IndexServiceException("Unable to update event", e);
        } catch (FileUploadException e) {
            throw new IndexServiceException("Unable to update event", e);
        }
    } else {
        throw new IllegalArgumentException("No multipart content");
    }
    return eventHttpServletRequest;
}
Also used : ServletFileUpload(org.apache.commons.fileupload.servlet.ServletFileUpload) FileItemStream(org.apache.commons.fileupload.FileItemStream) IOException(java.io.IOException) FileItemIterator(org.apache.commons.fileupload.FileItemIterator) IndexServiceException(org.opencastproject.index.service.exception.IndexServiceException) FileUploadException(org.apache.commons.fileupload.FileUploadException)

Aggregations

IndexServiceException (org.opencastproject.index.service.exception.IndexServiceException)21 NotFoundException (org.opencastproject.util.NotFoundException)18 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)13 WebApplicationException (javax.ws.rs.WebApplicationException)12 IOException (java.io.IOException)11 SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)11 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)11 WorkflowDatabaseException (org.opencastproject.workflow.api.WorkflowDatabaseException)11 AssetManagerException (org.opencastproject.assetmanager.api.AssetManagerException)9 IngestException (org.opencastproject.ingest.api.IngestException)9 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)9 WorkflowException (org.opencastproject.workflow.api.WorkflowException)9 ParseException (java.text.ParseException)8 JSONException (org.codehaus.jettison.json.JSONException)8 EventCommentException (org.opencastproject.event.comment.EventCommentException)8 MediaPackage (org.opencastproject.mediapackage.MediaPackage)8 MetadataParsingException (org.opencastproject.metadata.dublincore.MetadataParsingException)7 SeriesException (org.opencastproject.series.api.SeriesException)7 JSONObject (org.json.simple.JSONObject)6 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)6