Java Code Examples for org.camunda.bpm.engine.filter.Filter#setOwner()

The following examples show how to use org.camunda.bpm.engine.filter.Filter#setOwner() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterAuthorizationsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * CAM-4889
 */
public void FAILING_testUpdateFilterGenericOwnerId() {
  grantCreateFilter();

  Filter filter = filterService.newTaskFilter("someName");
  filterService.saveFilter(filter);

  grantUpdateFilter(filter.getId());
  filter.setOwner("*");

  try {
    filterService.saveFilter(filter);
    fail("it should not be possible to save a filter with the generic owner id");
  } catch (ProcessEngineException e) {
    assertTextPresent("foo", e.getMessage());
  }
}
 
Example 2
Source File: DefaultUserLifecycleBean.java    From Showcase with Apache License 2.0 5 votes vote down vote up
/**
 * creates a task query to select task to the logged in user.
 * Otherwise you would have to manually create a filter in TaskList after each boot up
 */
private void createAssignedTaskQuery() {
    TaskQuery query = taskService.createTaskQuery().taskAssignee(adminUsername);
    Filter taskFilter = filterService.newTaskFilter("assigned Tasks");
    taskFilter.setOwner(adminUsername);
    taskFilter.setQuery(query);
    filterService.saveFilter(taskFilter);
}
 
Example 3
Source File: FilterAuthorizationsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testDefaultFilterAuthorization() {
  // create two other users beside testUser
  User ownerUser = createTestUser("ownerUser");
  User anotherUser = createTestUser("anotherUser");

  // grant testUser create permission
  grantCreateFilter();

  // create a new filter with ownerUser as owner
  Filter filter = filterService.newTaskFilter("testFilter");
  filter.setOwner(ownerUser.getId());
  filterService.saveFilter(filter);

  assertFilterPermission(Permissions.CREATE, testUser, null, true);
  assertFilterPermission(Permissions.CREATE, ownerUser, null, false);
  assertFilterPermission(Permissions.CREATE, anotherUser, null, false);

  assertFilterPermission(Permissions.UPDATE, testUser, filter.getId(), false);
  assertFilterPermission(Permissions.UPDATE, ownerUser, filter.getId(), true);
  assertFilterPermission(Permissions.UPDATE, anotherUser, filter.getId(), false);

  assertFilterPermission(Permissions.READ, testUser, filter.getId(), false);
  assertFilterPermission(Permissions.READ, ownerUser, filter.getId(), true);
  assertFilterPermission(Permissions.READ, anotherUser, filter.getId(), false);

  assertFilterPermission(Permissions.DELETE, testUser, filter.getId(), false);
  assertFilterPermission(Permissions.DELETE, ownerUser, filter.getId(), true);
  assertFilterPermission(Permissions.DELETE, anotherUser, filter.getId(), false);
}
 
Example 4
Source File: FilterAuthorizationsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testCreateFilterGenericOwnerId() {
  grantCreateFilter();

  Filter filter = filterService.newTaskFilter("someName");
  filter.setOwner("*");

  try {
    filterService.saveFilter(filter);
    fail("exception expected");
  } catch (ProcessEngineException e) {
    assertTextPresent("Cannot create default authorization for filter owner *: "
        + "id cannot be *. * is a reserved identifier.", e.getMessage());
  }
}
 
Example 5
Source File: FilterDto.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void updateFilter(Filter filter, ProcessEngine engine) {
  if (getResourceType() != null && !getResourceType().equals(filter.getResourceType())) {
    throw new InvalidRequestException(Status.BAD_REQUEST, "Unable to update filter from resource type '" + filter.getResourceType() + "' to '" + getResourceType() + "'");
  }
  filter.setName(getName());
  filter.setOwner(getOwner());
  filter.setQuery(query.toQuery(engine));
  filter.setProperties(getProperties());
}