Update of 
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms
In directory 
james.mmbase.org:/tmp/cvs-serv7965/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms

Modified Files:
        AttachmentUploadAction.java AttachmentDeleteAction.java 
Log Message:
CMSC-1280 - Assets: Relate attachment to content element - New search screen


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms
See also: http://www.mmbase.org/jira/browse/CMSC-1280


Index: AttachmentUploadAction.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/AttachmentUploadAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AttachmentUploadAction.java 6 Jan 2009 07:59:41 -0000       1.1
+++ AttachmentUploadAction.java 20 Feb 2009 02:17:57 -0000      1.2
@@ -5,6 +5,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
@@ -16,6 +17,9 @@
 
 public class AttachmentUploadAction extends AbstractUploadAction {
 
+   private static final String ALL = "all";
+   private static final String CREATION = "creation";
+   
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request,
          HttpServletResponse response, Cloud cloud) throws Exception {
@@ -23,29 +27,35 @@
       AssetUploadForm attachmentUploadForm = (AssetUploadForm) form;
       String parentchannel = attachmentUploadForm.getParentchannel();
       FormFile file = attachmentUploadForm.getFile();
+      String strict = attachmentUploadForm.getStrict();
 
+      String exist = "1";
+      String exceed = "yes";
       int nodeId = 0;
-      String exist = "0";
-      String exceed = "no";
-      NodeManager manager = cloud.getNodeManager("attachments");
-      List<Integer> nodes = null;
 
-      if (file.getFileSize() != 0 && file.getFileName() != null) {
+      if (parentchannel.equalsIgnoreCase(ALL) || 
StringUtils.isEmpty(parentchannel)) {
+         parentchannel = (String) request.getSession().getAttribute(CREATION);
+      }
          int fileSize = file.getFileSize();
          if (maxFileSizeBiggerThan(fileSize)) {
+         NodeManager manager = cloud.getNodeManager("attachments");
+         exceed = "no";
             if (isNewFile(file, manager)) {
+            exist = "0";
+            List<Integer> nodes = null;
                nodes = BulkUploadUtil.store(cloud, manager, parentchannel, 
file);
-               request.setAttribute("uploadedNodes", nodes.size());
+            // to archive the upload asset
+            if (nodes != null) {
+               addRelationsForNodes(nodes, cloud);
+               nodeId = nodes.get(0);
+            }
             } else {
                exist = "1";
             }
          } else {
-            exceed = "yes";
-         }
-         // to archive the upload asset
-         addRelationsForNodes(nodes, cloud);
+         exist = "0";
       }
-      return new ActionForward(mapping.findForward(SUCCESS).getPath() + 
"?uploadAction=select&exist=" + exist
+      return new ActionForward(mapping.findForward(SUCCESS).getPath() + 
"?uploadAction=select&strict=" + strict + "&exist=" + exist
             + "&exceed=" + exceed + "&channelid=" + parentchannel + 
"&uploadedNodes=" + nodeId, true);
    }
 }


Index: AttachmentDeleteAction.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/AttachmentDeleteAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AttachmentDeleteAction.java 6 Jan 2009 07:59:41 -0000       1.1
+++ AttachmentDeleteAction.java 20 Feb 2009 02:17:57 -0000      1.2
@@ -25,6 +25,7 @@
       String channelnumber = getParameter(request, "channelnumber");
       Node channelNode = cloud.getNode(channelnumber);
       String objectnumber = getParameter(request, "objectnumber");
+      String strict = getParameter(request, "strict");
 
       Node objectNode = cloud.getNode(objectnumber);
 
@@ -32,6 +33,6 @@
       RepositoryUtil.removeCreationRelForAsset(objectNode);
       RepositoryUtil.addAssetToChannel(objectNode, 
RepositoryUtil.getTrashNode(cloud));
 
-      return new ActionForward(mapping.findForward(SUCCESS).getPath() + 
"?&channelid=" + channelnumber, true);
+      return new ActionForward(mapping.findForward(SUCCESS).getPath() + 
"?&channelid=" + channelnumber + "&strict=" + strict, true);
    }
 }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to