Search in sources :

Example 11 with SchedulerTransactionLockException

use of org.opencastproject.scheduler.api.SchedulerTransactionLockException in project opencast by opencast.

the class SchedulerRestService method addEvent.

/**
 * Creates new event based on parameters. All times and dates are in milliseconds.
 */
@POST
@Path("/")
@RestQuery(name = "newrecording", description = "Creates new event with specified parameters", returnDescription = "If an event was successfully created", restParameters = { @RestParameter(name = "start", isRequired = true, type = Type.INTEGER, description = "The start date of the event in milliseconds from 1970-01-01T00:00:00Z"), @RestParameter(name = "end", isRequired = true, type = Type.INTEGER, description = "The end date of the event in milliseconds from 1970-01-01T00:00:00Z"), @RestParameter(name = "agent", isRequired = true, type = Type.STRING, description = "The agent of the event"), @RestParameter(name = "users", isRequired = false, type = Type.STRING, description = "Comma separated list of user ids (speakers/lecturers) for the event"), @RestParameter(name = "mediaPackage", isRequired = true, type = Type.TEXT, description = "The media package of the event"), @RestParameter(name = "wfproperties", isRequired = false, type = Type.TEXT, description = "Workflow " + "configuration keys for the event. Each key will be prefixed by 'org.opencastproject.workflow" + ".config.' and added to the capture agent parameters."), @RestParameter(name = "agentparameters", isRequired = false, type = Type.TEXT, description = "The capture agent properties for the event"), @RestParameter(name = "optOut", isRequired = false, type = Type.BOOLEAN, description = "The opt out status of the event"), @RestParameter(name = "source", isRequired = false, type = Type.STRING, description = "The scheduling source of the event"), @RestParameter(name = "origin", isRequired = false, type = Type.STRING, description = "The origin") }, reponses = { @RestResponse(responseCode = HttpServletResponse.SC_CREATED, description = "Event is successfully created"), @RestResponse(responseCode = HttpServletResponse.SC_CONFLICT, description = "Unable to create event, conflicting events found (ConflicsFound)"), @RestResponse(responseCode = HttpServletResponse.SC_CONFLICT, description = "Unable to create event, event locked by a transaction  (TransactionLock)"), @RestResponse(responseCode = HttpServletResponse.SC_UNAUTHORIZED, description = "You do not have permission to create the event. Maybe you need to authenticate."), @RestResponse(responseCode = HttpServletResponse.SC_BAD_REQUEST, description = "Missing or invalid information for this request") })
public Response addEvent(@FormParam("start") long startTime, @FormParam("end") long endTime, @FormParam("agent") String agentId, @FormParam("users") String users, @FormParam("mediaPackage") String mediaPackageXml, @FormParam("wfproperties") String workflowProperties, @FormParam("agentparameters") String agentParameters, @FormParam("optOut") Boolean optOut, @FormParam("source") String schedulingSource, @FormParam("origin") String origin) throws UnauthorizedException {
    if (StringUtils.isBlank(origin))
        origin = SchedulerService.ORIGIN;
    if (endTime <= startTime || startTime < 0) {
        logger.debug("Cannot add event without proper start and end time");
        return RestUtil.R.badRequest("Cannot add event without proper start and end time");
    }
    if (StringUtils.isBlank(agentId)) {
        logger.debug("Cannot add event without agent identifier");
        return RestUtil.R.badRequest("Cannot add event without agent identifier");
    }
    if (StringUtils.isBlank(mediaPackageXml)) {
        logger.debug("Cannot add event without media package");
        return RestUtil.R.badRequest("Cannot add event without media package");
    }
    MediaPackage mediaPackage;
    try {
        mediaPackage = MediaPackageParser.getFromXml(mediaPackageXml);
    } catch (MediaPackageException e) {
        logger.debug("Could not parse media package", e);
        return RestUtil.R.badRequest("Could not parse media package");
    }
    String eventId = mediaPackage.getIdentifier().compact();
    Map<String, String> caProperties = new HashMap<>();
    if (StringUtils.isNotBlank(agentParameters)) {
        try {
            Properties prop = parseProperties(agentParameters);
            caProperties.putAll((Map) prop);
        } catch (Exception e) {
            logger.info("Could not parse capture agent properties: {}", agentParameters);
            return RestUtil.R.badRequest("Could not parse capture agent properties");
        }
    }
    Map<String, String> wfProperties = new HashMap<>();
    if (StringUtils.isNotBlank(workflowProperties)) {
        try {
            Properties prop = parseProperties(workflowProperties);
            wfProperties.putAll((Map) prop);
        } catch (IOException e) {
            logger.info("Could not parse workflow configuration properties: {}", workflowProperties);
            return RestUtil.R.badRequest("Could not parse workflow configuration properties");
        }
    }
    Set<String> userIds = new HashSet<>();
    String[] ids = StringUtils.split(users, ",");
    if (ids != null)
        userIds.addAll(Arrays.asList(ids));
    DateTime startDate = new DateTime(startTime).toDateTime(DateTimeZone.UTC);
    DateTime endDate = new DateTime(endTime).toDateTime(DateTimeZone.UTC);
    try {
        service.addEvent(startDate.toDate(), endDate.toDate(), agentId, userIds, mediaPackage, wfProperties, caProperties, Opt.nul(optOut), Opt.nul(schedulingSource), origin);
        return Response.status(Status.CREATED).header("Location", serverUrl + serviceUrl + '/' + eventId + "/mediapackage.xml").build();
    } catch (UnauthorizedException e) {
        throw e;
    } catch (SchedulerTransactionLockException | SchedulerConflictException e) {
        return Response.status(Status.CONFLICT).entity(generateErrorResponse(e)).type(MediaType.APPLICATION_JSON).build();
    } catch (Exception e) {
        logger.error("Unable to create new event with id '{}'", eventId, e);
        return Response.serverError().build();
    }
}
Also used : MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) HashMap(java.util.HashMap) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) IOException(java.io.IOException) Properties(java.util.Properties) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) WebApplicationException(javax.ws.rs.WebApplicationException) IOException(java.io.IOException) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) ParseException(java.text.ParseException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException) DateTime(org.joda.time.DateTime) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) MediaPackage(org.opencastproject.mediapackage.MediaPackage) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) RestQuery(org.opencastproject.util.doc.rest.RestQuery)

Example 12 with SchedulerTransactionLockException

use of org.opencastproject.scheduler.api.SchedulerTransactionLockException in project opencast by opencast.

the class SchedulerServiceImplTest method testTransactionConflicts.

@Test
public void testTransactionConflicts() throws Exception {
    Date start = new Date();
    Date end = new Date(System.currentTimeMillis() + 60000);
    String captureDeviceID = "demo";
    String seriesId = "series1";
    Set<String> userIds = new HashSet<>();
    userIds.add("user1");
    userIds.add("user2");
    MediaPackage mp = generateEvent(Opt.<String>none());
    mp.setSeries(seriesId);
    DublinCoreCatalog event = generateEvent(captureDeviceID, start, end);
    addDublinCore(Opt.<String>none(), mp, event);
    Map<String, String> caProperties = generateCaptureAgentMetadata("demo");
    try {
        schedSvc.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none(), Opt.some("new"), SchedulerService.ORIGIN);
    } catch (SchedulerTransactionLockException e) {
        fail("Transaction create lock not working!");
    }
    Assert.assertFalse(schedSvc.hasActiveTransaction(mp.getIdentifier().compact()));
    SchedulerTransaction trx = schedSvc.createTransaction("new");
    assertEquals("new", trx.getSource());
    SchedulerTransaction trx2 = schedSvc.createTransaction("new2");
    assertEquals("new2", trx2.getSource());
    try {
        schedSvc.createTransaction("new");
        fail("Duplicated transaction created!");
    } catch (SchedulerConflictException e) {
        assertNotNull(e);
    }
    try {
        schedSvc.updateEvent(mp.getIdentifier().compact(), Opt.<Date>none(), Opt.<Date>none(), Opt.<String>none(), Opt.<Set<String>>none(), Opt.<MediaPackage>none(), Opt.<Map<String, String>>none(), Opt.<Map<String, String>>none(), Opt.some(Opt.some(false)), SchedulerService.ORIGIN);
        fail("Transaction update lock not working!");
    } catch (SchedulerTransactionLockException e) {
        assertNotNull(e);
    }
    try {
        schedSvc.removeEvent(mp.getIdentifier().compact());
        fail("Transaction delete lock not working!");
    } catch (SchedulerTransactionLockException e) {
        assertNotNull(e);
    }
    try {
        MediaPackage mp2 = generateEvent(Opt.<String>none());
        schedSvc.addEvent(start, end, captureDeviceID, userIds, mp2, wfPropertiesUpdated, caProperties, Opt.<Boolean>none(), Opt.some("new"), SchedulerService.ORIGIN);
        fail("Transaction create lock not working!");
    } catch (SchedulerTransactionLockException e) {
        assertNotNull(e);
    }
    SchedulerTransaction trx3 = schedSvc.getTransaction(trx.getId());
    assertEquals(trx, trx3);
    mp = generateEvent(Opt.<String>none());
    event = generateEvent(captureDeviceID, new Date(), end);
    addDublinCore(Opt.<String>none(), mp, event);
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none());
    Assert.assertTrue(schedSvc.hasActiveTransaction(mp.getIdentifier().compact()));
    trx.commit();
    Assert.assertFalse(schedSvc.hasActiveTransaction(mp.getIdentifier().compact()));
    try {
        MediaPackage mp2 = generateEvent(Opt.<String>none());
        Date startDate = new Date(System.currentTimeMillis() + 600000);
        Date endDate = new Date(System.currentTimeMillis() + 660000);
        schedSvc.addEvent(startDate, endDate, captureDeviceID, userIds, mp2, wfPropertiesUpdated, caProperties, Opt.<Boolean>none(), Opt.some("new"), SchedulerService.ORIGIN);
    } catch (SchedulerTransactionLockException e) {
        fail("Transaction create lock not working!");
    }
}
Also used : SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) MediaPackage(org.opencastproject.mediapackage.MediaPackage) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) SchedulerTransaction(org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction) Date(java.util.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with SchedulerTransactionLockException

use of org.opencastproject.scheduler.api.SchedulerTransactionLockException in project opencast by opencast.

the class SchedulerServiceRemoteImpl method addMultipleEvents.

@Override
public Map<String, Period> addMultipleEvents(RRule rRule, Date start, Date end, Long duration, TimeZone tz, String captureAgentId, Set<String> userIds, MediaPackage templateMp, Map<String, String> wfProperties, Map<String, String> caMetadata, Opt<Boolean> optOut, Opt<String> schedulingSource, String modificationOrigin) throws UnauthorizedException, SchedulerConflictException, SchedulerTransactionLockException, SchedulerException {
    HttpPost post = new HttpPost("/");
    logger.debug("Start adding a new events through remote Schedule Service");
    List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair("rrule", rRule.getValue()));
    params.add(new BasicNameValuePair("start", Long.toString(start.getTime())));
    params.add(new BasicNameValuePair("end", Long.toString(end.getTime())));
    params.add(new BasicNameValuePair("duration", Long.toString(duration)));
    params.add(new BasicNameValuePair("tz", tz.toZoneId().getId()));
    params.add(new BasicNameValuePair("agent", captureAgentId));
    params.add(new BasicNameValuePair("users", StringUtils.join(userIds, ",")));
    params.add(new BasicNameValuePair("templateMp", MediaPackageParser.getAsXml(templateMp)));
    params.add(new BasicNameValuePair("wfproperties", toPropertyString(wfProperties)));
    params.add(new BasicNameValuePair("agentparameters", toPropertyString(caMetadata)));
    if (optOut.isSome())
        params.add(new BasicNameValuePair("optOut", Boolean.toString(optOut.get())));
    if (schedulingSource.isSome())
        params.add(new BasicNameValuePair("source", schedulingSource.get()));
    params.add(new BasicNameValuePair("origin", modificationOrigin));
    post.setEntity(new UrlEncodedFormEntity(params, UTF_8));
    String eventId = templateMp.getIdentifier().compact();
    HttpResponse response = getResponse(post, SC_CREATED, SC_UNAUTHORIZED, SC_CONFLICT);
    try {
        if (response != null && SC_CREATED == response.getStatusLine().getStatusCode()) {
            logger.info("Successfully added events to the scheduler service");
            return null;
        } else if (response != null && SC_CONFLICT == response.getStatusLine().getStatusCode()) {
            String errorJson = EntityUtils.toString(response.getEntity(), UTF_8);
            JSONObject json = (JSONObject) parser.parse(errorJson);
            JSONObject error = (JSONObject) json.get("error");
            String errorCode = (String) error.get("code");
            if (SchedulerTransactionLockException.ERROR_CODE.equals(errorCode)) {
                logger.info("Event is locked by a transaction, unable to add event based on {}", eventId);
                throw new SchedulerTransactionLockException("Event is locked by a transaction, unable to add event " + eventId);
            } else if (SchedulerConflictException.ERROR_CODE.equals(errorCode)) {
                logger.info("Conflicting events found when adding event based on {}", eventId);
                throw new SchedulerConflictException("Conflicting events found when adding event based on" + eventId);
            } else {
                throw new SchedulerException("Unexpected error code " + errorCode);
            }
        } else if (response != null && SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) {
            logger.info("Unauthorized to create the event");
            throw new UnauthorizedException("Unauthorized to create the event");
        } else {
            throw new SchedulerException("Unable to add event " + eventId + " to the scheduler service");
        }
    } catch (UnauthorizedException e) {
        throw e;
    } catch (SchedulerTransactionLockException e) {
        throw e;
    } catch (SchedulerConflictException e) {
        throw e;
    } catch (Exception e) {
        throw new SchedulerException("Unable to add event " + eventId + " to the scheduler service: " + e);
    } finally {
        closeConnection(response);
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) ArrayList(java.util.ArrayList) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) HttpResponse(org.apache.http.HttpResponse) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException) JSONObject(org.json.simple.JSONObject) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException)

Example 14 with SchedulerTransactionLockException

use of org.opencastproject.scheduler.api.SchedulerTransactionLockException in project opencast by opencast.

the class SchedulerServiceRemoteImpl method removeEvent.

@Override
public void removeEvent(String eventId) throws NotFoundException, UnauthorizedException, SchedulerTransactionLockException, SchedulerException {
    logger.debug("Start removing event {} from scheduling service.", eventId);
    HttpDelete delete = new HttpDelete("/" + eventId);
    HttpResponse response = getResponse(delete, SC_OK, SC_NOT_FOUND, SC_UNAUTHORIZED, SC_CONFLICT);
    try {
        if (response != null && SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
            logger.info("Event {} was not found by the scheduler service", eventId);
            throw new NotFoundException("Event '" + eventId + "' not found on remote scheduler service!");
        } else if (response != null && SC_OK == response.getStatusLine().getStatusCode()) {
            logger.info("Event {} removed from scheduling service.", eventId);
            return;
        } else if (response != null && SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) {
            logger.info("Unauthorized to remove the event {}.", eventId);
            throw new UnauthorizedException("Unauthorized to remove the event " + eventId);
        } else if (response != null && SC_CONFLICT == response.getStatusLine().getStatusCode()) {
            logger.info("Event is locked by a transaction, unable to delete event {}", eventId);
            throw new SchedulerTransactionLockException("Event is locked by a transaction, unable to delete event " + eventId);
        }
    } catch (UnauthorizedException e) {
        throw e;
    } catch (NotFoundException e) {
        throw e;
    } catch (SchedulerTransactionLockException e) {
        throw e;
    } catch (Exception e) {
        throw new SchedulerException("Unable to remove event " + eventId + " from the scheduler service: " + e);
    } finally {
        closeConnection(response);
    }
    throw new SchedulerException("Unable to remove  event " + eventId);
}
Also used : SchedulerException(org.opencastproject.scheduler.api.SchedulerException) HttpDelete(org.apache.http.client.methods.HttpDelete) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) HttpResponse(org.apache.http.HttpResponse) NotFoundException(org.opencastproject.util.NotFoundException) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException)

Example 15 with SchedulerTransactionLockException

use of org.opencastproject.scheduler.api.SchedulerTransactionLockException in project opencast by opencast.

the class SchedulerRestService method addMultipleEvents.

/**
 * Creates new event based on parameters. All times and dates are in milliseconds.
 */
@POST
@Path("/multiple")
@RestQuery(name = "newrecordings", description = "Creates new event with specified parameters", returnDescription = "If an event was successfully created", restParameters = { @RestParameter(name = "rrule", isRequired = true, type = Type.STRING, description = "The recurrence rule for the events"), @RestParameter(name = "start", isRequired = true, type = Type.INTEGER, description = "The start date of the event in milliseconds from 1970-01-01T00:00:00Z"), @RestParameter(name = "end", isRequired = true, type = Type.INTEGER, description = "The end date of the event in milliseconds from 1970-01-01T00:00:00Z"), @RestParameter(name = "duration", isRequired = true, type = Type.INTEGER, description = "The duration of the events in milliseconds"), @RestParameter(name = "tz", isRequired = true, type = Type.INTEGER, description = "The timezone of the events"), @RestParameter(name = "agent", isRequired = true, type = Type.STRING, description = "The agent of the event"), @RestParameter(name = "users", isRequired = false, type = Type.STRING, description = "Comma separated list of user ids (speakers/lecturers) for the event"), @RestParameter(name = "templateMp", isRequired = true, type = Type.TEXT, description = "The template mediapackage for the events"), @RestParameter(name = "wfproperties", isRequired = false, type = Type.TEXT, description = "Workflow " + "configuration keys for the event. Each key will be prefixed by 'org.opencastproject.workflow" + ".config.' and added to the capture agent parameters."), @RestParameter(name = "agentparameters", isRequired = false, type = Type.TEXT, description = "The capture agent properties for the event"), @RestParameter(name = "optOut", isRequired = false, type = Type.BOOLEAN, description = "The opt out status of the event"), @RestParameter(name = "source", isRequired = false, type = Type.STRING, description = "The scheduling source of the event"), @RestParameter(name = "origin", isRequired = false, type = Type.STRING, description = "The origin") }, reponses = { @RestResponse(responseCode = HttpServletResponse.SC_CREATED, description = "Event is successfully created"), @RestResponse(responseCode = HttpServletResponse.SC_CONFLICT, description = "Unable to create event, conflicting events found (ConflicsFound)"), @RestResponse(responseCode = HttpServletResponse.SC_CONFLICT, description = "Unable to create event, event locked by a transaction  (TransactionLock)"), @RestResponse(responseCode = HttpServletResponse.SC_UNAUTHORIZED, description = "You do not have permission to create the event. Maybe you need to authenticate."), @RestResponse(responseCode = HttpServletResponse.SC_BAD_REQUEST, description = "Missing or invalid information for this request") })
public Response addMultipleEvents(@FormParam("rrule") String rruleString, @FormParam("start") long startTime, @FormParam("end") long endTime, @FormParam("duration") long duration, @FormParam("tz") String tzString, @FormParam("agent") String agentId, @FormParam("users") String users, @FormParam("templateMp") MediaPackage templateMp, @FormParam("wfproperties") String workflowProperties, @FormParam("agentparameters") String agentParameters, @FormParam("optOut") Boolean optOut, @FormParam("source") String schedulingSource, @FormParam("origin") String origin) throws UnauthorizedException {
    if (StringUtils.isBlank(origin))
        origin = SchedulerService.ORIGIN;
    if (endTime <= startTime || startTime < 0) {
        logger.debug("Cannot add event without proper start and end time");
        return RestUtil.R.badRequest("Cannot add event without proper start and end time");
    }
    RRule rrule;
    try {
        rrule = new RRule(rruleString);
    } catch (ParseException e) {
        logger.debug("Could not parse recurrence rule");
        return RestUtil.R.badRequest("Could not parse recurrence rule");
    }
    if (duration < 1) {
        logger.debug("Cannot schedule events with durations less than 1");
        return RestUtil.R.badRequest("Cannot schedule events with durations less than 1");
    }
    if (StringUtils.isBlank(tzString)) {
        logger.debug("Cannot schedule events with blank timezone");
        return RestUtil.R.badRequest("Cannot schedule events with blank timezone");
    }
    TimeZone tz = TimeZone.getTimeZone(tzString);
    if (StringUtils.isBlank(agentId)) {
        logger.debug("Cannot add event without agent identifier");
        return RestUtil.R.badRequest("Cannot add event without agent identifier");
    }
    Map<String, String> caProperties = new HashMap<>();
    if (StringUtils.isNotBlank(agentParameters)) {
        try {
            Properties prop = parseProperties(agentParameters);
            caProperties.putAll((Map) prop);
        } catch (Exception e) {
            logger.info("Could not parse capture agent properties: {}", agentParameters);
            return RestUtil.R.badRequest("Could not parse capture agent properties");
        }
    }
    Map<String, String> wfProperties = new HashMap<>();
    if (StringUtils.isNotBlank(workflowProperties)) {
        try {
            Properties prop = parseProperties(workflowProperties);
            wfProperties.putAll((Map) prop);
        } catch (IOException e) {
            logger.info("Could not parse workflow configuration properties: {}", workflowProperties);
            return RestUtil.R.badRequest("Could not parse workflow configuration properties");
        }
    }
    Set<String> userIds = new HashSet<>();
    String[] ids = StringUtils.split(users, ",");
    if (ids != null)
        userIds.addAll(Arrays.asList(ids));
    DateTime startDate = new DateTime(startTime).toDateTime(DateTimeZone.UTC);
    DateTime endDate = new DateTime(endTime).toDateTime(DateTimeZone.UTC);
    try {
        service.addMultipleEvents(rrule, startDate.toDate(), endDate.toDate(), duration, tz, agentId, userIds, templateMp, wfProperties, caProperties, Opt.nul(optOut), Opt.nul(schedulingSource), origin);
        return Response.status(Status.CREATED).build();
    } catch (UnauthorizedException e) {
        throw e;
    } catch (SchedulerTransactionLockException | SchedulerConflictException e) {
        return Response.status(Status.CONFLICT).entity(generateErrorResponse(e)).type(MediaType.APPLICATION_JSON).build();
    } catch (Exception e) {
        logger.error("Unable to create new events", e);
        return Response.serverError().build();
    }
}
Also used : RRule(net.fortuna.ical4j.model.property.RRule) HashMap(java.util.HashMap) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) IOException(java.io.IOException) Properties(java.util.Properties) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) WebApplicationException(javax.ws.rs.WebApplicationException) IOException(java.io.IOException) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) ParseException(java.text.ParseException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException) DateTime(org.joda.time.DateTime) DateTimeZone(org.joda.time.DateTimeZone) TimeZone(java.util.TimeZone) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) ParseException(java.text.ParseException) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) RestQuery(org.opencastproject.util.doc.rest.RestQuery)

Aggregations

SchedulerTransactionLockException (org.opencastproject.scheduler.api.SchedulerTransactionLockException)15 NotFoundException (org.opencastproject.util.NotFoundException)14 SchedulerConflictException (org.opencastproject.scheduler.api.SchedulerConflictException)13 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)11 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)11 MediaPackage (org.opencastproject.mediapackage.MediaPackage)9 IOException (java.io.IOException)7 Date (java.util.Date)7 AQueryBuilder (org.opencastproject.assetmanager.api.query.AQueryBuilder)7 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)7 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)7 HashSet (java.util.HashSet)6 ARecord (org.opencastproject.assetmanager.api.query.ARecord)5 AResult (org.opencastproject.assetmanager.api.query.AResult)5 ValidationException (net.fortuna.ical4j.model.ValidationException)4 HttpResponse (org.apache.http.HttpResponse)4 SeriesException (org.opencastproject.series.api.SeriesException)4 Log.getHumanReadableTimeString (org.opencastproject.util.Log.getHumanReadableTimeString)4 ServiceException (org.osgi.framework.ServiceException)4 ConfigurationException (org.osgi.service.cm.ConfigurationException)4