Java Code Examples for org.mybatis.guice.transactional.Transactional

The following examples show how to use org.mybatis.guice.transactional.Transactional. These examples are extracted from open source projects. 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 Project: hmdm-server   Source File: DeviceDAO.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * <p>Updates the device data in persistent data store. The reference to related customer account and last update
 * time of the device are not affected by this method.</p>
 *
 * @param device a device to be updated.
 * @throws SecurityException if current user is not authorized to update this device.
 */
@Transactional
public void updateDevice(Device device) {
    updateById(device.getId(), this.mapper::getDeviceById, dbDevice -> {
        device.setCustomerId(dbDevice.getCustomerId());

        final Integer currentUserId = SecurityContext.get().getCurrentUser().get().getId();
        this.mapper.updateDevice(device);
        this.mapper.removeDeviceGroupsByDeviceId(currentUserId, device.getCustomerId(), device.getId());
        if (device.getGroups() != null && !device.getGroups().isEmpty()) {
            this.mapper.insertDeviceGroups(
                    device.getId(), device.getGroups().stream().map(LookupItem::getId).collect(Collectors.toList())
            );
        }
    }, SecurityException::onDeviceAccessViolation);
}
 
Example 2
Source Project: hmdm-server   Source File: ConfigurationDAO.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional
public Configuration getConfigurationByIdFull(Integer id) {
    final Configuration configuration = getSingleRecord(() -> this.mapper.getConfigurationById(id), SecurityException::onConfigurationAccessViolation);
    if (configuration != null) {
        final List<ApplicationSetting> appSettings = this.applicationSettingDAO.getApplicationSettingsByConfigurationId(id);
        configuration.setApplicationSettings(appSettings);

        final List<ConfigurationApplicationParameters> applicationParameters = this.mapper.getApplicationParameters(id);
        configuration.setApplicationUsageParameters(applicationParameters);

        final List<ConfigurationFile> files = this.configurationFileDAO.getConfigurationFiles(id);
        configuration.setFiles(files);

    }

    return configuration;
}
 
Example 3
Source Project: hmdm-server   Source File: ApplicationDAO.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * <p>Removes the application referenced by the specified ID. The associated application versions are removed as
 * well.</p>
 *
 * @param id an ID of an application to delete.
 * @throws SecurityException if current user is not granted a permission to delete the specified application.
 */
@Transactional
public void removeApplicationById(Integer id) {
    Application dbApplication = this.mapper.findById(id);
    if (dbApplication != null && dbApplication.isCommonApplication()) {
        if (!SecurityContext.get().isSuperAdmin()) {
            throw SecurityException.onAdminDataAccessViolation("delete common application");
        }
    }

    boolean used = this.mapper.isApplicationUsedInConfigurations(id);
    if (used) {
        throw new ApplicationReferenceExistsException(id, "configurations");
    }

    updateById(
            id,
            this::findById,
            (record) -> this.mapper.removeApplicationById(record.getId()),
            SecurityException::onApplicationAccessViolation
    );
}
 
Example 4
Source Project: hmdm-server   Source File: PushService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * <p>Sends the messages on configuration update for the devices related to specified configuration.</p>
 *
 * @param configurationId an ID of updated configuration.
 */
@Transactional
public void notifyDevicesOnUpdate(Integer configurationId) {
    final Configuration configuration = this.configurationDAO.getConfigurationById(configurationId);
    if (configuration != null) {
        final List<Device> devices
                = this.deviceDAO.getDeviceIdsByConfigurationId(configurationId);
        devices.forEach(device -> {
            PushMessage message = new PushMessage();
            message.setDeviceId(device.getId());
            message.setMessageType(PushMessage.TYPE_CONFIG_UPDATED);

            this.send(message);
        });
    }
}
 
Example 5
Source Project: apollo   Source File: ServicesStackController.java    License: Apache License 2.0 6 votes vote down vote up
@LoggedIn
@Transactional
@POST("/services-stack")
public void addServicesStack(String name, boolean isEnabled, String servicesCsv, Req req) {
    List<Integer> servicesIds = StringParser.splitCsvToIntegerList(servicesCsv);
    ServicesStack servicesStack = new ServicesStack(name, isEnabled);
    stackDao.addStack(servicesStack);
    if (servicesIds.size() > 0) {
        servicesIds.forEach(id -> {
            if (serviceDao.getService(id).getIsPartOfGroup()) {
                assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "Can't add to stack service that is part of a group");
                return;
            }
        });
        servicesStackDao.addServicesToStack(servicesIds, servicesStack.getId());
    }
    assignJsonResponseToReq(req, HttpStatus.CREATED, getServicesStack(servicesStack.getId()));
}
 
Example 6
Source Project: apollo   Source File: ServicesStackController.java    License: Apache License 2.0 6 votes vote down vote up
@LoggedIn
@Transactional
@PUT("/services-stack")
public void updateServicesStack(int id, String name, boolean isEnabled, String servicesCsv, Req req) {
    List<Integer> servicesIds = StringParser.splitCsvToIntegerList(servicesCsv);
    if (servicesIds.size() <= 0) {
        assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "The ServicesStack you asked to update has an empty services list");
        return;
    }
    servicesIds.forEach(serviceId -> {
        if (serviceDao.getService(id).getIsPartOfGroup()) {
            assignJsonResponseToReq(req, HttpStatus.BAD_REQUEST, "Can't add to stack service that is part of a group");
            return;
        }
    });
    ServicesStack servicesStack = new ServicesStack(id, name, isEnabled);
    stackDao.updateStack(servicesStack);
    servicesStackDao.clearServicesStack(id);
    servicesStackDao.addServicesToStack(servicesIds, id);
    assignJsonResponseToReq(req, HttpStatus.OK, getServicesStack(id));
}
 
Example 7
@Override
@Transactional
public InternalType createObject(ModeledAuthenticatedUser user, ExternalType object)
    throws GuacamoleException {

    ModelType model = getModelInstance(user, object);
    beforeCreate(user, object, model);
    
    // Create object
    getObjectMapper().insert(model);

    // Set identifier on original object
    object.setIdentifier(model.getIdentifier());

    // Add implicit permissions
    Collection<ObjectPermissionModel> implicitPermissions = getImplicitPermissions(user, model);
    if (!implicitPermissions.isEmpty())
        getPermissionMapper().insert(implicitPermissions);

    // Add any arbitrary attributes
    if (model.hasArbitraryAttributes())
        getObjectMapper().insertAttributes(model);

    return getObjectInstance(user, model);

}
 
Example 8
@Override
@Transactional
public void updateObject(ModeledAuthenticatedUser user, InternalType object)
    throws GuacamoleException {

    ModelType model = object.getModel();
    beforeUpdate(user, object, model);
    
    // Update object
    getObjectMapper().update(model);

    // Replace any existing arbitrary attributes
    getObjectMapper().deleteAttributes(model);
    if (model.hasArbitraryAttributes())
        getObjectMapper().insertAttributes(model);

}
 
Example 9
Source Project: guacamole-client   Source File: EntityService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the set of all group identifiers of which the given entity is a
 * member, taking into account the given collection of known group
 * memberships which are not necessarily defined within the database.
 * 
 * Note that group visibility with respect to the queried entity is NOT
 * taken into account. If the entity is a member of a group, the identifier
 * of that group will be included in the returned set even if the current
 * user lacks "READ" permission for that group.
 *
 * @param entity
 *     The entity whose effective groups should be returned.
 *
 * @param effectiveGroups
 *     The identifiers of any known effective groups that should be taken
 *     into account, such as those defined externally to the database.
 *
 * @return
 *     The set of identifiers of all groups that the given entity is a
 *     member of, including those where membership is inherited through
 *     membership in other groups.
 */
@Transactional
public Set<String> retrieveEffectiveGroups(ModeledPermissions<? extends EntityModel> entity,
        Collection<String> effectiveGroups) {

    // Retrieve the effective user groups of the given entity, recursively if possible
    boolean recursive = environment.isRecursiveQuerySupported(sqlSession);
    Set<String> identifiers = entityMapper.selectEffectiveGroupIdentifiers(entity.getModel(), effectiveGroups, recursive);

    // If the set of user groups retrieved was not produced recursively,
    // manually repeat the query to expand the set until all effective
    // groups have been found
    if (!recursive && !identifiers.isEmpty()) {
        Set<String> previousIdentifiers;
        do {
            previousIdentifiers = identifiers;
            identifiers = entityMapper.selectEffectiveGroupIdentifiers(entity.getModel(), previousIdentifiers, false);
        } while (identifiers.size() > previousIdentifiers.size());
    }

    return identifiers;

}
 
Example 10
@Override
@Transactional
public GuacamoleTunnel getGuacamoleTunnel(RemoteAuthenticatedUser user,
        SharedConnectionDefinition definition,
        GuacamoleClientInformation info, Map<String, String> tokens)
        throws GuacamoleException {

    // Create a connection record which describes the shared connection
    ActiveConnectionRecord connectionRecord = activeConnectionRecordProvider.get();
    connectionRecord.init(user, definition.getActiveConnection(),
            definition.getSharingProfile());

    // Connect to shared connection described by the created record
    GuacamoleTunnel tunnel = assignGuacamoleTunnel(connectionRecord, info, tokens, false);

    // Register tunnel, such that it is closed when the
    // SharedConnectionDefinition is invalidated
    definition.registerTunnel(tunnel);
    return tunnel;

}
 
Example 11
Source Project: hmdm-server   Source File: UserDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void updatePasswordBySuperAdmin(User user ) {
    if (SecurityContext.get().isSuperAdmin()) {
        this.mapper.updatePassword(user);
    } else {
        throw new IllegalArgumentException("Super-admin is allowed only");
    }
}
 
Example 12
Source Project: hmdm-server   Source File: UserDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Clears the list of identifiers for hints already show to current user.</p>
 */
@Transactional
public void disableHints() {
    SecurityContext.get().getCurrentUser()
            .map(user -> {
                this.mapper.clearHintsHistory(user.getId());
                this.mapper.insertHintsHistoryAll(user.getId());
                return Optional.empty();
            })
            .orElseThrow(SecurityException::onAnonymousAccess);
}
 
Example 13
Source Project: hmdm-server   Source File: DeviceDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void insertDevice(Device device) {
    insertRecord(device, d -> {
        this.mapper.insertDevice(d);
        if (d.getGroups() != null && !d.getGroups().isEmpty()) {
            this.mapper.insertDeviceGroups(
                    d.getId(), d.getGroups().stream().map(LookupItem::getId).collect(Collectors.toList())
            );
        }
        this.eventService.fireEvent(new DeviceInfoUpdatedEvent(d.getId()));
    });
}
 
Example 14
Source Project: hmdm-server   Source File: DeviceDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Gets the applications installed on specified device.</p>
 *
 * @param deviceId an ID of a device.
 * @return a list of applications reported as installed on specified device.
 */
@Transactional
public List<DeviceApplication> getDeviceInstalledApplications(int deviceId) {
    final Device dbDevice = getDeviceById(deviceId);
    if (dbDevice != null) {
        return this.mapper.getDeviceInstalledApplications(dbDevice.getId());
    } else {
        return new ArrayList<>();
    }
}
 
Example 15
Source Project: hmdm-server   Source File: DeviceDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void saveDeviceApplicationSettings(Integer deviceId, List<ApplicationSetting> applicationSettings) {
    final Device dbDevice = getDeviceById(deviceId);
    if (dbDevice != null) {
        this.mapper.deleteDeviceApplicationSettings(dbDevice.getId());
        this.mapper.insertDeviceApplicationSettings(dbDevice.getId(), applicationSettings);
    }
}
 
Example 16
Source Project: hmdm-server   Source File: DeviceDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Updates the description for the specified device.</p>
 *
 * @param deviceId an ID of a device to update description for.
 * @param newDeviceDescription a new device description.
 * @throws SecurityException if current user is not authorized to update the specified device description.
 */
@Transactional
public void updateDeviceDescription(Integer deviceId, String newDeviceDescription) {
    updateById(
            deviceId,
            this.mapper::getDeviceById,
            device -> this.mapper.updateDeviceDescription(deviceId, newDeviceDescription),
            SecurityException::onDeviceAccessViolation
    );
}
 
Example 17
Source Project: hmdm-server   Source File: ConfigurationDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void removeConfigurationById(Integer id) {
    long count = this.mapper.countDevices(id);
    if (count > 0) {
        throw new ConfigurationReferenceExistsException(id, "devices");
    }

    updateById(
            id,
            this.mapper::getConfigurationById,
            configuration -> this.mapper.removeConfigurationById(configuration.getId()),
            SecurityException::onConfigurationAccessViolation
    );
}
 
Example 18
Source Project: hmdm-server   Source File: ConfigurationDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Upgrades the useage of specified application by specified configuration to most recent version available for
 * application.</p>
 *
 * @param configurationId an ID of a configuration to upgrade application version for.
 * @param applicationId an ID of application to upgrade.
 */
@Transactional
public void upgradeConfigurationApplication(Integer configurationId, Integer applicationId) {
    updateLinkedData(configurationId,
            this.mapper::getConfigurationById,
            configuration -> {
                this.mapper.upgradeConfigurationApplication(configuration.getId(), applicationId);
                log.debug("Upgraded application #{} to most recent version for configuration #{}",
                        applicationId, configurationId);
            },
            SecurityException::onConfigurationAccessViolation
    );
}
 
Example 19
Source Project: hmdm-server   Source File: ApplicationDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Creates new application record in DB.</p>
 *
 * @param application an application record to be created.
 */
@Transactional
public int insertWebApplication(Application application) {
    log.debug("Entering #insertWebApplication: application = {}", application);

    final Optional<Integer> currentCustomerId = SecurityContext.get().getCurrentCustomerId();
    if (currentCustomerId.isPresent()) {
        String pkg;
        Long count;
        do {
            pkg = DigestUtils.sha1Hex(application.getUrl() + System.currentTimeMillis());
            count = this.mapper.countByPackageId(currentCustomerId.get(), pkg);
        } while (count > 0);

        application.setPkg(pkg);
        application.setVersion("0");

        insertRecord(application, this.mapper::insertApplication);

        final ApplicationVersion applicationVersion = new ApplicationVersion(application);

        this.mapper.insertApplicationVersion(applicationVersion);
        this.mapper.recalculateLatestVersion(application.getId());

        return application.getId();
    } else {
        throw SecurityException.onAnonymousAccess();
    }
}
 
Example 20
Source Project: hmdm-server   Source File: ApplicationDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Updates existing web application record in DB.</p>
 *
 * @param application an application record to be updated.
 * @throws DuplicateApplicationException if another application record with same package ID and version already
 *         exists either for current or master customer account.
 */
@Transactional
public void updateWebApplication(Application application) {
    final Optional<Integer> currentCustomerId = SecurityContext.get().getCurrentCustomerId();
    if (currentCustomerId.isPresent()) {
        final Application dbDevice = this.mapper.findById(application.getId());
        application.setPkg(dbDevice.getPkg());
        application.setVersion("0");

        updateRecord(application, this.mapper::updateApplication, SecurityException::onApplicationAccessViolation);
    } else {
        throw SecurityException.onAnonymousAccess();
    }
}
 
Example 21
Source Project: hmdm-server   Source File: ApplicationDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
    public void updateApplicationVersionConfigurations(LinkConfigurationsToAppVersionRequest request) {
        final int applicationVersionId = request.getApplicationVersionId();
        this.removeApplicationConfigurationsByVersionId(applicationVersionId);

        // If this version is set for installation, then other versions of same app must be set for de-installation
        final List<ApplicationVersionConfigurationLink> configurations = request.getConfigurations();
        configurations.forEach(link -> {
            if (link.getAction() == 1) {
                final int uninstalledCount = this.mapper.uninstallOtherVersions(applicationVersionId, link.getConfigurationId());
                log.debug("Uninstalled {} application versions of application #{} ({}) for configuration #{} ({})",
                        uninstalledCount, link.getApplicationId(), link.getApplicationName(),
                        link.getConfigurationId(), link.getConfigurationName());

                // Update the Main App and Content App references to refer to new application version (if necessary)
//                final int mainAppUpdateCount
//                        = this.mapper.syncConfigurationMainApplication(link.getConfigurationId(), applicationVersionId);
//                log.debug("Synchronized {} main application versions of application #{} ({}) for configuration #{} ({})",
//                        mainAppUpdateCount, link.getApplicationId(), link.getApplicationName(),
//                        link.getConfigurationId(), link.getConfigurationName());
//                final int contentAppUpdateCount
//                        = this.mapper.syncConfigurationContentApplication(link.getConfigurationId(), applicationVersionId);
//                log.debug("Synchronized {} content application versions of application #{} ({}) for configuration #{} ({})",
//                        contentAppUpdateCount, link.getApplicationId(), link.getApplicationName(),
//                        link.getConfigurationId(), link.getConfigurationName());
            }
        });

        this.insertApplicationVersionConfigurations(applicationVersionId, configurations);

        SecurityContext.get().getCurrentUser().ifPresent(user -> {
            this.mapper.recheckConfigurationMainApplications(user.getCustomerId());
            this.mapper.recheckConfigurationContentApplications(user.getCustomerId());
            this.mapper.recheckConfigurationKioskModes(user.getCustomerId());
        });
    }
 
Example 22
Source Project: hmdm-server   Source File: ApplicationDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Removes the application version referenced by the specified ID.</p>
 *
 * @param id an ID of an application to delete.
 * @return an URL for the deleted application version.
 * @throws SecurityException if current user is not granted a permission to delete the specified application.
 */
@Transactional
public String removeApplicationVersionById(@NotNull Integer id) {
    ApplicationVersion dbApplicationVersion = this.mapper.findVersionById(id);
    if (dbApplicationVersion != null) {
        if (dbApplicationVersion.isDeletionProhibited()) {
            throw SecurityException.onApplicationVersionAccessViolation(id);
        }

        if (dbApplicationVersion.isCommonApplication()) {
            if (!SecurityContext.get().isSuperAdmin()) {
                throw SecurityException.onAdminDataAccessViolation("delete common application version");
            }
        }

        final Application dbApplication = this.mapper.findById(dbApplicationVersion.getApplicationId());
        boolean used = this.mapper.isApplicationVersionUsedInConfigurations(id);
        if (used) {
            throw new ApplicationReferenceExistsException(id, "configurations");
        }

        this.mapper.removeApplicationVersionById(id);

        // Recalculate latest version for application if necessary
        if (dbApplication.getLatestVersion() != null && dbApplication.getLatestVersion().equals(id)) {
            this.mapper.recalculateLatestVersion(dbApplication.getId());
            final Application application = this.mapper.findById(dbApplication.getId());
            if (application.getLatestVersion() != null) {
                final ApplicationVersion latestVersion = this.mapper.findVersionById(application.getLatestVersion());
                doAutoUpdateToApplicationVersion(latestVersion);
            }
        }


        return dbApplicationVersion.getUrl();
    }

    return null;
}
 
Example 23
Source Project: hmdm-server   Source File: CustomerDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void updateCustomer(Customer customer) {
    if (!SecurityContext.get().isSuperAdmin()) {
        throw SecurityException.onAdminDataAccessViolation("update customer account with ID " + customer.getId());
    }
    this.mapper.update(customer);
    this.mapper.saveApiKey(customer);

    log.info("Updated customer account: {}", customer);
}
 
Example 24
Source Project: hmdm-server   Source File: UserRoleSettingsDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void saveCommonSettings(List<UserRoleSettings> settings) {
    SecurityContext.get().getCurrentUser().ifPresent(u -> settings.forEach(s -> {
        s.setCustomerId(u.getCustomerId());
        this.mapper.saveUserRoleCommonSettings(s);
    }));
}
 
Example 25
Source Project: hmdm-server   Source File: UnsecureDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void insertDevice(Device device) {
    this.deviceMapper.insertDevice(device);
    if (device.getGroups() != null && !device.getGroups().isEmpty()) {
        this.deviceMapper.insertDeviceGroups(
                device.getId(), device.getGroups().stream().map(LookupItem::getId).collect(Collectors.toList())
        );
    }
}
 
Example 26
Source Project: hmdm-server   Source File: UnsecureDAO.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public Configuration getConfigurationByIdWithAppSettings(Integer id) {
    final Configuration dbConfiguration = this.configurationMapper.getConfigurationById(id);
    if (dbConfiguration != null) {
        final List<ApplicationSetting> appSettings = this.applicationSettingDAO.getApplicationSettingsByConfigurationId(dbConfiguration.getId());
        dbConfiguration.setApplicationSettings(appSettings);
    }

    return dbConfiguration;
}
 
Example 27
Source Project: hmdm-server   Source File: DeviceStatusService.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
public void recalcDeviceStatuses(int deviceId) {
    final Device dbDevice = this.deviceMapper.getDeviceById(deviceId);
    if (dbDevice != null) {
        try {
            DeviceConfigFilesStatus deviceConfigFilesStatus = DeviceConfigFilesStatus.OTHER;
            DeviceApplicationsStatus deviceApplicatiosStatus = DeviceApplicationsStatus.FAILURE;

            if (dbDevice.getInfo() != null) {
                if (!dbDevice.getInfo().trim().isEmpty()) {
                    final String deviceInfoString = dbDevice.getInfo();
                    ObjectMapper jsonMapper = new ObjectMapper();
                    DeviceInfo info = jsonMapper.readValue(deviceInfoString, DeviceInfo.class);

                    deviceConfigFilesStatus = evaluateDeviceConfigurationFilesStatus(dbDevice, info);
                    deviceApplicatiosStatus = evaluateDeviceApplicationsStatus(dbDevice, info);
                }
            }

            this.deviceMapper.updateDeviceStatuses(dbDevice.getId(), deviceConfigFilesStatus, deviceApplicatiosStatus);
            
        } catch (IOException e) {
            logger.error("Failed to parse JSON data from info property", e);
        }

    }
}
 
Example 28
Source Project: hmdm-server   Source File: NotificationDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Gets the list of messages to be delivered to specified device. The returned messages are immediately marked as
 * delivered.</p>
 *
 * @param deviceId a device number identifying the device.
 * @return a list of messages to be delivered to device.
 */
@Transactional
public List<PushMessage> getPendingMessagesForDelivery(String deviceId) {
    final List<PushMessage> messages = this.notificationMapper.getPendingMessagesForDelivery(deviceId);
    if (!messages.isEmpty()) {
        final List<Integer> messageIds = messages.stream().map(PushMessage::getId).collect(Collectors.toList());
        this.notificationMapper.markMessagesAsDelivered(messageIds);
    }
    return messages;
}
 
Example 29
Source Project: hmdm-server   Source File: NotificationDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Sends the specified notification message. This implementation puts it to queue to be retrieved by device later.</p>
 *
 * @param message a message to send.
 * @return an ID of a message.
 */
@Transactional
public int send(PushMessage message) {
    this.notificationMapper.insertPushMessage(message);
    this.notificationMapper.insertPendingPush(message.getId());
    return message.getId();
}
 
Example 30
Source Project: hmdm-server   Source File: PluginDAO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Disables the specified plugins for customer account assoicated with the current user.</p>
 *
 * @param pluginIds a list of plugin IDs.
 */
@Transactional
public void saveDisabledPlugins(Integer[] pluginIds) {
    SecurityContext.get().getCurrentUser()
            .map(user -> {
                this.pluginMapper.cleanUpDisabledPlugins(user.getCustomerId());
                if (pluginIds.length > 0) {
                    this.pluginMapper.insertDisabledPlugin(pluginIds, user.getCustomerId());
                }
                return 1;
            })
            .orElseThrow(SecurityException::onAnonymousAccess);
}