com.liferay.fragment.service.impl.FragmentEntryServiceImpl Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.fragment.service.impl;
import com.liferay.fragment.constants.FragmentActionKeys;
import com.liferay.fragment.constants.FragmentConstants;
import com.liferay.fragment.model.FragmentEntry;
import com.liferay.fragment.service.base.FragmentEntryServiceBaseImpl;
import com.liferay.portal.dao.orm.custom.sql.CustomSQL;
import com.liferay.portal.kernel.dao.orm.WildcardMode;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.resource.PortletResourcePermission;
import com.liferay.portal.kernel.security.permission.resource.PortletResourcePermissionFactory;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.spring.extender.service.ServiceReference;
import java.util.List;
/**
* @author Jürgen Kappler
*/
public class FragmentEntryServiceImpl extends FragmentEntryServiceBaseImpl {
@Override
public FragmentEntry addFragmentEntry(
long groupId, long fragmentCollectionId, String name, int status,
ServiceContext serviceContext)
throws PortalException {
_portletResourcePermission.check(
getPermissionChecker(), groupId,
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.addFragmentEntry(
getUserId(), groupId, fragmentCollectionId, name, status,
serviceContext);
}
@Override
public FragmentEntry addFragmentEntry(
long groupId, long fragmentCollectionId, String fragmentEntryKey,
String name, int status, ServiceContext serviceContext)
throws PortalException {
_portletResourcePermission.check(
getPermissionChecker(), groupId,
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.addFragmentEntry(
getUserId(), groupId, fragmentCollectionId, fragmentEntryKey, name,
status, serviceContext);
}
@Override
public FragmentEntry addFragmentEntry(
long groupId, long fragmentCollectionId, String name, String css,
String html, String js, int status, ServiceContext serviceContext)
throws PortalException {
_portletResourcePermission.check(
getPermissionChecker(), groupId,
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.addFragmentEntry(
getUserId(), groupId, fragmentCollectionId, name, css, html, js,
status, serviceContext);
}
@Override
public FragmentEntry addFragmentEntry(
long groupId, long fragmentCollectionId, String fragmentEntryKey,
String name, String css, String html, String js, int status,
ServiceContext serviceContext)
throws PortalException {
_portletResourcePermission.check(
getPermissionChecker(), groupId,
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.addFragmentEntry(
getUserId(), groupId, fragmentCollectionId, fragmentEntryKey, name,
css, html, js, status, serviceContext);
}
@Override
public void deleteFragmentEntries(long[] fragmentEntriesIds)
throws PortalException {
for (long fragmentEntryId : fragmentEntriesIds) {
FragmentEntry fragmentEntry =
fragmentEntryLocalService.getFragmentEntry(fragmentEntryId);
_portletResourcePermission.check(
getPermissionChecker(), fragmentEntry.getGroupId(),
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
fragmentEntryLocalService.deleteFragmentEntry(fragmentEntry);
}
}
@Override
public FragmentEntry deleteFragmentEntry(long fragmentEntryId)
throws PortalException {
FragmentEntry fragmentEntry =
fragmentEntryLocalService.getFragmentEntry(fragmentEntryId);
_portletResourcePermission.check(
getPermissionChecker(), fragmentEntry.getGroupId(),
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.deleteFragmentEntry(fragmentEntryId);
}
@Override
public FragmentEntry fetchFragmentEntry(long fragmentEntryId)
throws PortalException {
FragmentEntry fragmentEntry =
fragmentEntryLocalService.fetchFragmentEntry(fragmentEntryId);
if (fragmentEntry != null) {
_portletResourcePermission.check(
getPermissionChecker(), fragmentEntry.getGroupId(),
ActionKeys.VIEW);
}
return fragmentEntry;
}
@Override
public int getFragmentCollectionsCount(
long groupId, long fragmentCollectionId) {
return fragmentEntryPersistence.countByG_FCI(
groupId, fragmentCollectionId);
}
@Override
public int getFragmentCollectionsCount(
long groupId, long fragmentCollectionId, int status) {
return fragmentEntryPersistence.countByG_FCI_S(
groupId, fragmentCollectionId, status);
}
@Override
public int getFragmentCollectionsCount(
long groupId, long fragmentCollectionId, String name) {
return fragmentEntryPersistence.countByG_FCI_LikeN(
groupId, fragmentCollectionId,
_customSQL.keywords(name, WildcardMode.SURROUND)[0]);
}
@Override
public int getFragmentCollectionsCount(
long groupId, long fragmentCollectionId, String name, int status) {
return fragmentEntryPersistence.countByG_FCI_LikeN_S(
groupId, fragmentCollectionId,
_customSQL.keywords(name, WildcardMode.SURROUND)[0], status);
}
@Override
public List getFragmentEntries(long fragmentCollectionId) {
return fragmentEntryLocalService.getFragmentEntries(
fragmentCollectionId);
}
@Override
public List getFragmentEntries(
long groupId, long fragmentCollectionId, int status) {
return fragmentEntryLocalService.getFragmentEntries(
groupId, fragmentCollectionId, status);
}
@Override
public List getFragmentEntries(
long groupId, long fragmentCollectionId, int start, int end) {
return fragmentEntryPersistence.findByG_FCI(
groupId, fragmentCollectionId, start, end);
}
@Override
public List getFragmentEntries(
long groupId, long fragmentCollectionId, int status, int start, int end,
OrderByComparator orderByComparator) {
return fragmentEntryPersistence.findByG_FCI_S(
groupId, fragmentCollectionId, status, start, end,
orderByComparator);
}
@Override
public List getFragmentEntries(
long groupId, long fragmentCollectionId, int start, int end,
OrderByComparator orderByComparator) {
return fragmentEntryPersistence.findByG_FCI(
groupId, fragmentCollectionId, start, end, orderByComparator);
}
@Override
public List getFragmentEntries(
long groupId, long fragmentCollectionId, String name, int status,
int start, int end,
OrderByComparator orderByComparator) {
return fragmentEntryPersistence.findByG_FCI_LikeN_S(
groupId, fragmentCollectionId,
_customSQL.keywords(name, WildcardMode.SURROUND)[0], status, start,
end, orderByComparator);
}
@Override
public List getFragmentEntries(
long groupId, long fragmentCollectionId, String name, int start,
int end, OrderByComparator orderByComparator) {
return fragmentEntryPersistence.findByG_FCI_LikeN(
groupId, fragmentCollectionId,
_customSQL.keywords(name, WildcardMode.SURROUND)[0], start, end,
orderByComparator);
}
@Override
public String[] getTempFileNames(long groupId, String folderName)
throws PortalException {
_portletResourcePermission.check(
getPermissionChecker(), groupId,
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.getTempFileNames(
getUserId(), groupId, folderName);
}
@Override
public FragmentEntry updateFragmentEntry(
long fragmentEntryId, long previewFileEntryId)
throws PortalException {
FragmentEntry fragmentEntry =
fragmentEntryLocalService.getFragmentEntry(fragmentEntryId);
_portletResourcePermission.check(
getPermissionChecker(), fragmentEntry.getGroupId(),
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.updateFragmentEntry(
fragmentEntryId, previewFileEntryId);
}
@Override
public FragmentEntry updateFragmentEntry(long fragmentEntryId, String name)
throws PortalException {
FragmentEntry fragmentEntry =
fragmentEntryLocalService.getFragmentEntry(fragmentEntryId);
_portletResourcePermission.check(
getPermissionChecker(), fragmentEntry.getGroupId(),
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.updateFragmentEntry(
fragmentEntryId, name);
}
@Override
public FragmentEntry updateFragmentEntry(
long fragmentEntryId, String name, String css, String html,
String js, int status)
throws PortalException {
FragmentEntry fragmentEntry =
fragmentEntryLocalService.getFragmentEntry(fragmentEntryId);
_portletResourcePermission.check(
getPermissionChecker(), fragmentEntry.getGroupId(),
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.updateFragmentEntry(
getUserId(), fragmentEntryId, name, css, html, js, status);
}
@Override
public FragmentEntry updateFragmentEntry(
long fragmentEntryId, String name, String css, String html,
String js, long previewFileEntryId, int status)
throws PortalException {
FragmentEntry fragmentEntry =
fragmentEntryLocalService.getFragmentEntry(fragmentEntryId);
_portletResourcePermission.check(
getPermissionChecker(), fragmentEntry.getGroupId(),
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES);
return fragmentEntryLocalService.updateFragmentEntry(
getUserId(), fragmentEntryId, name, css, html, js,
previewFileEntryId, status);
}
private static volatile PortletResourcePermission
_portletResourcePermission =
PortletResourcePermissionFactory.getInstance(
FragmentEntryServiceImpl.class, "_portletResourcePermission",
FragmentConstants.RESOURCE_NAME);
@ServiceReference(type = CustomSQL.class)
private CustomSQL _customSQL;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy