use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.
the class PusherFacade method removeResourceVariableNotification.
public void removeResourceVariableNotification(@Observes final RemoveResourceVariable removeResourceVariable) {
if (isEnabled()) {
try {
ResourceVariable resourceVariable = resourceVariableAdapter.mapVariable(removeResourceVariable.getVariable());
Organization organization = organizationDao.getOrganizationById(resourceVariable.getOrganizationId());
ResourceId resourceId;
Set<String> users;
if (resourceVariable.getResourceType() == ResourceType.ORGANIZATION) {
resourceId = new ResourceId(getAppId(), resourceVariable.getId(), organization.getId());
users = permissionAdapter.getOrganizationUsersByRole(organization, RoleType.TechConfig);
} else {
Project project = projectDao.getProjectById(resourceVariable.getProjectId());
resourceId = new ResourceId(getAppId(), resourceVariable.getId(), organization.getId(), project.getId());
users = permissionAdapter.getProjectUsersByRole(organization, project, RoleType.TechConfig);
}
List<Event> events = users.stream().map(userId -> createEventForRemove(resourceVariable.getClass().getSimpleName(), resourceId, userId)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.
the class ResourceVariableFacade method delete.
public void delete(String id) {
ResourceVariable currentVariable = resourceVariableDao.getVariable(id);
checkPermissions(currentVariable, RoleType.TechConfig);
resourceVariableDao.delete(currentVariable);
}
use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.
the class ResourceVariableFacade method update.
public ResourceVariable update(final String id, ResourceVariable variable) {
ResourceVariable currentVariable = resourceVariableDao.getVariable(id);
currentVariable.patch(variable);
checkPermissions(currentVariable, RoleType.TechConfig);
return mapVariable(resourceVariableDao.update(id, variable));
}
use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.
the class ResourceVariablesServiceIT method testGetSecureVariable.
@Test
public void testGetSecureVariable() {
final ResourceVariable variable = createVariable("key", "value", true);
Response response = client.target(variablesUrl).path(variable.getId()).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
ResourceVariable returnedVariable = response.readEntity(ResourceVariable.class);
assertVariables(variable, returnedVariable, true);
}
use of io.lumeer.api.model.ResourceVariable in project engine by Lumeer.
the class ResourceVariablesServiceIT method testCreateExisting.
@Test
public void testCreateExisting() {
ResourceVariable variable = createVariable("key", "value", false);
Entity entity = Entity.json(prepareVariable(variable.getKey(), "xyz", false));
Response response = client.target(variablesUrl).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR);
}
Aggregations