Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lps 73035 #49579

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.BaseModelPermissionChecker;
import com.liferay.portal.kernel.security.permission.PermissionChecker;
import com.liferay.portal.kernel.util.HashUtil;
import com.liferay.portal.kernel.workflow.permission.WorkflowPermissionUtil;

import java.util.Map;
import java.util.Objects;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

Expand Down Expand Up @@ -65,6 +69,76 @@ public static boolean contains(
PermissionChecker permissionChecker, BlogsEntry entry,
String actionId) {

Map<Object, Object> permissionChecksMap =
permissionChecker.getPermissionChecksMap();

PermissionCacheKey permissionCacheKey = new PermissionCacheKey(
entry.getEntryId(), actionId);

Boolean contains = (Boolean)permissionChecksMap.get(permissionCacheKey);

if (contains == null) {
contains = _contains(permissionChecker, entry, actionId);

permissionChecksMap.put(permissionCacheKey, contains);
}

return contains;
}

public static boolean contains(
PermissionChecker permissionChecker, long entryId, String actionId)
throws PortalException {

Map<Object, Object> permissionChecksMap =
permissionChecker.getPermissionChecksMap();

PermissionCacheKey permissionCacheKey = new PermissionCacheKey(
entryId, actionId);

Boolean contains = (Boolean)permissionChecksMap.get(permissionCacheKey);

if (contains == null) {
BlogsEntryCacheKey blogsEntryCacheKey = new BlogsEntryCacheKey(
entryId);

BlogsEntry entry = (BlogsEntry)permissionChecksMap.get(
blogsEntryCacheKey);

if (entry == null) {
entry = _blogsEntryLocalService.getEntry(entryId);

permissionChecksMap.put(blogsEntryCacheKey, entry);
}

contains = _contains(permissionChecker, entry, actionId);

permissionChecksMap.put(permissionCacheKey, contains);
}

return contains;
}

@Override
public void checkBaseModel(
PermissionChecker permissionChecker, long groupId, long primaryKey,
String actionId)
throws PortalException {

check(permissionChecker, primaryKey, actionId);
}

@Reference(unbind = "-")
protected void setBlogsEntryLocalService(
BlogsEntryLocalService blogsEntryLocalService) {

_blogsEntryLocalService = blogsEntryLocalService;
}

private static boolean _contains(
PermissionChecker permissionChecker, BlogsEntry entry,
String actionId) {

String portletId = PortletProviderUtil.getPortletId(
BlogsEntry.class.getName(), PortletProvider.Action.EDIT);

Expand Down Expand Up @@ -105,31 +179,80 @@ else if (entry.isPending()) {
actionId);
}

public static boolean contains(
PermissionChecker permissionChecker, long entryId, String actionId)
throws PortalException {
private static BlogsEntryLocalService _blogsEntryLocalService;

BlogsEntry entry = _blogsEntryLocalService.getEntry(entryId);
private static class BlogsEntryCacheKey {

return contains(permissionChecker, entry, actionId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

@Override
public void checkBaseModel(
PermissionChecker permissionChecker, long groupId, long primaryKey,
String actionId)
throws PortalException {
if (!(obj instanceof BlogsEntryCacheKey)) {
return false;
}

check(permissionChecker, primaryKey, actionId);
}
BlogsEntryCacheKey blogsEntryCacheKey = (BlogsEntryCacheKey)obj;

@Reference(unbind = "-")
protected void setBlogsEntryLocalService(
BlogsEntryLocalService blogsEntryLocalService) {
if (_entryId == blogsEntryCacheKey._entryId) {
return true;
}

return false;
}

@Override
public int hashCode() {
return (int)_entryId;
}

private BlogsEntryCacheKey(long entryId) {
_entryId = entryId;
}

private final long _entryId;

_blogsEntryLocalService = blogsEntryLocalService;
}

private static BlogsEntryLocalService _blogsEntryLocalService;
private static class PermissionCacheKey {

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (!(obj instanceof PermissionCacheKey)) {
return false;
}

PermissionCacheKey permissionCacheKey = (PermissionCacheKey)obj;

if ((_entryId == permissionCacheKey._entryId) &&
Objects.equals(_actionId, permissionCacheKey._actionId)) {

return true;
}

return false;
}

@Override
public int hashCode() {
int hash = HashUtil.hash(0, _entryId);

return HashUtil.hash(hash, _actionId);
}

private PermissionCacheKey(long entryId, String actionId) {
_entryId = entryId;
_actionId = actionId;
}

private final String _actionId;
private final long _entryId;

}

}

This file was deleted.

4 changes: 2 additions & 2 deletions modules/apps/web-experience/journal/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[subrepo]
autopull = true
cmdver = liferay
commit = 50a0ae58c28a191cde089d0520d0b702bbe69aa5
commit = aa38f3dabb74d3990b847524ea84e15beb2ef53e
mergebuttonmergecommits = false
mode = pull
parent = bc23cef00f82764b34ec2fc30f6c875f4bf91345
parent = be16af6d68fa196b299e3bbb4135746117d770d0
remote = git@github.com:liferay/com-liferay-journal.git
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies {
testIntegrationCompile group: "com.liferay", name: "com.liferay.dynamic.data.mapping.io", version: "2.0.0"
testIntegrationCompile group: "com.liferay", name: "com.liferay.dynamic.data.mapping.service", version: "2.0.0"
testIntegrationCompile group: "com.liferay", name: "com.liferay.dynamic.data.mapping.test.util", version: "2.1.0"
testIntegrationCompile group: "com.liferay", name: "com.liferay.registry.api", version: "1.0.0"
testIntegrationCompile group: "com.liferay", name: "com.liferay.trash.api", version: "1.0.0-20170428.233956-1"
testIntegrationCompile group: "com.liferay", name: "com.liferay.trash.test.util", version: "1.0.0-20170327.173148-1"
testIntegrationCompile group: "com.liferay.portal", name: "com.liferay.portal.impl", version: "2.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version 1.2.0
version 1.3.0