Source code: org/acs/damsel/client/remove/removeCollectionAction.java
1 package org.acs.damsel.client.remove;
2
3 import java.sql.*;
4 import java.util.*;
5 import javax.servlet.http.*;
6
7 import org.acs.damsel.srvr.db.*;
8 import org.apache.struts.action.*;
9 import org.acs.damsel.srvr.schema.SchemaException;
10
11 public class removeCollectionAction
12 extends Action {
13 public ActionForward execute(ActionMapping actionMapping,
14 ActionForm actionForm,
15 HttpServletRequest httpServletRequest,
16 HttpServletResponse httpServletResponse) {
17 /**@todo: complete the business logic here, this is just a skeleton.*/
18 removeCollectionForm removeCollectionForm = (removeCollectionForm)
19 actionForm;
20 ActionErrors errors;
21 /*We need to check if a MetaData Tag has been selected from the MetaData pull
22 down menu in removeCollecction.jsp. In other words, we need to check if this
23 Action was invoked by the onChange event in the MetaData pull down or a
24 submit event from the submit button. isCheckOrderBy will be true if
25 a MetaData Tag has been selected from the MetaData pull down menu...*/
26 if (removeCollectionForm.isCheckOrderBy()) {
27 removeCollectionForm.setCheckOrderBy(false);
28 return actionMapping.findForward("failure");
29 }
30
31 try {
32 AssetDB assetDB = AssetDB.instance();
33 String value;
34 String name;
35 String potentialName;
36 Vector collectionsToDelete = new Vector();
37
38 for (Enumeration e = httpServletRequest.getParameterNames();
39 e.hasMoreElements(); ) {
40 potentialName = (String) e.nextElement();
41
42 if (potentialName.indexOf("remove") != -1) {
43 name = potentialName.substring(potentialName.indexOf("remove") + 6);
44 value = httpServletRequest.getParameter(potentialName);
45 if (value.equals("true")) {
46 collectionsToDelete.addElement(name);
47 assetDB.deleteCollection(name);
48 }
49 }
50 }
51 httpServletRequest.getSession().setAttribute("collectionsToDelete",
52 collectionsToDelete);
53 }
54 catch (SQLException ex) {
55 errors = new ActionErrors();
56 errors.add("removeCollection", new ActionError("removeCollection.caught.exception"));
57 this.saveErrors(httpServletRequest, errors);
58 return (actionMapping.findForward("failure"));
59 }
60 catch (SchemaException ex2) {
61 errors = new ActionErrors();
62 errors.add("removeCollection", new ActionError("removeCollection.caught.exception"));
63 this.saveErrors(httpServletRequest, errors);
64 return (actionMapping.findForward("failure"));
65 }
66 return actionMapping.findForward("success");
67 }
68
69 }