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;
}
Aggregations