@Override public boolean isReadable(ShareableResource resource) { Ticket ticket = SharingServiceFactory.getSharingTicketService().getTicket(resource.getToken()); try { if (ticket != null && ticket instanceof NodeTicket) { NodePK nodePk = new NodePK(String.valueOf(ticket.getSharedObjectId()), ticket.getComponentId()); Collection<NodePK> autorizedNodes = getNodeDescendants(nodePk); autorizedNodes.add(nodePk); if (resource.getAccessedObject() instanceof AttachmentDetail) { AttachmentDetail attachment = (AttachmentDetail) resource.getAccessedObject(); return isPublicationReadable( attachment.getForeignKey(), nodePk.getInstanceId(), autorizedNodes); } if (resource.getAccessedObject() instanceof SimpleDocument) { SimpleDocument attachment = (SimpleDocument) resource.getAccessedObject(); return isPublicationReadable( new ForeignPK(attachment.getForeignId(), attachment.getInstanceId()), nodePk.getInstanceId(), autorizedNodes); } if (resource.getAccessedObject() instanceof Document) { Document document = (Document) resource.getAccessedObject(); return isPublicationReadable( document.getForeignKey(), nodePk.getInstanceId(), autorizedNodes); } if (resource.getAccessedObject() instanceof NodeDetail) { NodeDetail node = (NodeDetail) resource.getAccessedObject(); return autorizedNodes.contains(node.getNodePK()); } } } catch (Exception ex) { return false; } return false; }
/* * (non-Javadoc) * @see * com.silverpeas.notification.builder.AbstractResourceUserNotificationBuilder#getResourceURL( * java.lang.Object) */ @Override protected String getResourceURL(final NodePK resource) { return URLManager.getURL(null, null, resource.getInstanceId()) + "Main"; }