Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2024 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -22,7 +22,6 @@

public class AccessSnippet {


//tag::ReadCompanyPermission[]
public static class ReadCompanyPermission extends AbstractPermission {
@Serial
Expand Down Expand Up @@ -55,8 +54,9 @@ public String getAccessCheckFailedMessage() {
protected void snippets() {

//tag::ACCESS_A[]
if (ACCESS.check(new ReadCompanyPermission())) { // <1>
throw new AccessForbiddenException(TEXTS.get("YouAreNotAllowedToReadThisData"));
if (!ACCESS.check(new ReadCompanyPermission())) { // <1>
throw new AccessForbiddenException(TEXTS.get("YouAreNotAllowedToReadThisData"))
.withPermission(ReadCompanyPermission.class);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also change documentation here:

[source,java,indent=0]
----
include::common:example$org.eclipse.scout.docs.snippets/src/main/java/org/eclipse/scout/docs/snippets/AccessSnippet.java[tags=ACCESS_A]
----
<1> Checks permission against granted permissions of current user.
<2> Checks permission and if this check fails, throw an `AccessForbiddenException` with a default message.
We can define a default access check failed message for a permission.

And add migration notes for users?

}

ACCESS.checkAndThrow(new ReadCompanyPermission()); // <2>
Expand Down Expand Up @@ -142,6 +142,5 @@ else if (!m_companyId.equals(other.m_companyId)) {
protected interface ICompanyService {

boolean isOwnCompany(UUID companyId);

}
}