Author: raintang
Date: 2009-08-20 08:28:50 +0200 (Thu, 20 Aug 2009)
New Revision: 38055

Modified:
   
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/ContentElementUtil.java
   
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentAction.java
   
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentSearchAction.java
   
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchAction.java
   
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchInitAction.java
Log:
CMSC-1476 3 Based on the FD, implement simple editor overview page including: 
head/body/foot page. refact the code

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/ContentElementUtil.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/ContentElementUtil.java
        2009-08-20 02:55:24 UTC (rev 38054)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/ContentElementUtil.java
        2009-08-20 06:28:50 UTC (rev 38055)
@@ -1,11 +1,9 @@
 /*
-
-This software is OSI Certified Open Source Software.
-OSI Certified is a certification mark of the Open Source Initiative.
-
-The license (Mozilla version 1.0) can be read at the MMBase site.
-See http://www.MMBase.org/license
-
+ * 
+ * This software is OSI Certified Open Source Software. OSI Certified is a 
certification mark of the Open Source
+ * Initiative.
+ * 
+ * The license (Mozilla version 1.0) can be read at the MMBase site. See 
http://www.MMBase.org/license
  */
 package com.finalist.cmsc.repository;
 
@@ -16,10 +14,12 @@
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.TreeSet;
 
 import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.struts.util.LabelValueBean;
 import org.mmbase.bridge.Cloud;
 import org.mmbase.bridge.Field;
 import org.mmbase.bridge.Node;
@@ -70,17 +70,15 @@
    private static final String PROPERTY_HIDDEN_TYPES = 
"system.contenttypes.hide";
 
    private static final String SYSTEM_SIMPLEEDITOR_CONTENTTYPES = 
"system.simpleeditor.contenttypes";
-   
+
    private ContentElementUtil() {
       // utility
    }
 
-
    public static NodeManager getNodeManager(Cloud cloud) {
       return cloud.getNodeManager(CONTENTELEMENT);
    }
 
-
    public static List<NodeManager> getContentTypes(Cloud cloud) {
       List<NodeManager> result = new ArrayList<NodeManager>();
       NodeManagerList nml = cloud.getNodeManagers();
@@ -95,7 +93,6 @@
       return result;
    }
 
-
    private static void sortContentTypes(List<NodeManager> result) {
       Collections.sort(result, new Comparator<NodeManager>() {
          public int compare(NodeManager o1, NodeManager o2) {
@@ -104,7 +101,6 @@
       });
    }
 
-
    public static List<NodeManager> getAllowedContentTypes(Cloud cloud, String 
nodeNumber) {
       List<NodeManager> types = new ArrayList<NodeManager>();
 
@@ -119,33 +115,28 @@
       return types;
    }
 
-   
-
    public static boolean isContentElementField(Field field) {
-      Cloud cloud = field.getNodeManager().getCloud();
-      ;
+      Cloud cloud = field.getNodeManager().getCloud();;
       return cloud.getNodeManager(CONTENTELEMENT).hasField(field.getName());
    }
 
-
    /**
     * Is element from one of the content types
-    *
+    * 
     * @param element
     *           node to check
     * @return is content type
     */
    public static boolean isContentElement(Node element) {
       if (element == null) return false;
-      
+
       NodeManager nm = element.getNodeManager();
       return isContentType(nm);
    }
 
-
    /**
     * Is ModeManager of the content types
-    *
+    * 
     * @param nm
     *           NodeManager to check
     * @return is content type
@@ -161,17 +152,15 @@
             nmTemp = nmTemp.getParent();
          }
          return true;
-      }
-      catch (NotFoundException nfe) {
+      } catch (NotFoundException nfe) {
          // Ran out of NodeManager parents
       }
       return false;
    }
 
-
    /**
     * Is type of content type
-    *
+    * 
     * @param type
     *           to check
     * @return is content type
@@ -181,7 +170,6 @@
       return isContentType(nm);
    }
 
-
    public static void removeContentBlock(Node node) {
       List<Node> nodes = findContentBlockNodes(node);
       for (Node removeNode : nodes) {
@@ -189,21 +177,18 @@
       }
    }
 
-
    public static List<Node> findContentBlockNodes(Node node) {
       List<Node> nodes = new ArrayList<Node>();
       findContentBlockNodes(node, nodes, false, false);
       return nodes;
    }
 
-
    public static List<Node> findContentBlockNodesWithRelations(Node node) {
       List<Node> nodes = new ArrayList<Node>();
       findContentBlockNodes(node, nodes, true, false);
       return nodes;
    }
 
-
    public static void findContentBlockNodes(Node node, List<Node> nodes, 
boolean withRelation, boolean remove) {
       if (!remove) {
          if (!nodes.contains(node)) {
@@ -218,15 +203,13 @@
             if (!RepositoryUtil.hasContentChannel(childNode)) {
                findContentBlockNodes(childNode, nodes, withRelation, remove);
             }
-         }
-         else {
+         } else {
             if (!RepositoryUtil.isContentChannel(childNode)) {
                if (remove) {
                   if (childNode.countRelatedNodes(null, null, SOURCE) <= 1) {
                      findContentBlockNodes(childNode, nodes, withRelation, 
remove);
                   }
-               }
-               else {
+               } else {
                   if 
(!TypeUtil.isSystemType(childNode.getNodeManager().getName())) {
                      findContentBlockNodes(childNode, nodes, withRelation, 
remove);
                   }
@@ -251,7 +234,6 @@
       }
    }
 
-
    public static Node createContentElement(Cloud cloud, String manager, String 
creationPath, boolean linkToChannel) {
       Node creationChannel = RepositoryUtil.getChannelFromPath(cloud, 
creationPath);
       if (creationChannel == null) {
@@ -261,7 +243,6 @@
       return createContentElement(cloud, manager, creationChannel, title, 
linkToChannel);
    }
 
-
    public static Node createContentElement(Cloud cloud, String manager, String 
creationPath, String title,
          boolean linkToChannel) {
       Node creationChannel = RepositoryUtil.getChannelFromPath(cloud, 
creationPath);
@@ -271,13 +252,11 @@
       return createContentElement(cloud, manager, creationChannel, title, 
linkToChannel);
    }
 
-
    public static Node createContentElement(Cloud cloud, String manager, Node 
creationChannel, boolean linkToChannel) {
       String title = 
creationChannel.getStringValue(RepositoryUtil.TITLE_FIELD);
       return createContentElement(cloud, manager, creationChannel, title, 
linkToChannel);
    }
 
-
    public static Node createContentElement(Cloud cloud, String manager, Node 
creationChannel, String title,
          boolean linkToChannel) {
       NodeManager contentManager = cloud.getNodeManager(manager);
@@ -290,19 +269,17 @@
       addOwner(content);
       if (linkToChannel) {
          RepositoryUtil.addContentToChannel(content, creationChannel);
-      }
-      else {
+      } else {
          RepositoryUtil.addCreationChannel(content, creationChannel);
       }
       return content;
    }
 
-
    /**
     * Add owner
-    *
-    * @param content -
-    *           content
+    * 
+    * @param content
+    *           - content
     */
    public static void addOwner(Node content) {
       Cloud cloud = content.getCloud();
@@ -312,12 +289,11 @@
       ownerrel.commit();
    }
 
-
    /**
     * Check if a contentnode has an owner
-    *
-    * @param content -
-    *           Content Node
+    * 
+    * @param content
+    *           - Content Node
     * @return true if the node has a related workflowitem
     */
    public static boolean hasOwner(Node content) {
@@ -325,12 +301,11 @@
       return count > 0;
    }
 
-
    /**
     * Get author of the content element
-    *
-    * @param content -
-    *           Content Node
+    * 
+    * @param content
+    *           - Content Node
     * @return Author node
     */
    public static Node getAuthor(Node content) {
@@ -338,12 +313,11 @@
       return SecurityUtil.getUserNode(content.getCloud(), creator);
    }
 
-
    /**
     * Get owner of the content element
-    *
-    * @param content -
-    *           Content Node
+    * 
+    * @param content
+    *           - Content Node
     * @return Owner node
     */
    public static Node getOwner(Node content) {
@@ -354,7 +328,6 @@
       return null;
    }
 
-
    public static void addNotExpiredConstraint(Node channel, NodeQuery query, 
long date) {
       NodeManager contentManager = 
channel.getCloud().getNodeManager(CONTENTELEMENT);
 
@@ -365,7 +338,6 @@
       SearchUtil.addConstraint(query, composite);
    }
 
-
    public static void addLifeCycleConstraint(NodeQuery query, long date) {
       NodeManager contentManager = 
query.getCloud().getNodeManager(CONTENTELEMENT);
 
@@ -379,7 +351,6 @@
       SearchUtil.addConstraint(query, composite);
    }
 
-
    public static void addLifeCycleInverseConstraint(NodeQuery query, long 
date) {
       NodeManager contentManager = 
query.getCloud().getNodeManager(CONTENTELEMENT);
 
@@ -393,7 +364,6 @@
       SearchUtil.addConstraint(query, composite);
    }
 
-
    public static Constraint getUseExpireConstraint(NodeQuery query, 
NodeManager contentManager, Boolean value) {
       Field useExpireField = contentManager.getField(USE_EXPIRY_FIELD);
       Constraint useExpire = 
query.createConstraint(query.getStepField(useExpireField), 
FieldCompareConstraint.EQUAL,
@@ -401,7 +371,6 @@
       return useExpire;
    }
 
-
    public static Constraint getExpireConstraint(NodeQuery query, long date, 
NodeManager contentManager, boolean greater) {
       int operator = (greater ? FieldCompareConstraint.GREATER_EQUAL : 
FieldCompareConstraint.LESS_EQUAL);
 
@@ -411,7 +380,6 @@
       return expirydate;
    }
 
-
    public static Constraint getPublishConstraint(NodeQuery query, long date, 
NodeManager contentManager, boolean greater) {
       int operator = (greater ? FieldCompareConstraint.GREATER_EQUAL : 
FieldCompareConstraint.LESS_EQUAL);
 
@@ -421,7 +389,6 @@
       return publishdate;
    }
 
-
    public static void addArchiveConstraint(Node channel, NodeQuery query, Long 
date, String archive) {
       if (StringUtils.isEmpty(archive) || "all".equalsIgnoreCase(archive)) {
          return;
@@ -435,8 +402,7 @@
       if ("old".equalsIgnoreCase(archive)) {
          archivedate = 
query.createConstraint(query.getStepField(archiveDateField), 
FieldCompareConstraint.LESS_EQUAL,
                archiveDateObj);
-      }
-      else {
+      } else {
          // "new".equalsIgnoreCase(archive)
          archivedate = 
query.createConstraint(query.getStepField(archiveDateField),
                FieldCompareConstraint.GREATER_EQUAL, archiveDateObj);
@@ -444,15 +410,17 @@
       SearchUtil.addConstraint(query, archivedate);
    }
 
-
-    /**
-     * judge if the content's archive date is in the archive time scope
-     * @param content the node to be match
-     * @param archive spcifiy how to calculate the archive time scrop.accept 
"all" "old" or other String as parameter,
-     * @return <li>true if archive is "all" or content is empty.
-     *         <li>true if archive is "old" and content's archive time is 
before current time
-     *         <li>true if archive is others and content's archive time is 
after or equels to current time
-     */
+   /**
+    * judge if the content's archive date is in the archive time scope
+    * 
+    * @param content
+    *           the node to be match
+    * @param archive
+    *           spcifiy how to calculate the archive time scrop.accept "all" 
"old" or other String as parameter,
+    * @return <li>true if archive is "all" or content is empty. <li>true if 
archive is "old" and content's archive time
+    *         is before current time <li>true if archive is others and 
content's archive time is after or equels to
+    *         current time
+    */
    public static boolean matchArchive(Node content, String archive) {
       if (StringUtils.isEmpty(archive) || "all".equalsIgnoreCase(archive)) {
          return true;
@@ -466,21 +434,20 @@
       Date archiveDate = content.getDateValue(ARCHIVEDATE_FIELD);
       if ("old".equalsIgnoreCase(archive)) {
          return archiveDate.getTime() < date;
-      }
-      else {
+      } else {
          return archiveDate.getTime() >= date;
       }
    }
 
    /**
     * Helper method to get all hidden types
-    *
+    * 
     * @return List of hidden types
     */
    public static List<String> getHiddenTypes() {
       return getProperty(PROPERTY_HIDDEN_TYPES);
    }
-   
+
    /**
     * Helper method to get all valid simple editor's types
     * 
@@ -506,9 +473,12 @@
       }
       return simpleEditorTypes;
    }
+
    /**
     * Helper method to get properties from System Property
-    * @param propertyKey the key of property,
+    * 
+    * @param propertyKey
+    *           the key of property,
     * @return List of the value, if the value is separated by comma,return the 
list
     */
    public static List<String> getProperty(String propertyKey) {
@@ -524,4 +494,42 @@
       }
       return list;
    }
+
+   /**
+    * Return a valid type list, not including those belong to hidden types
+    * 
+    * @param cloud
+    * @param request
+    * @param types
+    */
+   public static List<LabelValueBean> getValidTypesList(Cloud cloud, 
List<NodeManager> types) {
+      List<LabelValueBean> typesList = new ArrayList<LabelValueBean>();
+      List<String> hiddenTypes = getHiddenTypes();
+      for (NodeManager manager : types) {
+         String name = manager.getName();
+         if (!hiddenTypes.contains(name)) {
+            LabelValueBean bean = new LabelValueBean(manager.getGUIName(), 
name);
+            typesList.add(bean);
+         }
+      }
+      return typesList;
+   }
+
+   /**
+    * 
+    * @param cloud
+    * @param types
+    * @return
+    */
+   public static TreeSet<Integer> getValidTypes(Cloud cloud, List<NodeManager> 
types) {
+      List<String> hiddenTypes = getHiddenTypes();
+      TreeSet<Integer> validTypes = null;
+      for (NodeManager manager : types) {
+         String name = manager.getName();
+         if (!hiddenTypes.contains(name)) {
+            validTypes.add(manager.getNumber());
+         }
+      }
+      return validTypes;
+   }
 }

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentAction.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentAction.java
       2009-08-20 02:55:24 UTC (rev 38054)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentAction.java
       2009-08-20 06:28:50 UTC (rev 38055)
@@ -1,54 +1,48 @@
 /*
-
-This software is OSI Certified Open Source Software.
-OSI Certified is a certification mark of the Open Source Initiative.
-
-The license (Mozilla version 1.0) can be read at the MMBase site.
-See http://www.MMBase.org/license
-
+ * 
+ * This software is OSI Certified Open Source Software. OSI Certified is a 
certification mark of the Open Source
+ * Initiative.
+ * 
+ * The license (Mozilla version 1.0) can be read at the MMBase site. See 
http://www.MMBase.org/license
  */
 package com.finalist.cmsc.repository.forms;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 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;
+import org.mmbase.bridge.Cloud;
+import org.mmbase.bridge.Node;
+import org.mmbase.bridge.NodeList;
+import org.mmbase.bridge.NodeManager;
 
-import org.apache.struts.action.*;
-import org.apache.struts.util.LabelValueBean;
-import org.mmbase.bridge.*;
-
 import com.finalist.cmsc.mmbase.PropertiesUtil;
 import com.finalist.cmsc.repository.ContentElementUtil;
 import com.finalist.cmsc.repository.RepositoryUtil;
 import com.finalist.cmsc.struts.MMBaseAction;
 
 public class ContentAction extends MMBaseAction {
-   
+
    private final static String MOVECONTENTTOCHANNEL = "moveContentToChannel";
+
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request,
          HttpServletResponse response, Cloud cloud) throws Exception {
 
       String action = request.getParameter("action");
-      if(StringUtils.isNotEmpty(action) && 
action.equals(MOVECONTENTTOCHANNEL)) {
+      if (StringUtils.isNotEmpty(action) && 
action.equals(MOVECONTENTTOCHANNEL)) {
          return mapping.findForward(MOVECONTENTTOCHANNEL);
       }
-      List<LabelValueBean> typesList = new ArrayList<LabelValueBean>();
-
       List<NodeManager> types = ContentElementUtil.getContentTypes(cloud);
-      List<String> hiddenTypes = ContentElementUtil.getHiddenTypes();
-      for (NodeManager manager : types) {
-         String name = manager.getName();
-         if (!hiddenTypes.contains(name)) {
-            LabelValueBean bean = new LabelValueBean(manager.getGUIName(), 
name);
-            typesList.add(bean);
-         }
-      }
-      addToRequest(request, "typesList", typesList);
-
+      addToRequest(request, "typesList", 
ContentElementUtil.getValidTypesList(cloud, types));
       String parentchannel = request.getParameter("parentchannel");
       String orderby = request.getParameter("orderby");
       String direction = request.getParameter("direction");
@@ -56,27 +50,28 @@
          orderby = null;
       }
       if (StringUtils.isEmpty(direction)) {
-        direction = null;
+         direction = null;
       }
 
       // Set the offset (used for paging).
       String offsetString = request.getParameter("offset");
       int offset = 0;
       if (offsetString != null && offsetString.matches("\\d+")) {
-         offset = Integer.parseInt(offsetString);
+         offset = Integer.parseInt(offsetString);
       }
-      
+
       // Set the maximum result size.
       String resultsPerPage = 
PropertiesUtil.getProperty(SearchAction.REPOSITORY_SEARCH_RESULTS_PER_PAGE);
       int maxNumber = 25;
       if (resultsPerPage != null && resultsPerPage.matches("\\d+")) {
-         maxNumber = Integer.parseInt(resultsPerPage);
+         maxNumber = Integer.parseInt(resultsPerPage);
       }
       addToRequest(request, "resultsPerPage", Integer.toString(maxNumber));
-      
+
       if (StringUtils.isNotEmpty(parentchannel)) {
          Node channel = cloud.getNode(parentchannel);
-         NodeList elements = RepositoryUtil.getLinkedElements(channel, null, 
orderby, direction, false, offset*maxNumber, maxNumber, -1, -1, -1);
+         NodeList elements = RepositoryUtil.getLinkedElements(channel, null, 
orderby, direction, false, offset
+               * maxNumber, maxNumber, -1, -1, -1);
          int elementCount = RepositoryUtil.countLinkedContent(channel);
          addToRequest(request, "direction", direction);
          addToRequest(request, "orderby", orderby);
@@ -87,7 +82,7 @@
             addToRequest(request, "message", (String) 
request.getSession().getAttribute("message"));
             request.getSession().removeAttribute("message");
          }
-         
+
          NodeList created = RepositoryUtil.getCreatedElements(channel);
          Map<String, Node> createdNumbers = new HashMap<String, Node>();
          for (Iterator<Node> iter = created.iterator(); iter.hasNext();) {
@@ -95,17 +90,17 @@
             createdNumbers.put(String.valueOf(createdElement.getNumber()), 
createdElement);
          }
          addToRequest(request, "createdNumbers", createdNumbers);
-         //cmsc-1205 don't refresh channel tree when not necessary
+         // cmsc-1205 don't refresh channel tree when not necessary
          String type = request.getParameter("type");
-         //cmsc-144 make reorder icon show up
-         if(elementCount==2&& type != null){
-                request.setAttribute("refresh", true);
+         // cmsc-144 make reorder icon show up
+         if (elementCount == 2 && type != null) {
+            request.setAttribute("refresh", true);
          }
-         //reset the show mode of assets in the session when enter another 
channel
-         if(type==null){
+         // reset the show mode of assets in the session when enter another 
channel
+         if (type == null) {
             request.getSession().removeAttribute("show");
             request.getSession().removeAttribute("imageOnly");
-           }
+         }
       }
       return mapping.findForward(SUCCESS);
    }

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentSearchAction.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentSearchAction.java
 2009-08-20 02:55:24 UTC (rev 38054)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ContentSearchAction.java
 2009-08-20 06:28:50 UTC (rev 38055)
@@ -1,6 +1,5 @@
 package com.finalist.cmsc.repository.forms;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -13,7 +12,6 @@
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
-import org.apache.struts.util.LabelValueBean;
 import org.mmbase.bridge.Cloud;
 import org.mmbase.bridge.Field;
 import org.mmbase.bridge.FieldIterator;
@@ -85,7 +83,7 @@
       request.setAttribute("index", index);
       request.setAttribute("title", searchForm.getTitle());
       request.setAttribute(ONLYTYPE, onlytype);
-      
+
       if (StringUtils.isNotEmpty(deleteContentRequest)) {
          if (deleteContentRequest.startsWith("massDelete:")) {
             massDeleteContent(deleteContentRequest.substring(11), cloud);
@@ -99,28 +97,18 @@
       }
 
       // First prepare the typeList, we'll need this one anyway:
-      List<LabelValueBean> typesList = new ArrayList<LabelValueBean>();
-      TreeSet<Integer> validTypes = new TreeSet<Integer>();
 
       List<NodeManager> types;
-      if(StringUtils.isEmpty(portletId)){
-         types = ContentElementUtil.getContentTypes(cloud);
+      if (StringUtils.isEmpty(portletId)) {
+         types = ContentElementUtil.getContentTypes(cloud);
       } else {
          types = ContentElementUtil.getAllowedContentTypes(cloud, portletId);
-          if(types.size() == 0){
-                 types = ContentElementUtil.getContentTypes(cloud);
-          }
-      }
-      List<String> hiddenTypes = ContentElementUtil.getHiddenTypes();
-      for (NodeManager manager : types) {
-         String name = manager.getName();
-         if (!hiddenTypes.contains(name)) {
-            LabelValueBean bean = new LabelValueBean(manager.getGUIName(), 
name);
-            typesList.add(bean);
-            validTypes.add(manager.getNumber());
+         if (types.size() == 0) {
+            types = ContentElementUtil.getContentTypes(cloud);
          }
       }
-      addToRequest(request, TYPES_LIST, typesList);
+      addToRequest(request, "typesList", 
ContentElementUtil.getValidTypesList(cloud, types));
+      TreeSet<Integer> validTypes = ContentElementUtil.getValidTypes(cloud, 
types);
 
       // Switching tab, no searching.
       if ("false".equalsIgnoreCase(searchForm.getSearch())) {
@@ -185,13 +173,17 @@
 
       // Set some date constraints.
       queryStringComposer.addParameter(ContentElementUtil.CREATIONDATE_FIELD, 
"" + searchForm.getCreationdate());
-      SearchUtil.addDayConstraint(query, nodeManager, 
ContentElementUtil.CREATIONDATE_FIELD, searchForm.getCreationdate());
+      SearchUtil.addDayConstraint(query, nodeManager, 
ContentElementUtil.CREATIONDATE_FIELD, searchForm
+            .getCreationdate());
       queryStringComposer.addParameter(ContentElementUtil.PUBLISHDATE_FIELD, 
"" + searchForm.getPublishdate());
-      SearchUtil.addDayConstraint(query, nodeManager, 
ContentElementUtil.PUBLISHDATE_FIELD, searchForm.getPublishdate());
+      SearchUtil
+            .addDayConstraint(query, nodeManager, 
ContentElementUtil.PUBLISHDATE_FIELD, searchForm.getPublishdate());
       queryStringComposer.addParameter(ContentElementUtil.EXPIREDATE_FIELD, "" 
+ searchForm.getExpiredate());
       SearchUtil.addDayConstraint(query, nodeManager, 
ContentElementUtil.EXPIREDATE_FIELD, searchForm.getExpiredate());
-      
queryStringComposer.addParameter(ContentElementUtil.LASTMODIFIEDDATE_FIELD, "" 
+ searchForm.getLastmodifieddate());
-      SearchUtil.addDayConstraint(query, nodeManager, 
ContentElementUtil.LASTMODIFIEDDATE_FIELD, searchForm.getLastmodifieddate());
+      queryStringComposer
+            .addParameter(ContentElementUtil.LASTMODIFIEDDATE_FIELD, "" + 
searchForm.getLastmodifieddate());
+      SearchUtil.addDayConstraint(query, nodeManager, 
ContentElementUtil.LASTMODIFIEDDATE_FIELD, searchForm
+            .getLastmodifieddate());
 
       // Perhaps we have some more constraints if the nodetype was specified 
(=> not contentelement).
       if 
(!ContentElementUtil.CONTENTELEMENT.equalsIgnoreCase(nodeManager.getName())) {
@@ -203,13 +195,13 @@
             String paramName = nodeManager.getName() + "." + field.getName();
             String paramValue = request.getParameter(paramName);
             if (StringUtils.isNotEmpty(paramValue)) {
-               //CMSC-1116 advanced search for dynamic form save answer gives 
500 error
-               //The following if to deal with INTEGER field
-               if(field.getType() == Field.TYPE_INTEGER){
-                  FieldValueConstraint fvc = 
SearchUtil.createEqualConstraint(query, nodeManager, field.getName(), 
Integer.parseInt(paramValue));
+               // CMSC-1116 advanced search for dynamic form save answer gives 
500 error
+               // The following if to deal with INTEGER field
+               if (field.getType() == Field.TYPE_INTEGER) {
+                  FieldValueConstraint fvc = 
SearchUtil.createEqualConstraint(query, nodeManager, field.getName(),
+                        Integer.parseInt(paramValue));
                   SearchUtil.addConstraint(query, fvc);
-               }
-               else{
+               } else {
                   SearchUtil.addLikeConstraint(query, field, 
paramValue.trim());
                   queryStringComposer.addParameter(paramName, paramValue);
                }
@@ -226,11 +218,11 @@
          SearchUtil.addConstraint(query, titleConstraint);
       }
 
-      //if in simple search mode, add input to the keyword search too
-      //And add ordinary keywords
+      // if in simple search mode, add input to the keyword search too
+      // And add ordinary keywords
       List<String> keywords = searchKeywords(request.getParameter(MODE), 
searchForm);
       addKeyConstraint(searchForm, nodeManager, queryStringComposer, query, 
keywords);
-      
+
       // Set the objectid constraint
       if (StringUtils.isNotEmpty(searchForm.getObjectid())) {
          String stringObjectId = searchForm.getObjectid();
@@ -325,7 +317,8 @@
       return keywords;
    }
 
-   private void addKeyConstraint(SearchForm searchForm, NodeManager 
nodeManager, QueryStringComposer queryStringComposer, NodeQuery query, 
List<String> keywords) {
+   private void addKeyConstraint(SearchForm searchForm, NodeManager 
nodeManager,
+         QueryStringComposer queryStringComposer, NodeQuery query, 
List<String> keywords) {
       if (keywords == null) return;
 
       queryStringComposer.addParameter(ContentElementUtil.KEYWORD_FIELD, 
searchForm.getKeywords());
@@ -376,7 +369,7 @@
       RepositoryUtil.removeContentFromAllChannels(objectNode);
       RepositoryUtil.addContentToChannel(objectNode, 
RepositoryUtil.getTrash(cloud));
 
-      // unpublish and remove from workflow
+      // Unpublish and remove from workflow
       Publish.remove(objectNode);
       Workflow.remove(objectNode);
       Publish.unpublish(objectNode);

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchAction.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchAction.java
        2009-08-20 02:55:24 UTC (rev 38054)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchAction.java
        2009-08-20 06:28:50 UTC (rev 38055)
@@ -74,15 +74,7 @@
         List<LabelValueBean> typesList = new ArrayList<LabelValueBean>();
 
         List<NodeManager> types = ContentElementUtil.getContentTypes(cloud);
-        List<String> hiddenTypes = ContentElementUtil.getHiddenTypes();
-        for (NodeManager manager : types) {
-            String name = manager.getName();
-            if (!hiddenTypes.contains(name)) {
-                LabelValueBean bean = new LabelValueBean(manager.getGUIName(), 
name);
-                typesList.add(bean);
-            }
-        }
-        addToRequest(request, "typesList", typesList);
+        addToRequest(request,"typesList", 
ContentElementUtil.getValidTypesList(cloud, types));
 
         // Switching tab, no searching.
         if ("false".equalsIgnoreCase(searchForm.getSearch())) {

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchInitAction.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchInitAction.java
    2009-08-20 02:55:24 UTC (rev 38054)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/SearchInitAction.java
    2009-08-20 06:28:50 UTC (rev 38055)
@@ -65,15 +65,7 @@
                     types = ContentElementUtil.getContentTypes(cloud);
           }
       }
-      List<String> hiddenTypes = ContentElementUtil.getHiddenTypes();
-      for (NodeManager manager : types) {
-         String name = manager.getName();
-         if (!hiddenTypes.contains(name)) {
-            LabelValueBean bean = new LabelValueBean(manager.getGUIName(), 
name);
-            typesList.add(bean);
-         }
-      }
-      addToRequest(request, TYPES_LIST, typesList);
+      addToRequest(request,"typesList", 
ContentElementUtil.getValidTypesList(cloud, types));
       addToRequest(request, PORTLET_ID, portletId);
       addToRequest(request, POSITION, position);
       addToRequest(request, TITLE, searchForm.getTitle());

_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to