Search in sources :

Example 11 with ResourceVariable

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);
        }
    }
}
Also used : AppId(io.lumeer.api.model.AppId) Sequence(io.lumeer.api.model.Sequence) RemoveSequence(io.lumeer.engine.api.event.RemoveSequence) RemoveResource(io.lumeer.engine.api.event.RemoveResource) OrganizationUserEvent(io.lumeer.engine.api.event.OrganizationUserEvent) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) Resource(io.lumeer.api.model.common.Resource) ResourceVariableAdapter(io.lumeer.core.adapter.ResourceVariableAdapter) CreateResourceVariable(io.lumeer.engine.api.event.CreateResourceVariable) ResourceCommentDao(io.lumeer.storage.api.dao.ResourceCommentDao) RequestDataKeeper(io.lumeer.core.auth.RequestDataKeeper) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) CreateOrUpdateSequence(io.lumeer.engine.api.event.CreateOrUpdateSequence) CreateOrUpdatePayment(io.lumeer.engine.api.event.CreateOrUpdatePayment) UpdateResourceVariable(io.lumeer.engine.api.event.UpdateResourceVariable) CreateDocument(io.lumeer.engine.api.event.CreateDocument) Set(java.util.Set) LinkInstance(io.lumeer.api.model.LinkInstance) CreateOrUpdateUserNotification(io.lumeer.engine.api.event.CreateOrUpdateUserNotification) LinkType(io.lumeer.api.model.LinkType) Group(io.lumeer.api.model.Group) CreateOrUpdateUser(io.lumeer.engine.api.event.CreateOrUpdateUser) PusherClient(io.lumeer.core.util.PusherClient) RemoveUserNotification(io.lumeer.engine.api.event.RemoveUserNotification) FavoriteItemDao(io.lumeer.storage.api.dao.FavoriteItemDao) ViewAdapter(io.lumeer.core.adapter.ViewAdapter) Utils(io.lumeer.core.util.Utils) CreateDocumentsAndLinks(io.lumeer.engine.api.event.CreateDocumentsAndLinks) UserDao(io.lumeer.storage.api.dao.UserDao) DocumentAdapter(io.lumeer.core.adapter.DocumentAdapter) CreateOrUpdateGroup(io.lumeer.engine.api.event.CreateOrUpdateGroup) RemoveLinkType(io.lumeer.engine.api.event.RemoveLinkType) OrganizationDao(io.lumeer.storage.api.dao.OrganizationDao) FavoriteItem(io.lumeer.engine.api.event.FavoriteItem) ViewDao(io.lumeer.storage.api.dao.ViewDao) RemoveResourceComment(io.lumeer.engine.api.event.RemoveResourceComment) RemoveUser(io.lumeer.engine.api.event.RemoveUser) Permissions(io.lumeer.api.model.Permissions) ResourceAdapter(io.lumeer.core.adapter.ResourceAdapter) ResourceComment(io.lumeer.api.model.ResourceComment) LinkTypeAdapter(io.lumeer.core.adapter.LinkTypeAdapter) DocumentUtils(io.lumeer.core.util.DocumentUtils) RemoveSelectionList(io.lumeer.engine.api.event.RemoveSelectionList) Project(io.lumeer.api.model.Project) LinkInstanceDao(io.lumeer.storage.api.dao.LinkInstanceDao) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter) CreateSelectionList(io.lumeer.engine.api.event.CreateSelectionList) UpdateLinkType(io.lumeer.engine.api.event.UpdateLinkType) ResourceVariable(io.lumeer.api.model.ResourceVariable) ReloadResourceVariables(io.lumeer.engine.api.event.ReloadResourceVariables) UpdateDocument(io.lumeer.engine.api.event.UpdateDocument) TemplateCreated(io.lumeer.engine.api.event.TemplateCreated) SetDocumentLinks(io.lumeer.engine.api.event.SetDocumentLinks) ProjectDao(io.lumeer.storage.api.dao.ProjectDao) User(io.lumeer.api.model.User) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) AddFavoriteItem(io.lumeer.engine.api.event.AddFavoriteItem) UpdateCompanyContact(io.lumeer.engine.api.event.UpdateCompanyContact) CreateLinkInstance(io.lumeer.engine.api.event.CreateLinkInstance) CreateResource(io.lumeer.engine.api.event.CreateResource) SelectionList(io.lumeer.api.model.SelectionList) RolesDifference(io.lumeer.api.model.RolesDifference) ResourceType(io.lumeer.api.model.ResourceType) UpdateDashboardData(io.lumeer.engine.api.event.UpdateDashboardData) UpdateResourceComment(io.lumeer.engine.api.event.UpdateResourceComment) Observes(javax.enterprise.event.Observes) ReloadSelectionLists(io.lumeer.engine.api.event.ReloadSelectionLists) RemoveFavoriteItem(io.lumeer.engine.api.event.RemoveFavoriteItem) CollectionAdapter(io.lumeer.core.adapter.CollectionAdapter) RemoveGroup(io.lumeer.engine.api.event.RemoveGroup) RoleType(io.lumeer.api.model.RoleType) View(io.lumeer.api.model.View) UpdateServiceLimits(io.lumeer.engine.api.event.UpdateServiceLimits) Document(io.lumeer.api.model.Document) RemoveDocument(io.lumeer.engine.api.event.RemoveDocument) ResourceVariableEvent(io.lumeer.engine.api.event.ResourceVariableEvent) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) UpdateCurrentUser(io.lumeer.engine.api.event.UpdateCurrentUser) CreateResourceComment(io.lumeer.engine.api.event.CreateResourceComment) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) List(java.util.List) PostConstruct(javax.annotation.PostConstruct) UpdateResource(io.lumeer.engine.api.event.UpdateResource) ReloadGroups(io.lumeer.engine.api.event.ReloadGroups) WithId(io.lumeer.api.model.common.WithId) LinkInstanceAdapter(io.lumeer.core.adapter.LinkInstanceAdapter) UserNotification(io.lumeer.api.model.UserNotification) CreateLinkType(io.lumeer.engine.api.event.CreateLinkType) SelectionListEvent(io.lumeer.engine.api.event.SelectionListEvent) UpdateDefaultViewConfig(io.lumeer.engine.api.event.UpdateDefaultViewConfig) Event(org.marvec.pusher.data.Event) DashboardData(io.lumeer.api.model.DashboardData) Level(java.util.logging.Level) HashSet(java.util.HashSet) Inject(javax.inject.Inject) DataDao(io.lumeer.storage.api.dao.DataDao) ReloadResourceContent(io.lumeer.engine.api.event.ReloadResourceContent) ReloadLinkTypeContent(io.lumeer.engine.api.event.ReloadLinkTypeContent) Organization(io.lumeer.api.model.Organization) RemoveResourceVariable(io.lumeer.engine.api.event.RemoveResourceVariable) DocumentDao(io.lumeer.storage.api.dao.DocumentDao) ImportResource(io.lumeer.engine.api.event.ImportResource) RemoveLinkInstance(io.lumeer.engine.api.event.RemoveLinkInstance) UpdateLinkInstance(io.lumeer.engine.api.event.UpdateLinkInstance) UpdateSelectionList(io.lumeer.engine.api.event.UpdateSelectionList) PusherAdapter(io.lumeer.core.adapter.PusherAdapter) RequestScoped(javax.enterprise.context.RequestScoped) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) Project(io.lumeer.api.model.Project) CreateResourceVariable(io.lumeer.engine.api.event.CreateResourceVariable) UpdateResourceVariable(io.lumeer.engine.api.event.UpdateResourceVariable) ResourceVariable(io.lumeer.api.model.ResourceVariable) RemoveResourceVariable(io.lumeer.engine.api.event.RemoveResourceVariable) Organization(io.lumeer.api.model.Organization) OrganizationUserEvent(io.lumeer.engine.api.event.OrganizationUserEvent) ResourceVariableEvent(io.lumeer.engine.api.event.ResourceVariableEvent) SelectionListEvent(io.lumeer.engine.api.event.SelectionListEvent) Event(org.marvec.pusher.data.Event)

Example 12 with ResourceVariable

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);
}
Also used : ResourceVariable(io.lumeer.api.model.ResourceVariable)

Example 13 with ResourceVariable

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));
}
Also used : ResourceVariable(io.lumeer.api.model.ResourceVariable)

Example 14 with ResourceVariable

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);
}
Also used : Response(javax.ws.rs.core.Response) ResourceVariable(io.lumeer.api.model.ResourceVariable) Test(org.junit.Test)

Example 15 with ResourceVariable

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);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) ResourceVariable(io.lumeer.api.model.ResourceVariable) Test(org.junit.Test)

Aggregations

ResourceVariable (io.lumeer.api.model.ResourceVariable)15 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)6 ResourceType (io.lumeer.api.model.ResourceType)3 Entity (javax.ws.rs.client.Entity)3 AppId (io.lumeer.api.model.AppId)2 Collection (io.lumeer.api.model.Collection)2 DashboardData (io.lumeer.api.model.DashboardData)2 Document (io.lumeer.api.model.Document)2 Group (io.lumeer.api.model.Group)2 LinkInstance (io.lumeer.api.model.LinkInstance)2 LinkType (io.lumeer.api.model.LinkType)2 Organization (io.lumeer.api.model.Organization)2 Permissions (io.lumeer.api.model.Permissions)2 Project (io.lumeer.api.model.Project)2 ResourceComment (io.lumeer.api.model.ResourceComment)2 RoleType (io.lumeer.api.model.RoleType)2 RolesDifference (io.lumeer.api.model.RolesDifference)2 SelectionList (io.lumeer.api.model.SelectionList)2 Sequence (io.lumeer.api.model.Sequence)2