Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/acs/damsel/client/add/AddAssetToCollectionAction.java


1   package org.acs.damsel.client.add;
2   
3   import org.apache.struts.action.*;
4   import javax.servlet.http.*;
5   import org.acs.damsel.client.ClientApp;
6   import org.acs.damsel.srvr.asset.*;
7   import java.sql.*;
8   
9   public class AddAssetToCollectionAction extends Action {
10  
11    public ActionForward execute(ActionMapping actionMapping,
12                                 ActionForm actionForm,
13                                 HttpServletRequest httpServletRequest,
14                                 HttpServletResponse httpServletResponse) {
15  
16      AddAssetToCollectionForm addAssetToCollectionForm = (AddAssetToCollectionForm) actionForm;
17  
18      String addToCollectionSelect = addAssetToCollectionForm.getAddToCollectionSelect();
19      String assetSelect = addAssetToCollectionForm.getAssetSelect();
20      String action = addAssetToCollectionForm.getActionType();
21  
22      if (action.equals("refresh"))
23        return actionMapping.findForward("refresh");
24      if (action.equals("submit")) {
25        try {
26          Asset asset = ClientApp.instance().getRepositoryMgr().getAsset(
27              assetSelect);
28          ClientApp.instance().getCollectionMgr().addAssetToCollection(
29              assetSelect,
30              addToCollectionSelect);
31        }
32        catch (SQLException ex) {
33          ActionErrors errors = new ActionErrors();
34        errors.add("asset", new ActionError("asset.not.added.to.collection"));
35        this.saveErrors(httpServletRequest, errors);
36        return actionMapping.findForward("refresh");
37        }
38      }
39      addAssetToCollectionForm.setCollectionSelect("");
40      return actionMapping.findForward("success");
41    }
42  }