1 package org.apache.slide.projector.processor.core; 2 3 import java.util.Map ; 4 import java.util.logging.Logger ; 5 6 import org.apache.slide.projector.Context; 7 import org.apache.slide.projector.ProcessException; 8 import org.apache.slide.projector.Processor; 9 import org.apache.slide.projector.Result; 10 import org.apache.slide.projector.Store; 11 import org.apache.slide.projector.descriptor.ParameterDescriptor; 12 import org.apache.slide.projector.descriptor.ResultDescriptor; 13 import org.apache.slide.projector.descriptor.StateDescriptor; 14 import org.apache.slide.projector.descriptor.StringValueDescriptor; 15 import org.apache.slide.projector.i18n.ErrorMessage; 16 import org.apache.slide.projector.i18n.ParameterMessage; 17 import org.apache.slide.projector.util.StoreHelper; 18 import org.apache.slide.projector.value.StringValue; 19 20 public class Dispose implements Processor { 21 private static Logger logger = Logger.getLogger(Dispose.class.getName()); 22 23 public final static String STORE = "store"; 24 public final static String KEY = "key"; 25 26 private final static ParameterDescriptor[] parameterDescriptor = new ParameterDescriptor[]{ 27 new ParameterDescriptor(STORE, new ParameterMessage("dispose/parameter/store"), new StringValueDescriptor(Store.stores)), 28 new ParameterDescriptor(KEY, new ParameterMessage("dispose/parameter/key"), new StringValueDescriptor()) 29 }; 30 31 private final static ResultDescriptor resultDescriptor = new ResultDescriptor(new StateDescriptor[]{ StateDescriptor.OK_DESCRIPTOR }); 32 33 public Result process(Map parameter, Context context) throws Exception { 34 String name = ((StringValue)parameter.get(STORE)).toString(); 35 String key = ((StringValue)parameter.get(KEY)).toString(); 36 Store store = context.getStore(StoreHelper.getStoreByName(name)); 37 if ( store == null ) { 38 throw new ProcessException(new ErrorMessage("storeNotAvailable", new String [] {name})); 39 } 40 store.dispose(key); 41 return new Result( StateDescriptor.OK ); 42 } 43 44 public ParameterDescriptor[] getParameterDescriptors() { 45 return parameterDescriptor; 46 } 47 48 49 public ResultDescriptor getResultDescriptor() { 50 return resultDescriptor; 51 } 52 } | Popular Tags |