Source Code Cross Referenced for WebDAVPropsPersistenceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portal » service » persistence » 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 » Portal » liferay portal 4.4.2 » com.liferay.portal.service.persistence 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020:         * SOFTWARE.
021:         */package com.liferay.portal.service.persistence;
022:
023:        import com.liferay.portal.NoSuchWebDAVPropsException;
024:        import com.liferay.portal.SystemException;
025:        import com.liferay.portal.kernel.dao.DynamicQuery;
026:        import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
027:        import com.liferay.portal.kernel.util.GetterUtil;
028:        import com.liferay.portal.kernel.util.OrderByComparator;
029:        import com.liferay.portal.kernel.util.StringMaker;
030:        import com.liferay.portal.kernel.util.StringPool;
031:        import com.liferay.portal.kernel.util.Validator;
032:        import com.liferay.portal.model.ModelListener;
033:        import com.liferay.portal.model.WebDAVProps;
034:        import com.liferay.portal.model.impl.WebDAVPropsImpl;
035:        import com.liferay.portal.model.impl.WebDAVPropsModelImpl;
036:        import com.liferay.portal.spring.hibernate.FinderCache;
037:        import com.liferay.portal.spring.hibernate.HibernateUtil;
038:        import com.liferay.portal.util.PropsUtil;
039:
040:        import com.liferay.util.dao.hibernate.QueryUtil;
041:
042:        import org.apache.commons.logging.Log;
043:        import org.apache.commons.logging.LogFactory;
044:
045:        import org.hibernate.Query;
046:        import org.hibernate.Session;
047:
048:        import java.util.Collections;
049:        import java.util.Iterator;
050:        import java.util.List;
051:
052:        /**
053:         * <a href="WebDAVPropsPersistenceImpl.java.html"><b><i>View Source</i></b></a>
054:         *
055:         * @author Brian Wing Shun Chan
056:         *
057:         */
058:        public class WebDAVPropsPersistenceImpl extends BasePersistence
059:                implements  WebDAVPropsPersistence {
060:            public WebDAVProps create(long webDavPropsId) {
061:                WebDAVProps webDAVProps = new WebDAVPropsImpl();
062:
063:                webDAVProps.setNew(true);
064:                webDAVProps.setPrimaryKey(webDavPropsId);
065:
066:                return webDAVProps;
067:            }
068:
069:            public WebDAVProps remove(long webDavPropsId)
070:                    throws NoSuchWebDAVPropsException, SystemException {
071:                Session session = null;
072:
073:                try {
074:                    session = openSession();
075:
076:                    WebDAVProps webDAVProps = (WebDAVProps) session.get(
077:                            WebDAVPropsImpl.class, new Long(webDavPropsId));
078:
079:                    if (webDAVProps == null) {
080:                        if (_log.isWarnEnabled()) {
081:                            _log
082:                                    .warn("No WebDAVProps exists with the primary key "
083:                                            + webDavPropsId);
084:                        }
085:
086:                        throw new NoSuchWebDAVPropsException(
087:                                "No WebDAVProps exists with the primary key "
088:                                        + webDavPropsId);
089:                    }
090:
091:                    return remove(webDAVProps);
092:                } catch (NoSuchWebDAVPropsException nsee) {
093:                    throw nsee;
094:                } catch (Exception e) {
095:                    throw HibernateUtil.processException(e);
096:                } finally {
097:                    closeSession(session);
098:                }
099:            }
100:
101:            public WebDAVProps remove(WebDAVProps webDAVProps)
102:                    throws SystemException {
103:                ModelListener listener = _getListener();
104:
105:                if (listener != null) {
106:                    listener.onBeforeRemove(webDAVProps);
107:                }
108:
109:                webDAVProps = removeImpl(webDAVProps);
110:
111:                if (listener != null) {
112:                    listener.onAfterRemove(webDAVProps);
113:                }
114:
115:                return webDAVProps;
116:            }
117:
118:            protected WebDAVProps removeImpl(WebDAVProps webDAVProps)
119:                    throws SystemException {
120:                Session session = null;
121:
122:                try {
123:                    session = openSession();
124:
125:                    session.delete(webDAVProps);
126:
127:                    session.flush();
128:
129:                    return webDAVProps;
130:                } catch (Exception e) {
131:                    throw HibernateUtil.processException(e);
132:                } finally {
133:                    closeSession(session);
134:
135:                    FinderCache.clearCache(WebDAVProps.class.getName());
136:                }
137:            }
138:
139:            public WebDAVProps update(WebDAVProps webDAVProps)
140:                    throws SystemException {
141:                return update(webDAVProps, false);
142:            }
143:
144:            public WebDAVProps update(WebDAVProps webDAVProps, boolean merge)
145:                    throws SystemException {
146:                ModelListener listener = _getListener();
147:
148:                boolean isNew = webDAVProps.isNew();
149:
150:                if (listener != null) {
151:                    if (isNew) {
152:                        listener.onBeforeCreate(webDAVProps);
153:                    } else {
154:                        listener.onBeforeUpdate(webDAVProps);
155:                    }
156:                }
157:
158:                webDAVProps = updateImpl(webDAVProps, merge);
159:
160:                if (listener != null) {
161:                    if (isNew) {
162:                        listener.onAfterCreate(webDAVProps);
163:                    } else {
164:                        listener.onAfterUpdate(webDAVProps);
165:                    }
166:                }
167:
168:                return webDAVProps;
169:            }
170:
171:            public WebDAVProps updateImpl(
172:                    com.liferay.portal.model.WebDAVProps webDAVProps,
173:                    boolean merge) throws SystemException {
174:                Session session = null;
175:
176:                try {
177:                    session = openSession();
178:
179:                    if (merge) {
180:                        session.merge(webDAVProps);
181:                    } else {
182:                        if (webDAVProps.isNew()) {
183:                            session.save(webDAVProps);
184:                        }
185:                    }
186:
187:                    session.flush();
188:
189:                    webDAVProps.setNew(false);
190:
191:                    return webDAVProps;
192:                } catch (Exception e) {
193:                    throw HibernateUtil.processException(e);
194:                } finally {
195:                    closeSession(session);
196:
197:                    FinderCache.clearCache(WebDAVProps.class.getName());
198:                }
199:            }
200:
201:            public WebDAVProps findByPrimaryKey(long webDavPropsId)
202:                    throws NoSuchWebDAVPropsException, SystemException {
203:                WebDAVProps webDAVProps = fetchByPrimaryKey(webDavPropsId);
204:
205:                if (webDAVProps == null) {
206:                    if (_log.isWarnEnabled()) {
207:                        _log.warn("No WebDAVProps exists with the primary key "
208:                                + webDavPropsId);
209:                    }
210:
211:                    throw new NoSuchWebDAVPropsException(
212:                            "No WebDAVProps exists with the primary key "
213:                                    + webDavPropsId);
214:                }
215:
216:                return webDAVProps;
217:            }
218:
219:            public WebDAVProps fetchByPrimaryKey(long webDavPropsId)
220:                    throws SystemException {
221:                Session session = null;
222:
223:                try {
224:                    session = openSession();
225:
226:                    return (WebDAVProps) session.get(WebDAVPropsImpl.class,
227:                            new Long(webDavPropsId));
228:                } catch (Exception e) {
229:                    throw HibernateUtil.processException(e);
230:                } finally {
231:                    closeSession(session);
232:                }
233:            }
234:
235:            public WebDAVProps findByC_C(long classNameId, long classPK)
236:                    throws NoSuchWebDAVPropsException, SystemException {
237:                WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
238:
239:                if (webDAVProps == null) {
240:                    StringMaker msg = new StringMaker();
241:
242:                    msg.append("No WebDAVProps exists with the key {");
243:
244:                    msg.append("classNameId=" + classNameId);
245:
246:                    msg.append(", ");
247:                    msg.append("classPK=" + classPK);
248:
249:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
250:
251:                    if (_log.isWarnEnabled()) {
252:                        _log.warn(msg.toString());
253:                    }
254:
255:                    throw new NoSuchWebDAVPropsException(msg.toString());
256:                }
257:
258:                return webDAVProps;
259:            }
260:
261:            public WebDAVProps fetchByC_C(long classNameId, long classPK)
262:                    throws SystemException {
263:                boolean finderClassNameCacheEnabled = WebDAVPropsModelImpl.CACHE_ENABLED;
264:                String finderClassName = WebDAVProps.class.getName();
265:                String finderMethodName = "fetchByC_C";
266:                String[] finderParams = new String[] { Long.class.getName(),
267:                        Long.class.getName() };
268:                Object[] finderArgs = new Object[] { new Long(classNameId),
269:                        new Long(classPK) };
270:
271:                Object result = null;
272:
273:                if (finderClassNameCacheEnabled) {
274:                    result = FinderCache.getResult(finderClassName,
275:                            finderMethodName, finderParams, finderArgs,
276:                            getSessionFactory());
277:                }
278:
279:                if (result == null) {
280:                    Session session = null;
281:
282:                    try {
283:                        session = openSession();
284:
285:                        StringMaker query = new StringMaker();
286:
287:                        query
288:                                .append("FROM com.liferay.portal.model.WebDAVProps WHERE ");
289:
290:                        query.append("classNameId = ?");
291:
292:                        query.append(" AND ");
293:
294:                        query.append("classPK = ?");
295:
296:                        query.append(" ");
297:
298:                        Query q = session.createQuery(query.toString());
299:
300:                        int queryPos = 0;
301:
302:                        q.setLong(queryPos++, classNameId);
303:
304:                        q.setLong(queryPos++, classPK);
305:
306:                        List list = q.list();
307:
308:                        FinderCache.putResult(finderClassNameCacheEnabled,
309:                                finderClassName, finderMethodName,
310:                                finderParams, finderArgs, list);
311:
312:                        if (list.size() == 0) {
313:                            return null;
314:                        } else {
315:                            return (WebDAVProps) list.get(0);
316:                        }
317:                    } catch (Exception e) {
318:                        throw HibernateUtil.processException(e);
319:                    } finally {
320:                        closeSession(session);
321:                    }
322:                } else {
323:                    List list = (List) result;
324:
325:                    if (list.size() == 0) {
326:                        return null;
327:                    } else {
328:                        return (WebDAVProps) list.get(0);
329:                    }
330:                }
331:            }
332:
333:            public List findWithDynamicQuery(
334:                    DynamicQueryInitializer queryInitializer)
335:                    throws SystemException {
336:                Session session = null;
337:
338:                try {
339:                    session = openSession();
340:
341:                    DynamicQuery query = queryInitializer.initialize(session);
342:
343:                    return query.list();
344:                } catch (Exception e) {
345:                    throw HibernateUtil.processException(e);
346:                } finally {
347:                    closeSession(session);
348:                }
349:            }
350:
351:            public List findWithDynamicQuery(
352:                    DynamicQueryInitializer queryInitializer, int begin, int end)
353:                    throws SystemException {
354:                Session session = null;
355:
356:                try {
357:                    session = openSession();
358:
359:                    DynamicQuery query = queryInitializer.initialize(session);
360:
361:                    query.setLimit(begin, end);
362:
363:                    return query.list();
364:                } catch (Exception e) {
365:                    throw HibernateUtil.processException(e);
366:                } finally {
367:                    closeSession(session);
368:                }
369:            }
370:
371:            public List findAll() throws SystemException {
372:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
373:            }
374:
375:            public List findAll(int begin, int end) throws SystemException {
376:                return findAll(begin, end, null);
377:            }
378:
379:            public List findAll(int begin, int end, OrderByComparator obc)
380:                    throws SystemException {
381:                boolean finderClassNameCacheEnabled = WebDAVPropsModelImpl.CACHE_ENABLED;
382:                String finderClassName = WebDAVProps.class.getName();
383:                String finderMethodName = "findAll";
384:                String[] finderParams = new String[] { "java.lang.Integer",
385:                        "java.lang.Integer",
386:                        "com.liferay.portal.kernel.util.OrderByComparator" };
387:                Object[] finderArgs = new Object[] { String.valueOf(begin),
388:                        String.valueOf(end), String.valueOf(obc) };
389:
390:                Object result = null;
391:
392:                if (finderClassNameCacheEnabled) {
393:                    result = FinderCache.getResult(finderClassName,
394:                            finderMethodName, finderParams, finderArgs,
395:                            getSessionFactory());
396:                }
397:
398:                if (result == null) {
399:                    Session session = null;
400:
401:                    try {
402:                        session = openSession();
403:
404:                        StringMaker query = new StringMaker();
405:
406:                        query
407:                                .append("FROM com.liferay.portal.model.WebDAVProps ");
408:
409:                        if (obc != null) {
410:                            query.append("ORDER BY ");
411:                            query.append(obc.getOrderBy());
412:                        }
413:
414:                        Query q = session.createQuery(query.toString());
415:
416:                        List list = QueryUtil.list(q, getDialect(), begin, end);
417:
418:                        if (obc == null) {
419:                            Collections.sort(list);
420:                        }
421:
422:                        FinderCache.putResult(finderClassNameCacheEnabled,
423:                                finderClassName, finderMethodName,
424:                                finderParams, finderArgs, list);
425:
426:                        return list;
427:                    } catch (Exception e) {
428:                        throw HibernateUtil.processException(e);
429:                    } finally {
430:                        closeSession(session);
431:                    }
432:                } else {
433:                    return (List) result;
434:                }
435:            }
436:
437:            public void removeByC_C(long classNameId, long classPK)
438:                    throws NoSuchWebDAVPropsException, SystemException {
439:                WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
440:
441:                remove(webDAVProps);
442:            }
443:
444:            public void removeAll() throws SystemException {
445:                Iterator itr = findAll().iterator();
446:
447:                while (itr.hasNext()) {
448:                    remove((WebDAVProps) itr.next());
449:                }
450:            }
451:
452:            public int countByC_C(long classNameId, long classPK)
453:                    throws SystemException {
454:                boolean finderClassNameCacheEnabled = WebDAVPropsModelImpl.CACHE_ENABLED;
455:                String finderClassName = WebDAVProps.class.getName();
456:                String finderMethodName = "countByC_C";
457:                String[] finderParams = new String[] { Long.class.getName(),
458:                        Long.class.getName() };
459:                Object[] finderArgs = new Object[] { new Long(classNameId),
460:                        new Long(classPK) };
461:
462:                Object result = null;
463:
464:                if (finderClassNameCacheEnabled) {
465:                    result = FinderCache.getResult(finderClassName,
466:                            finderMethodName, finderParams, finderArgs,
467:                            getSessionFactory());
468:                }
469:
470:                if (result == null) {
471:                    Session session = null;
472:
473:                    try {
474:                        session = openSession();
475:
476:                        StringMaker query = new StringMaker();
477:
478:                        query.append("SELECT COUNT(*) ");
479:                        query
480:                                .append("FROM com.liferay.portal.model.WebDAVProps WHERE ");
481:
482:                        query.append("classNameId = ?");
483:
484:                        query.append(" AND ");
485:
486:                        query.append("classPK = ?");
487:
488:                        query.append(" ");
489:
490:                        Query q = session.createQuery(query.toString());
491:
492:                        int queryPos = 0;
493:
494:                        q.setLong(queryPos++, classNameId);
495:
496:                        q.setLong(queryPos++, classPK);
497:
498:                        Long count = null;
499:
500:                        Iterator itr = q.list().iterator();
501:
502:                        if (itr.hasNext()) {
503:                            count = (Long) itr.next();
504:                        }
505:
506:                        if (count == null) {
507:                            count = new Long(0);
508:                        }
509:
510:                        FinderCache.putResult(finderClassNameCacheEnabled,
511:                                finderClassName, finderMethodName,
512:                                finderParams, finderArgs, count);
513:
514:                        return count.intValue();
515:                    } catch (Exception e) {
516:                        throw HibernateUtil.processException(e);
517:                    } finally {
518:                        closeSession(session);
519:                    }
520:                } else {
521:                    return ((Long) result).intValue();
522:                }
523:            }
524:
525:            public int countAll() throws SystemException {
526:                boolean finderClassNameCacheEnabled = WebDAVPropsModelImpl.CACHE_ENABLED;
527:                String finderClassName = WebDAVProps.class.getName();
528:                String finderMethodName = "countAll";
529:                String[] finderParams = new String[] {};
530:                Object[] finderArgs = new Object[] {};
531:
532:                Object result = null;
533:
534:                if (finderClassNameCacheEnabled) {
535:                    result = FinderCache.getResult(finderClassName,
536:                            finderMethodName, finderParams, finderArgs,
537:                            getSessionFactory());
538:                }
539:
540:                if (result == null) {
541:                    Session session = null;
542:
543:                    try {
544:                        session = openSession();
545:
546:                        Query q = session
547:                                .createQuery("SELECT COUNT(*) FROM com.liferay.portal.model.WebDAVProps");
548:
549:                        Long count = null;
550:
551:                        Iterator itr = q.list().iterator();
552:
553:                        if (itr.hasNext()) {
554:                            count = (Long) itr.next();
555:                        }
556:
557:                        if (count == null) {
558:                            count = new Long(0);
559:                        }
560:
561:                        FinderCache.putResult(finderClassNameCacheEnabled,
562:                                finderClassName, finderMethodName,
563:                                finderParams, finderArgs, count);
564:
565:                        return count.intValue();
566:                    } catch (Exception e) {
567:                        throw HibernateUtil.processException(e);
568:                    } finally {
569:                        closeSession(session);
570:                    }
571:                } else {
572:                    return ((Long) result).intValue();
573:                }
574:            }
575:
576:            protected void initDao() {
577:            }
578:
579:            private static ModelListener _getListener() {
580:                if (Validator.isNotNull(_LISTENER)) {
581:                    try {
582:                        return (ModelListener) Class.forName(_LISTENER)
583:                                .newInstance();
584:                    } catch (Exception e) {
585:                        _log.error(e);
586:                    }
587:                }
588:
589:                return null;
590:            }
591:
592:            private static final String _LISTENER = GetterUtil
593:                    .getString(PropsUtil
594:                            .get("value.object.listener.com.liferay.portal.model.WebDAVProps"));
595:            private static Log _log = LogFactory
596:                    .getLog(WebDAVPropsPersistenceImpl.class);
597:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.