1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.NoSuchWebDAVPropsException;
18  import com.liferay.portal.PortalException;
19  import com.liferay.portal.SystemException;
20  import com.liferay.portal.model.WebDAVProps;
21  import com.liferay.portal.service.base.WebDAVPropsLocalServiceBaseImpl;
22  import com.liferay.portal.util.PortalUtil;
23  import com.liferay.portal.webdav.WebDAVException;
24  
25  import java.util.Date;
26  
27  /**
28   * <a href="WebDAVPropsLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Alexander Chow
31   */
32  public class WebDAVPropsLocalServiceImpl
33      extends WebDAVPropsLocalServiceBaseImpl {
34  
35      public void deleteWebDAVProps(String className, long classPK)
36          throws SystemException {
37  
38          long classNameId = PortalUtil.getClassNameId(className);
39  
40          try {
41              webDAVPropsPersistence.removeByC_C(classNameId, classPK);
42          }
43          catch (NoSuchWebDAVPropsException nswdavpe) {
44          }
45      }
46  
47      public WebDAVProps getWebDAVProps(
48              long companyId, String className, long classPK)
49          throws SystemException {
50  
51          long classNameId = PortalUtil.getClassNameId(className);
52  
53          WebDAVProps webDavProps = webDAVPropsPersistence.fetchByC_C(
54              classNameId, classPK);
55  
56          if (webDavProps == null) {
57              webDavProps = webDAVPropsPersistence.create(
58                  counterLocalService.increment());
59  
60              Date now = new Date();
61  
62              webDavProps.setCompanyId(companyId);
63              webDavProps.setCreateDate(now);
64              webDavProps.setModifiedDate(now);
65              webDavProps.setClassNameId(classNameId);
66              webDavProps.setClassPK(classPK);
67  
68              webDAVPropsPersistence.update(webDavProps, false);
69          }
70  
71          return webDavProps;
72      }
73  
74      public void storeWebDAVProps(WebDAVProps webDavProps)
75          throws PortalException, SystemException {
76  
77          try {
78              webDavProps.store();
79          }
80          catch (Exception e) {
81              throw new WebDAVException("Problem trying to store WebDAVProps", e);
82          }
83  
84          webDAVPropsPersistence.update(webDavProps, true);
85      }
86  
87  }