Source code: org/acs/damsel/client/cb/CbCollectionInfoAction.java
1 package org.acs.damsel.client.cb;
2
3 import org.apache.struts.action.*;
4 import org.apache.log4j.*;
5 import javax.servlet.http.*;
6
7 import org.acs.damsel.client.ClientApp;
8 import org.acs.damsel.srvr.collection.*;
9 import org.acs.damsel.srvr.Config;
10
11 public class CbCollectionInfoAction extends Action {
12
13 private Logger log = Logger.getLogger(CbCollectionInfoAction.class);
14
15 public CbCollectionInfoAction(){
16 BasicConfigurator.resetConfiguration();
17 PropertyConfigurator.configure(Config.instance().getLogPropertiesFileName());
18 }
19
20 public ActionForward execute(ActionMapping actionMapping,
21 ActionForm actionForm,
22 HttpServletRequest httpServletRequest,
23 HttpServletResponse httpServletResponse) {
24 CbCollectionInfoForm cbCollectionInfoForm = (CbCollectionInfoForm) actionForm;
25 ActionErrors errors;
26
27 String collectionName = cbCollectionInfoForm.getCollectionName();
28
29 /*Check for a blank collection name */
30 if (collectionName.trim().equals("")) {
31 errors = new ActionErrors();
32 errors.add("cb", new ActionError("collection.name.blank"));
33 this.saveErrors(httpServletRequest, errors);
34 return actionMapping.findForward("failure");
35 }
36
37 /*Check if the user selected private/public */
38 if (cbCollectionInfoForm.getPrivateCollection().trim().equals("")) {
39 errors = new ActionErrors();
40 errors.add("cb", new ActionError("private.public.not.selected"));
41 this.saveErrors(httpServletRequest, errors);
42 return actionMapping.findForward("failure");
43 }
44
45 // Get the collectionName from the form. Check if it is unique. If not, post
46 // errors and forward back to the page, displaying the errors.
47 // @todo Change the null collection check to user isCollectionInDB(String)
48
49 Collection collection = null;
50
51
52 collection = ClientApp.instance().getCollectionMgr().getCollection(collectionName);
53
54
55 if (collection != null) {
56 errors = new ActionErrors();
57 errors.add("cb", new ActionError("collection.exists"));
58 this.saveErrors(httpServletRequest, errors);
59 return actionMapping.findForward("failure");
60 }
61
62 // Get the private/public field and forward to GroupInfo page if collection
63 // is private. Forward to SchemaInfo if collection is public.
64
65 String isCollecPrivate = cbCollectionInfoForm.getPrivateCollection();
66 if(isCollecPrivate.equals("true")){
67 return actionMapping.findForward("private");
68 }
69
70 else if(isCollecPrivate.equals("false")){
71 return actionMapping.findForward("public");
72 }
73 return actionMapping.findForward("success"); //or is it faillure?
74
75 }
76 }