You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2011/01/23 20:31:39 UTC

svn commit: r1062501 [1/3] - in /ofbiz/trunk/applications/content/src/org/ofbiz/content: ContentManagementEvents.java ContentManagementServices.java ContentManagementWorker.java

Author: mrisaliti
Date: Sun Jan 23 19:31:39 2011
New Revision: 1062501

URL: http://svn.apache.org/viewvc?rev=1062501&view=rev
Log:
Remove some java compilation warnings of ContentManagementEvents/ContentManagementServices/ContentManagementWorker (OFBIZ-4102)

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java?rev=1062501&r1=1062500&r2=1062501&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java Sun Jan 23 19:31:39 2011
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -34,6 +35,7 @@ import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
@@ -55,7 +57,6 @@ public class ContentManagementEvents {
     public static final String module = ContentManagementEvents.class.getName();
 
     public static String updateStaticValues(HttpServletRequest request, HttpServletResponse response) {
-
         HttpSession session = request.getSession();
         Security security = (Security)request.getAttribute("security");
         GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
@@ -63,16 +64,16 @@ public class ContentManagementEvents {
         String webSiteId = (String) servletContext.getAttribute("webSiteId");
         Delegator delegator = (Delegator)request.getAttribute("delegator");
         LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
-        Map paramMap = UtilHttp.getParameterMap(request);
-                //if (Debug.infoOn()) Debug.logInfo("in updateStaticValues, paramMap:" + paramMap , module);
+        Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
+        //if (Debug.infoOn()) Debug.logInfo("in updateStaticValues, paramMap:" + paramMap , module);
         String parentPlaceholderId = (String)paramMap.get("ph");
         if (UtilValidate.isEmpty(parentPlaceholderId)) {
             request.setAttribute("_ERROR_MESSAGE_", "ParentPlaceholder is empty.");
             return "error";
         }
-        List allPublishPointList = null;
-        List permittedPublishPointList = null;
-        List valueList = null;
+        List<GenericValue> allPublishPointList = null;
+        List<String []> permittedPublishPointList = null;
+        List<Map<String, Object>> valueList = null;
         try {
             allPublishPointList = ContentManagementWorker.getAllPublishPoints(delegator, webSiteId);
             permittedPublishPointList = ContentManagementWorker.getPermittedPublishPoints(delegator, allPublishPointList, userLogin, security, "_ADMIN", null, null);
@@ -98,22 +99,22 @@ public class ContentManagementEvents {
         }
 */
 
-        Iterator it = valueList.iterator();
+        Iterator<Map<String, Object>> it = valueList.iterator();
         int counter = 0;
         while (it.hasNext()) {
-            Map map = (Map)it.next();
+            Map<String, Object> map = it.next();
             String contentId = (String)map.get("contentId");
             //Integer idxObj = (Integer)contentIdLookup.get(contentId);
             //int idx = idxObj.intValue();
-            Iterator itPubPt = permittedPublishPointList.iterator();
+            Iterator<String []> itPubPt = permittedPublishPointList.iterator();
             while (itPubPt.hasNext()) {
-                String [] pubArr = (String [])itPubPt.next();
+                String [] pubArr = itPubPt.next();
                 String pubContentId = pubArr[0];
                 String pubValue = (String)map.get(pubContentId);
                 String paramName = Integer.toString(counter)  + "_" + pubContentId;
                 String paramValue = (String)paramMap.get(paramName);
                 //if (Debug.infoOn()) Debug.logInfo("in updateStaticValues, contentId:" + contentId + " pubContentId:" + pubContentId + " pubValue:" + pubValue + " paramName:" + paramName + " paramValue:" + paramValue, module);
-                Map serviceIn = FastMap.newInstance();
+                Map<String, Object> serviceIn = FastMap.newInstance();
                 serviceIn.put("userLogin", userLogin);
                 serviceIn.put("contentIdTo", contentId);
                 serviceIn.put("contentId", pubContentId);
@@ -123,12 +124,12 @@ public class ContentManagementEvents {
                         if (!paramValue.equals(pubValue)) {
                             if (paramValue.equalsIgnoreCase("Y")) {
                                 serviceIn.put("fromDate", UtilDateTime.nowTimestamp());
-                                Map results = dispatcher.runSync("createContentAssoc", serviceIn);
+                                dispatcher.runSync("createContentAssoc", serviceIn);
                             } else if (paramValue.equalsIgnoreCase("N") && pubValue.equalsIgnoreCase("Y")) {
                                 serviceIn.put("thruDate", UtilDateTime.nowTimestamp());
                                 Timestamp fromDate = (Timestamp)map.get(pubContentId + "FromDate");
                                 serviceIn.put("fromDate", fromDate);
-                                Map results = dispatcher.runSync("updateContentAssoc", serviceIn);
+                                dispatcher.runSync("updateContentAssoc", serviceIn);
                             }
                         }
                     } else if (UtilValidate.isNotEmpty(pubValue)) {
@@ -136,7 +137,7 @@ public class ContentManagementEvents {
                                 serviceIn.put("thruDate", UtilDateTime.nowTimestamp());
                                 Timestamp fromDate = (Timestamp)map.get(pubContentId + "FromDate");
                                 serviceIn.put("fromDate", fromDate);
-                                Map results = dispatcher.runSync("updateContentAssoc", serviceIn);
+                                dispatcher.runSync("updateContentAssoc", serviceIn);
                         }
                     }
                 } catch (GenericServiceException e) {
@@ -156,7 +157,6 @@ public class ContentManagementEvents {
     }
 
     public static String updatePublishLinks(HttpServletRequest request, HttpServletResponse response) {
-
         HttpSession session = request.getSession();
         Security security = (Security)request.getAttribute("security");
         GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
@@ -164,8 +164,8 @@ public class ContentManagementEvents {
         String webSiteId = (String) servletContext.getAttribute("webSiteId");
         Delegator delegator = (Delegator)request.getAttribute("delegator");
         LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
-        Map paramMap = UtilHttp.getParameterMap(request);
-                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, paramMap:" + paramMap , module);
+        Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
+        //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, paramMap:" + paramMap , module);
         String targContentId = (String)paramMap.get("contentId"); // The content to be linked to one or more sites
         String roles = null;
         String authorId = null;
@@ -179,14 +179,14 @@ public class ContentManagementEvents {
 
         // Determine if user is owner of target content
         String userLoginId = userLogin.getString("userLoginId");
-                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, userLoginId:" + userLoginId + " authorId:" + authorId , module);
-        List roleTypeList = null;
+        //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, userLoginId:" + userLoginId + " authorId:" + authorId , module);
+        List<String> roleTypeList = null;
         if (authorId != null && userLoginId != null && authorId.equals(userLoginId)) {
             roles = "OWNER";
             roleTypeList = StringUtil.split(roles, "|");
         }
-        List targetOperationList = UtilMisc.toList("CONTENT_PUBLISH");
-        List contentPurposeList = null; //UtilMisc.toList("ARTICLE");
+        List<String> targetOperationList = UtilMisc.<String>toList("CONTENT_PUBLISH");
+        List<String> contentPurposeList = null; //UtilMisc.toList("ARTICLE");
         //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, roles:" + roles +" roleTypeList:" + roleTypeList , module);
         String permittedAction = (String)paramMap.get("permittedAction"); // The content to be linked to one or more sites
         String permittedOperations = (String)paramMap.get("permittedOperations"); // The content to be linked to one or more sites
@@ -196,10 +196,10 @@ public class ContentManagementEvents {
         }
 
         // Get all the subSites that the user is permitted to link to
-        List origPublishedLinkList = null;
+        List<Object []> origPublishedLinkList = null;
         try {
             // TODO: this needs to be given author userLogin
-            GenericValue authorUserLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", authorId));
+            delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", authorId));
             origPublishedLinkList = ContentManagementWorker.getPublishedLinks(delegator, targContentId, webSiteId, userLogin, security, permittedAction, permittedOperations, roles);
         } catch (GenericEntityException e) {
             request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -212,11 +212,11 @@ public class ContentManagementEvents {
 
         // make a map of the values that are passed in using the top subSite as the key.
         // Content can only be linked to one subsite under a top site (ends with "_MASTER")
-        Set keySet = paramMap.keySet();
-        Iterator itKeySet = keySet.iterator();
-        Map siteIdLookup = FastMap.newInstance();
+        Set<String> keySet = paramMap.keySet();
+        Iterator<String> itKeySet = keySet.iterator();
+        Map<String, String> siteIdLookup = FastMap.newInstance();
         while (itKeySet.hasNext()) {
-            String param = (String)itKeySet.next();
+            String param = itKeySet.next();
             int pos = param.indexOf("select_");
                 //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, param:" + param + " pos:" + pos , module);
             if (pos >= 0) {
@@ -225,30 +225,29 @@ public class ContentManagementEvents {
                 siteIdLookup.put(siteId, subSiteVal);
             }
         }
-
-                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, siteIdLookup:" + siteIdLookup , module);
+        //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, siteIdLookup:" + siteIdLookup , module);
 
         // Loop thru all the possible subsites
-        Iterator it = origPublishedLinkList.iterator();
+        Iterator<Object []> it = origPublishedLinkList.iterator();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
-        int counter = 0;
+        // int counter = 0;
         String responseMessage = null;
         String errorMessage = null;
-        String permissionMessage = null;
+        // String permissionMessage = null;
         boolean statusIdUpdated = false;
-        Map results = null;
+        Map<String, Object> results = null;
         while (it.hasNext()) {
             Object [] arr = (Object [])it.next();
-                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, arr:" + Arrays.asList(arr) , module);
+            //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, arr:" + Arrays.asList(arr) , module);
             String contentId = (String)arr[0]; // main (2nd level) site id
             String origSubContentId = null;
-            List origSubList = (List)arr[1];
-            Timestamp topFromDate = (Timestamp)arr[3];
+            List<Object []> origSubList = UtilGenerics.checkList(arr[1]);
+            // Timestamp topFromDate = (Timestamp)arr[3];
             Timestamp origFromDate = null;
-            Iterator itOrigSubPt = origSubList.iterator();
+            Iterator<Object []> itOrigSubPt = origSubList.iterator();
             // see if a link already exists by looking for non-null fromDate
             while (itOrigSubPt.hasNext()) {
-                Object [] pubArr = (Object [])itOrigSubPt.next();
+                Object [] pubArr = itOrigSubPt.next();
                 //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, pubArr:" + Arrays.asList(pubArr) , module);
                 Timestamp fromDate = (Timestamp)pubArr[2];
                 origSubContentId = null;
@@ -260,24 +259,24 @@ public class ContentManagementEvents {
             }
 
             String currentSubContentId = (String)siteIdLookup.get(contentId);
-                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, currentSubContentId:" + currentSubContentId , module);
-                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, origSubContentId:" + origSubContentId , module);
+            //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, currentSubContentId:" + currentSubContentId , module);
+            //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, origSubContentId:" + origSubContentId , module);
             try {
                 if (UtilValidate.isNotEmpty(currentSubContentId)) {
                     if (!currentSubContentId.equals(origSubContentId)) {
                         // disable existing link
                         if (UtilValidate.isNotEmpty(origSubContentId) && origFromDate != null) {
-                            List oldActiveValues = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentIdTo", origSubContentId, "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null));
-                            Iterator iterOldActive = oldActiveValues.iterator();
+                            List<GenericValue> oldActiveValues = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentIdTo", origSubContentId, "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null));
+                            Iterator<GenericValue> iterOldActive = oldActiveValues.iterator();
                             while (iterOldActive.hasNext()) {
-                                GenericValue cAssoc = (GenericValue)iterOldActive.next();
+                                GenericValue cAssoc = iterOldActive.next();
                                 cAssoc.set("thruDate", nowTimestamp);
                                 cAssoc.store();
                                 //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, deactivating:" + cAssoc , module);
                             }
                         }
                         // create new link
-                        Map serviceIn = FastMap.newInstance();
+                        Map<String, Object> serviceIn = FastMap.newInstance();
                         serviceIn.put("userLogin", userLogin);
                         serviceIn.put("contentId", targContentId);
                         serviceIn.put("contentAssocTypeId", "PUBLISH_LINK");
@@ -323,10 +322,10 @@ public class ContentManagementEvents {
                     }
                 } else if (UtilValidate.isNotEmpty(origSubContentId)) {
                     // if no current link is passed in, look to see if there is an existing link(s) that must be disabled
-                    List oldActiveValues = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentIdTo", origSubContentId, "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null));
-                    Iterator iterOldActive = oldActiveValues.iterator();
+                    List<GenericValue> oldActiveValues = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentIdTo", origSubContentId, "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null));
+                    Iterator<GenericValue> iterOldActive = oldActiveValues.iterator();
                     while (iterOldActive.hasNext()) {
-                        GenericValue cAssoc = (GenericValue)iterOldActive.next();
+                        GenericValue cAssoc = iterOldActive.next();
                         cAssoc.set("thruDate", nowTimestamp);
                         cAssoc.store();
                     }
@@ -339,13 +338,13 @@ public class ContentManagementEvents {
                     }
                 }
             } catch (GenericEntityException e) {
-                    Debug.logError(e.getMessage(), module);
-                    request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
-                    return "error";
+                Debug.logError(e.getMessage(), module);
+                request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
+                return "error";
             } catch (GenericServiceException e2) {
-                    Debug.logError(e2, module);
-                    request.setAttribute("_ERROR_MESSAGE_", e2.getMessage());
-                    return "error";
+                Debug.logError(e2, module);
+                request.setAttribute("_ERROR_MESSAGE_", e2.getMessage());
+                return "error";
             }
         }
         return "success";