1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.wiki.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.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  }