Source Code Cross Referenced for ContentManagementWorker.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » content » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » SourceTap CRM » org.ofbiz.content 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.ofbiz.content;
002:
003:        import java.util.Collection;
004:        import java.util.HashMap;
005:        import java.util.Iterator;
006:        import java.util.List;
007:        import java.util.ArrayList;
008:        import java.util.Collection;
009:        import java.util.Collections;
010:        import java.util.Map;
011:        import java.util.Locale;
012:        import java.io.IOException;
013:
014:        import javax.servlet.http.HttpSession;
015:        import javax.servlet.http.HttpServletRequest;
016:        import javax.servlet.http.HttpServletResponse;
017:
018:        import org.ofbiz.base.util.Debug;
019:        import org.ofbiz.base.util.UtilDateTime;
020:        import org.ofbiz.base.util.UtilMisc;
021:        import org.ofbiz.base.util.UtilProperties;
022:        import org.ofbiz.base.util.UtilValidate;
023:        import org.ofbiz.base.util.UtilCache;
024:        import org.ofbiz.entity.GenericDelegator;
025:        import org.ofbiz.entity.GenericEntityException;
026:        import org.ofbiz.entity.GenericValue;
027:        import org.ofbiz.entity.GenericEntity;
028:        import org.ofbiz.entity.GenericPK;
029:        import org.ofbiz.entity.condition.EntityCondition;
030:        import org.ofbiz.entity.condition.EntityConditionList;
031:        import org.ofbiz.entity.condition.EntityExpr;
032:        import org.ofbiz.entity.condition.EntityOperator;
033:        import org.ofbiz.entity.util.ByteWrapper;
034:        import org.ofbiz.security.Security;
035:        import org.ofbiz.service.DispatchContext;
036:        import org.ofbiz.service.ServiceUtil;
037:        import org.ofbiz.service.GenericServiceException;
038:        import org.ofbiz.service.LocalDispatcher;
039:        import org.ofbiz.service.ModelService;
040:        import org.ofbiz.content.content.ContentServices;
041:        import org.ofbiz.content.data.DataServices;
042:        import org.ofbiz.content.content.ContentWorker;
043:
044:        /**
045:         * ContentManagementWorker Class
046:         *
047:         * @author     <a href="mailto:byersa@automationgroups.com">Al Byers</a>
048:         * @version    $Revision: 1.4 $
049:         * @since      3.0
050:         *
051:         * 
052:         */
053:        public class ContentManagementWorker {
054:
055:            public static final String module = ContentManagementWorker.class
056:                    .getName();
057:
058:            public static void mruAdd(HttpServletRequest request,
059:                    GenericEntity pk, String suffix) {
060:                HttpSession session = request.getSession();
061:                mruAdd(session, pk, suffix);
062:            }
063:
064:            public static void mruAdd(HttpServletRequest request,
065:                    GenericEntity pk) {
066:                HttpSession session = request.getSession();
067:                mruAdd(session, pk, null);
068:            }
069:
070:            public static void mruAdd(HttpSession session, GenericEntity pk) {
071:                mruAdd(session, pk, null);
072:            }
073:
074:            public static void mruAdd(HttpSession session, GenericEntity pk,
075:                    String suffix) {
076:
077:                if (pk == null)
078:                    return;
079:
080:                Map lookupCaches = (Map) session.getAttribute("lookupCaches");
081:                if (lookupCaches == null) {
082:                    lookupCaches = new HashMap();
083:                    session.setAttribute("lookupCaches", lookupCaches);
084:                }
085:                //Debug.logVerbose("in mruAdd, lookupCaches:" + lookupCaches, "");
086:                String entityName = pk.getEntityName();
087:                //Debug.logVerbose("in mruAdd, entityName:" + entityName, "");
088:                //Debug.logVerbose("in mruAdd, suffix:" + suffix, "");
089:                if (entityName.indexOf("DataResource") >= 0) {
090:                    GenericDelegator delegator = pk.getDelegator();
091:
092:                    // Force all view variations to DataResource
093:                    GenericValue p = delegator.makeValue(
094:                            "DataResourceContentView", null);
095:                    //Debug.logVerbose("in mruAdd, p:" + p, "");
096:                    String s = null;
097:                    try {
098:                        s = (String) pk.get("dataResourceId");
099:                        if (UtilValidate.isEmpty(s)) {
100:                            s = (String) pk.get("drDataResourceId");
101:                        }
102:                        p.set("dataResourceId", s);
103:                        s = (String) pk.get("contentId");
104:                        if (UtilValidate.isEmpty(s)) {
105:                            s = (String) pk.get("coContentId");
106:                        }
107:                        p.set("coContentId", s);
108:                    } catch (IllegalArgumentException e) {
109:                        // ignore 
110:                    }
111:                    //Debug.logVerbose("in mruAdd, s:" + s, "");
112:                    if (UtilValidate.isNotEmpty(s)) {
113:                        mruAddByEntityName("DataResourceContentView", null, p,
114:                                lookupCaches);
115:                        if (suffix != null && suffix.length() > 0) {
116:                            mruAddByEntityName("DataResourceContentView",
117:                                    suffix, p, lookupCaches);
118:                        }
119:                    }
120:
121:                } else {
122:                    mruAddByEntityName(entityName, null, pk, lookupCaches);
123:                    if (suffix != null && suffix.length() > 0) {
124:                        mruAddByEntityName(entityName, suffix, pk, lookupCaches);
125:                    }
126:                }
127:                return;
128:            }
129:
130:            /**
131:             * Makes an entry in the "most recently used" cache. It picks the cache
132:             * by the entity name and builds a signature from the primary key values.
133:             *
134:             * @param entityName 
135:             * @param suffix 
136:             * @param pk either a GenericValue or GenericPK - populated
137:             */
138:            public static void mruAddByEntityName(String entityName,
139:                    String suffix, GenericEntity pk, Map lookupCaches) {
140:
141:                //Debug.logVerbose("in mruAddByEntityName, pk:" + pk, "");
142:                String cacheEntityName = entityName;
143:                if (UtilValidate.isNotEmpty(suffix)) {
144:                    cacheEntityName = entityName + suffix;
145:                }
146:                //Debug.logVerbose("in mruAddByEntityName, cacheEntityName:" + cacheEntityName, "");
147:                UtilCache lkupCache = (UtilCache) lookupCaches
148:                        .get(cacheEntityName);
149:                //Debug.logVerbose("in mruAddByEntityName, lkupCache:" + lkupCache, "");
150:                if (lkupCache == null) {
151:                    lkupCache = new UtilCache(cacheEntityName, 10, 0);
152:                    lookupCaches.put(cacheEntityName, lkupCache);
153:                }
154:
155:                String idSig = buildPKSig(pk, null);
156:                //Debug.logVerbose("in mruAddByEntityName, idSig:" + idSig, "");
157:                GenericPK p = pk.getPrimaryKey();
158:                //Debug.logVerbose("in mruAddByEntityName, p:" + p, "");
159:                lkupCache.put(idSig, p);
160:                return;
161:            }
162:
163:            /**
164:             * Builds a string signature from a GenericValue or GenericPK.
165:             *
166:             * @param pk either a populated GenericValue or GenericPK.
167:             * @param suffix a string that can be used to distinguish the signature (probably not used).
168:             */
169:            public static String buildPKSig(GenericEntity pk, String suffix) {
170:
171:                String sig = "";
172:                Collection keyColl = pk.getPrimaryKey().getAllKeys();
173:                List keyList = new ArrayList(keyColl);
174:                Collections.sort(keyList);
175:                Iterator it = keyList.iterator();
176:                while (it.hasNext()) {
177:                    String ky = (String) it.next();
178:                    String val = (String) pk.get(ky);
179:                    //Debug.logVerbose("in buildPKSig, ky:" + ky + " val:" + val, "");
180:                    if (val != null && val.length() > 0) {
181:                        if (sig.length() > 0)
182:                            sig += "_";
183:                        sig += val;
184:                    }
185:                }
186:                if (suffix != null && suffix.length() > 0) {
187:                    if (sig.length() > 0)
188:                        sig += "_";
189:                    sig += suffix;
190:                }
191:                return sig;
192:            }
193:
194:            public static void setCurrentEntityMap(HttpServletRequest request,
195:                    GenericEntity ent) {
196:
197:                String entityName = ent.getEntityName();
198:                setCurrentEntityMap(request, entityName, ent);
199:            }
200:
201:            public static void setCurrentEntityMap(HttpServletRequest request,
202:                    String entityName, GenericEntity ent) {
203:                HttpSession session = request.getSession();
204:                Map currentEntityMap = (Map) session
205:                        .getAttribute("currentEntityMap");
206:                if (currentEntityMap == null) {
207:                    currentEntityMap = new HashMap();
208:                    session.setAttribute("currentEntityMap", currentEntityMap);
209:                }
210:
211:                currentEntityMap.put(entityName, ent);
212:                //Debug.logVerbose("in setCurrentEntityMap, ent:" + ent,"");
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.