use of org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition in project opencast by opencast.
the class AbstractAclServiceRestEndpoint method addSeriesTransition.
@POST
@Path("/series/{seriesId}")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "addseriestransition", description = "Add a series transition", returnDescription = "Add a series transition", pathParameters = { @RestParameter(name = "seriesId", isRequired = true, description = "The series id", type = STRING) }, restParameters = { @RestParameter(name = "applicationDate", isRequired = true, description = "The date to applicate", type = STRING), @RestParameter(name = "managedAclId", isRequired = true, description = "The managed access control list id", type = INTEGER), @RestParameter(name = "workflowDefinitionId", isRequired = false, description = "The workflow definition identifier", type = STRING), @RestParameter(name = "workflowParams", isRequired = false, description = "The workflow parameters as JSON", type = STRING), @RestParameter(name = "override", isRequired = false, description = "If to override the episode ACL's", type = STRING, defaultValue = "false") }, reponses = { @RestResponse(responseCode = SC_OK, description = "The series transition has successfully been added"), @RestResponse(responseCode = SC_CONFLICT, description = "The series transition with the applicationDate already exists"), @RestResponse(responseCode = SC_BAD_REQUEST, description = "The given managed acl id could not be found"), @RestResponse(responseCode = SC_INTERNAL_SERVER_ERROR, description = "Error during adding a series transition") })
public String addSeriesTransition(@PathParam("seriesId") String seriesId, @FormParam("applicationDate") String applicationDate, @FormParam("managedAclId") long managedAclId, @FormParam("workflowDefinitionId") String workflowDefinitionId, @FormParam("workflowParams") String workflowParams, @FormParam("override") boolean override) {
try {
final Date at = new Date(DateTimeSupport.fromUTC(applicationDate));
final Option<ConfiguredWorkflowRef> workflow = createConfiguredWorkflowRef(workflowDefinitionId, workflowParams);
SeriesACLTransition seriesTransition = aclService().addSeriesTransition(seriesId, managedAclId, at, override, workflow);
return JsonConv.full(seriesTransition).toJson();
} catch (AclServiceNoReferenceException e) {
logger.info("Managed acl with id '{}' coudl not be found", managedAclId);
throw new WebApplicationException(Status.BAD_REQUEST);
} catch (AclTransitionDbDuplicatedException e) {
logger.info("Error adding series transition: transition with date {} already exists", applicationDate);
throw new WebApplicationException(Status.CONFLICT);
} catch (AclServiceException e) {
logger.warn("Error adding series transition:", e);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
} catch (Exception e) {
logger.warn("Unable to parse the application date");
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition in project opencast by opencast.
the class AbstractAclServiceRestEndpoint method updateSeriesTransition.
@PUT
@Path("/series/{transitionId}")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "updateseriestransition", description = "Update an existing series transition", returnDescription = "Update an existing series transition", pathParameters = { @RestParameter(name = "transitionId", isRequired = true, description = "The transition id", type = STRING) }, restParameters = { @RestParameter(name = "applicationDate", isRequired = true, description = "The date to applicate", type = STRING), @RestParameter(name = "managedAclId", isRequired = true, description = "The managed access control list id", type = INTEGER), @RestParameter(name = "workflowDefinitionId", isRequired = false, description = "The workflow definition identifier", type = STRING), @RestParameter(name = "workflowParams", isRequired = false, description = "The workflow parameters as JSON", type = STRING), @RestParameter(name = "override", isRequired = false, description = "If to override the episode ACL's", type = STRING, defaultValue = "false") }, reponses = { @RestResponse(responseCode = SC_OK, description = "The series transition has successfully been updated"), @RestResponse(responseCode = SC_BAD_REQUEST, description = "The given managed acl id could not be found"), @RestResponse(responseCode = SC_INTERNAL_SERVER_ERROR, description = "Error during updating a series transition") })
public String updateSeriesTransition(@PathParam("transitionId") long transitionId, @FormParam("applicationDate") String applicationDate, @FormParam("managedAclId") long managedAclId, @FormParam("workflowDefinitionId") String workflowDefinitionId, @FormParam("workflowParams") String workflowParams, @FormParam("override") boolean override) throws NotFoundException {
try {
final Date at = new Date(DateTimeSupport.fromUTC(applicationDate));
final Option<ConfiguredWorkflowRef> workflow = createConfiguredWorkflowRef(workflowDefinitionId, workflowParams);
final SeriesACLTransition t = aclService().updateSeriesTransition(transitionId, managedAclId, at, workflow, override);
return JsonConv.full(t).toJson();
} catch (AclServiceNoReferenceException e) {
logger.info("Managed acl with id '{}' could not be found", managedAclId);
throw new WebApplicationException(Status.BAD_REQUEST);
} catch (AclServiceException e) {
logger.warn("Error updating series transition:", e);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.warn("Unable to parse the application date");
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testDeleteSeries.
@Test
public void testDeleteSeries() throws Exception {
final ManagedAcl macl = createAcl();
SeriesACLTransition t1 = db.storeSeriesAclTransition(ORG, "uuid", new Date(), macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
// try deletion from different org
try {
db.deleteSeriesAclTransition(ORG2, t1.getTransitionId());
fail("Deleting from non-owner org should not be possible");
} catch (NotFoundException ignore) {
}
db.deleteSeriesAclTransition(ORG, t1.getTransitionId());
try {
db.deleteSeriesAclTransition(ORG, t1.getTransitionId());
fail("Deleting a non existing transition should throw an exception");
} catch (NotFoundException ignore) {
}
}
use of org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testStoreAndGetSeriesACL.
@Test
public void testStoreAndGetSeriesACL() throws Exception {
final Date now = new Date();
// a transition referencing a non existing ACL should not be saveable
try {
db.storeSeriesAclTransition(ORG, "uuid", new Date(), 1L, true, Option.<ConfiguredWorkflowRef>none());
fail("No ACL with ID 1");
} catch (AclTransitionDbException ignore) {
}
// a transition referencing an existing ACL should be saveable
final ManagedAcl macl = createAcl();
final SeriesACLTransition t3 = db.storeSeriesAclTransition(ORG, "uuid", now, macl.getId(), false, Option.<ConfiguredWorkflowRef>none());
assertEquals("uuid", t3.getSeriesId());
assertEquals(now, t3.getApplicationDate());
assertEquals(macl.getName(), t3.getAccessControlList().getName());
// a transition with the same properties should not be saveable
try {
db.storeSeriesAclTransition(ORG, "uuid", now, macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
fail("Duplicated episode ACL must not be stored");
} catch (AclTransitionDbDuplicatedException ignore) {
}
List<SeriesACLTransition> ts = db.getSeriesAclTransitions(ORG, "uuid");
assertEquals(1, ts.size());
assertEquals("uuid", ts.get(0).getSeriesId());
assertTrue(!ts.get(0).isOverride());
assertTrue(!ts.get(0).isDone());
}
use of org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition in project opencast by opencast.
the class SeriesAclTransitionEntity method update.
SeriesAclTransitionEntity update(final String seriesId, final String orgId, final Date applicationDate, final ManagedAclEntity managedAcl, final Option<ConfiguredWorkflowRef> workflow, final boolean override) {
final SeriesAclTransitionEntity self = this;
run(SeriesACLTransition.class, new SeriesACLTransition() {
@Override
public String getSeriesId() {
self.seriesId = seriesId;
return null;
}
@Override
public ManagedAcl getAccessControlList() {
self.managedAcl = managedAcl;
return null;
}
@Override
public boolean isOverride() {
self.override = override;
return false;
}
@Override
public long getTransitionId() {
return 0;
}
@Override
public String getOrganizationId() {
self.organizationId = orgId;
return null;
}
@Override
public Date getApplicationDate() {
self.applicationDate = applicationDate;
return null;
}
@Override
public Option<ConfiguredWorkflowRef> getWorkflow() {
final Tuple<Option<String>, Option<String>> s = splitConfiguredWorkflowRef(workflow);
self.workflowId = s.getA().getOrElseNull();
self.workflowParams = s.getB().getOrElseNull();
return null;
}
@Override
public boolean isDone() {
self.done = done;
return false;
}
});
return this;
}
Aggregations