001/* 002 * Copyright 2019 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.odf.ose.schedulable; 017 018import java.util.Set; 019 020import org.apache.avalon.framework.service.ServiceException; 021import org.apache.avalon.framework.service.ServiceManager; 022import org.quartz.JobDataMap; 023import org.quartz.JobExecutionContext; 024 025import org.ametys.core.schedule.Schedulable; 026import org.ametys.odf.ose.export.OSEExport; 027import org.ametys.odf.ose.export.OSEExportExtensionPoint; 028import org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable; 029import org.ametys.plugins.core.schedule.Scheduler; 030 031/** 032 * {@link Schedulable} for OSE export. 033 */ 034public class ExportSchedulable extends AbstractStaticSchedulable 035{ 036 private static final String __AMETYS_CATALOG = "ametys.catalog"; 037 private static final String __OSE_CATALOG = "ose.catalog"; 038 private static final String __JOBDATAMAP_AMETYS_CATALOG = Scheduler.PARAM_VALUES_PREFIX + __AMETYS_CATALOG; 039 private static final String __JOBDATAMAP_OSE_CATALOG = Scheduler.PARAM_VALUES_PREFIX + __OSE_CATALOG; 040 041 /** The OSE export extension point */ 042 protected OSEExportExtensionPoint _oseExportEP; 043 044 @Override 045 public void service(ServiceManager manager) throws ServiceException 046 { 047 super.service(manager); 048 _oseExportEP = (OSEExportExtensionPoint) manager.lookup(OSEExportExtensionPoint.ROLE); 049 } 050 051 @Override 052 public void execute(JobExecutionContext context) throws Exception 053 { 054 JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); 055 String ametysCatalog = jobDataMap.getString(__JOBDATAMAP_AMETYS_CATALOG); 056 Long oseCatalog = jobDataMap.getLong(__JOBDATAMAP_OSE_CATALOG); 057 058 Set<String> exportIds = _oseExportEP.getExtensionsIds(); 059 060 for (String exportId : exportIds) 061 { 062 OSEExport export = _oseExportEP.getExtension(exportId); 063 export.populate(ametysCatalog, oseCatalog); 064 } 065 } 066}