Example usage for com.liferay.portal.background.task.constants BackgroundTaskContextMapConstants DELETE_ON_SUCCESS

List of usage examples for com.liferay.portal.background.task.constants BackgroundTaskContextMapConstants DELETE_ON_SUCCESS

Introduction

In this page you can find the example usage for com.liferay.portal.background.task.constants BackgroundTaskContextMapConstants DELETE_ON_SUCCESS.

Prototype

String DELETE_ON_SUCCESS

To view the source code for com.liferay.portal.background.task.constants BackgroundTaskContextMapConstants DELETE_ON_SUCCESS.

Click Source Link

Usage

From source file:com.liferay.adaptive.media.web.internal.portlet.action.OptimizeImagesMVCActionCommand.java

License:Open Source License

private BackgroundTask _optimizeImages(long userId, long companyId, String jobName) throws PortalException {

    Map<String, Serializable> taskContextMap = new HashMap<>();

    taskContextMap.put(OptimizeImagesBackgroundTaskConstants.COMPANY_ID, companyId);
    taskContextMap.put(BackgroundTaskContextMapConstants.DELETE_ON_SUCCESS, true);

    try {//from w  ww .  ja  v a  2s .c om
        return _backgroundTaskManager.addBackgroundTask(userId, CompanyConstants.SYSTEM, jobName,
                OptimizeImagesAllConfigurationsBackgroundTaskExecutor.class.getName(), taskContextMap,
                new ServiceContext());
    } catch (PortalException pe) {
        throw new PortalException("Unable to schedule adaptive media images optimization", pe);
    }
}

From source file:com.liferay.adaptive.media.web.internal.portlet.action.OptimizeImagesMVCActionCommand.java

License:Open Source License

private BackgroundTask _optimizeImagesSingleConfiguration(long userId, long companyId, String jobName,
        String configurationEntryUuid) throws PortalException {

    Map<String, Serializable> taskContextMap = new HashMap<>();

    taskContextMap.put(OptimizeImagesBackgroundTaskConstants.CONFIGURATION_ENTRY_UUID, configurationEntryUuid);
    taskContextMap.put(OptimizeImagesBackgroundTaskConstants.COMPANY_ID, companyId);
    taskContextMap.put(BackgroundTaskContextMapConstants.DELETE_ON_SUCCESS, true);

    try {//w  w  w .  ja va  2 s  .  com
        return _backgroundTaskManager.addBackgroundTask(userId, CompanyConstants.SYSTEM, jobName,
                OptimizeImagesSingleConfigurationBackgroundTaskExecutor.class.getName(), taskContextMap,
                new ServiceContext());
    } catch (PortalException pe) {
        throw new PortalException("Unable to schedule adaptive media images optimization for "
                + "configuration " + configurationEntryUuid, pe);
    }
}