1 package org.astrogrid.portal.myspace.acting.framework;
2
3 /***
4 * Create a MySpace handler based on the action value.
5 *
6 * @author peter.shillan
7 */
8 public class MySpaceHandlerFactory {
9
10 private static final String ACTION_CHANGE = "myspace-change";
11 private static final String ACTION_COPY = "myspace-copy";
12 private static final String ACTION_DELETE = "myspace-delete";
13 private static final String ACTION_FIND_URL = "myspace-find-url";
14 private static final String ACTION_MOVE = "myspace-move";
15 private static final String ACTION_NEW_CONTAINER = "myspace-new-container";
16 private static final String ACTION_UPLOAD = "myspace-upload";
17 private static final String ACTION_UPLOAD_URL = "myspace-upload-url";
18
19 /***
20 * Create a MySpace handler based on the action value.
21 *
22 * @param action MySpace action to perform
23 * @param context environment context
24 */
25
26 public static MySpaceHandler getMySpaceHandler(String action, ContextWrapper context) {
27 AbstractMySpaceHandler result = null;
28
29 if(action != null && action.length() > 0) {
30 if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_CHANGE)) {
31 result = new ChangeHandler(context);
32 }
33 else if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_COPY)) {
34 result = new CopyHandler(context);
35 }
36 else if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_DELETE)) {
37 result = new DeleteHandler(context);
38 }
39 else if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_FIND_URL)) {
40 result = new FindURLHandler(context);
41 }
42 else if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_MOVE)) {
43 result = new MoveHandler(context);
44 }
45 else if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_NEW_CONTAINER)) {
46 result = new NewContainerHandler(context);
47 }
48 else if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_UPLOAD)) {
49 result = new UploadHandler(context);
50 }
51 else if(action.equalsIgnoreCase(MySpaceHandlerFactory.ACTION_UPLOAD_URL)) {
52 result = new UploadURLHandler(context);
53 }
54 }
55
56 return result;
57 }
58
59 /***
60 * No instances allowed.
61 */
62 private MySpaceHandlerFactory() {
63 super();
64 }
65 }