Skip to content

Commit

Permalink
Protect resources, fix permission error response
Browse files Browse the repository at this point in the history
  • Loading branch information
guggi committed Sep 5, 2024
1 parent 05d81d0 commit e6b6e5b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gentics.api.lib.exception.NodeException;
import com.gentics.contentnode.etc.ContentNodeHelper;
import com.gentics.contentnode.etc.Function;
import com.gentics.contentnode.exception.RestMappedException;
import com.gentics.contentnode.factory.Transaction;
import com.gentics.contentnode.factory.Trx;
import com.gentics.contentnode.i18n.I18NHelper;
Expand All @@ -12,6 +13,7 @@
import com.gentics.contentnode.perm.PermHandler;
import com.gentics.contentnode.publish.protocol.PublishLogEntry;
import com.gentics.contentnode.publish.protocol.PublishProtocolService;
import com.gentics.contentnode.rest.filters.Authenticated;
import com.gentics.contentnode.rest.model.PublishLogDto;
import com.gentics.contentnode.rest.model.response.GenericItemList;
import com.gentics.contentnode.rest.resource.PublishProtocolResource;
Expand All @@ -25,7 +27,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;


@Authenticated
@Produces({MediaType.APPLICATION_JSON})
@Path("/publish/state")
public class PublishProtocolResourceImpl implements PublishProtocolResource {
Expand All @@ -51,7 +53,7 @@ public PublishLogDto get(@PathParam("objId") Integer objId) throws NodeException
var publishLogEntry = this.publishProtocolService.getPublishLogEntryByObjectId(objId);

if (!canView(publishLogEntry, trx.getTransaction())) {
throw new NodeException(I18NHelper.get("rest.permission.required"));
throw new RestMappedException(I18NHelper.get("rest.permission.required"));
}

return MAP2REST.apply(publishLogEntry);
Expand Down

0 comments on commit e6b6e5b

Please sign in to comment.