org.molgenis.data.security.exception.PackagePermissionDeniedException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of molgenis-data-security Show documentation
Show all versions of molgenis-data-security Show documentation
Security data model and data layer security.
package org.molgenis.data.security.exception;
import static java.util.Objects.requireNonNull;
import org.molgenis.data.meta.model.Package;
import org.molgenis.data.security.PackagePermission;
@SuppressWarnings("squid:MaximumInheritanceDepth")
public class PackagePermissionDeniedException extends PermissionDeniedException {
private static final String ERROR_CODE = "DS01";
private final PackagePermission permission;
private final transient Package pack;
public PackagePermissionDeniedException(PackagePermission permission, Package pack) {
super(ERROR_CODE);
this.permission = requireNonNull(permission);
this.pack = requireNonNull(pack);
}
@Override
public String getMessage() {
return String.format("permission:%s package:%s", permission.getName(), pack.getId());
}
@Override
protected Object[] getLocalizedMessageArguments() {
return new Object[] {permission.getName(), pack.getLabel()};
}
}