001
014
015 package com.liferay.portlet.wiki.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portlet.wiki.model.WikiPageResource;
020 import com.liferay.portlet.wiki.service.base.WikiPageResourceLocalServiceBaseImpl;
021
022
026 public class WikiPageResourceLocalServiceImpl
027 extends WikiPageResourceLocalServiceBaseImpl {
028
029 @Override
030 public WikiPageResource addPageResource(long nodeId, String title)
031 throws SystemException {
032
033 long pageResourcePrimKey = counterLocalService.increment();
034
035 WikiPageResource pageResource = wikiPageResourcePersistence.create(
036 pageResourcePrimKey);
037
038 pageResource.setNodeId(nodeId);
039 pageResource.setTitle(title);
040
041 wikiPageResourcePersistence.update(pageResource, false);
042
043 return pageResource;
044 }
045
046 @Override
047 public void deletePageResource(long nodeId, String title)
048 throws PortalException, SystemException {
049
050 wikiPageResourcePersistence.removeByN_T(nodeId, title);
051 }
052
053 @Override
054 public WikiPageResource getPageResource(long pageResourcePrimKey)
055 throws PortalException, SystemException {
056
057 return wikiPageResourcePersistence.findByPrimaryKey(
058 pageResourcePrimKey);
059 }
060
061 @Override
062 public WikiPageResource getPageResource(long nodeId, String title)
063 throws PortalException, SystemException {
064
065 return wikiPageResourcePersistence.findByN_T(nodeId, title);
066 }
067
068 @Override
069 public long getPageResourcePrimKey(long nodeId, String title)
070 throws SystemException {
071
072 WikiPageResource pageResource = wikiPageResourcePersistence.fetchByN_T(
073 nodeId, title);
074
075 if (pageResource == null) {
076 long pageResourcePrimKey = counterLocalService.increment();
077
078 pageResource = wikiPageResourcePersistence.create(
079 pageResourcePrimKey);
080
081 pageResource.setNodeId(nodeId);
082 pageResource.setTitle(title);
083
084 wikiPageResourcePersistence.update(pageResource, false);
085 }
086
087 return pageResource.getResourcePrimKey();
088 }
089
090 }