View Javadoc

1   package org.astrogrid.portal.myspace.acting.framework;
2   
3   import java.util.Map;
4   
5   import org.astrogrid.store.Agsl;
6   
7   /***
8    * Copy a MySpace entry.
9    * 
10   * @author peter.shillan
11   */
12  public class CopyHandler extends AbstractMySpaceHandler {
13    /***
14     * @see org.astrogrid.portal.myspace.acting.framework.AbstractMySpaceHandler#AbstractMySpaceHandler(org.astrogrid.portal.myspace.acting.framework.ContextWrapper)
15     * @param context
16     */
17    public CopyHandler(ContextWrapper context) {
18      super(context);
19    }
20  
21    /***
22     * Copy a MySpace entity from one location to another.
23     * 
24     * @see org.astrogrid.portal.myspace.acting.framework.AbstractMySpaceHandler#executeTemplateMethod(java.util.Map)
25     */
26    protected void executeTemplateMethod(Map results) throws Throwable {
27      String src = context.getParameter(MySpaceHandler.PARAM_SRC);
28      String dest = context.getParameter(MySpaceHandler.PARAM_DEST);
29      
30      // Validate the parameters.
31      if(src != null && src.length() > 0 &&
32          dest != null && dest.length() > 0) {
33        // Create a new storage location within the same MySpace store.
34        Agsl destination = new Agsl(context.getAgsl(), dest);
35        
36        // Copy the MySpace entries.
37        context.getStoreClient().copy(src, destination);
38      }
39      else {
40        throw new MySpaceHandlerException("invalid source or destination");
41      }
42    }
43  }