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.portlet.wiki.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portlet.wiki.model.WikiPageResource;
20  import com.liferay.portlet.wiki.service.base.WikiPageResourceLocalServiceBaseImpl;
21  
22  /**
23   * <a href="WikiPageResourceLocalServiceImpl.java.html"><b><i>View Source</i>
24   * </b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class WikiPageResourceLocalServiceImpl
29      extends WikiPageResourceLocalServiceBaseImpl {
30  
31      public void deletePageResource(long nodeId, String title)
32          throws PortalException, SystemException {
33  
34          wikiPageResourcePersistence.removeByN_T(nodeId, title);
35      }
36  
37      public WikiPageResource getPageResource(long pageResourcePrimKey)
38          throws PortalException, SystemException {
39  
40          return wikiPageResourcePersistence.findByPrimaryKey(
41              pageResourcePrimKey);
42      }
43  
44      public long getPageResourcePrimKey(long nodeId, String title)
45          throws SystemException {
46  
47          WikiPageResource pageResource = wikiPageResourcePersistence.fetchByN_T(
48              nodeId, title);
49  
50          if (pageResource == null) {
51              long pageResourcePrimKey = counterLocalService.increment();
52  
53              pageResource = wikiPageResourcePersistence.create(
54                  pageResourcePrimKey);
55  
56              pageResource.setNodeId(nodeId);
57              pageResource.setTitle(title);
58  
59              wikiPageResourcePersistence.update(pageResource, false);
60          }
61  
62          return pageResource.getResourcePrimKey();
63      }
64  
65  }