/** * From EntityProducer */ public Collection getEntityAuthzGroups(Reference ref, String userId) { log.debug("getEntityAuthzGroups(Ref ID:{},{})", ref.getId(), userId); List ids = new ArrayList(); ids.add("/site/" + ref.getContext()); return ids; }
@Override public String getReference() { return (reference != null) ? reference.getReference() : null; }
public boolean parseEntityReference(String reference, Reference ref) { if (reference.startsWith(getContext())) { // removing our label, we expose the wrapped Entity reference String wrappedRef = reference.substring(getLabel().length() + 1); // make a reference for this Reference wrapped = entityManager.newReference(wrappedRef); // use the wrapped id, container and context - our own type (no subtype) ref.set(getLabel(), null, wrapped.getId(), wrapped.getContainer(), wrapped.getContext()); return true; } return false; }
/** * Looks up the entity handler based on sybtype, the registerd subtype must * match the key in the m_handlers map * * @param ref * @return */ private EntityHandler findEntityHandler(Reference ref) { if (!APPLICATION_ID.equals(ref.getType())) return null; String subtype = ref.getSubType(); return (EntityHandler) m_handlers.get(subtype); }
public Entity getEntity(Reference ref) { // TODO Auto-generated method stub Entity rv = null; if (REF_POLL_TYPE.equals(ref.getSubType())) { rv = getPoll(ref.getReference()); } return rv; }
@Override public String getId() { return (reference != null) ? reference.getId() : null; }
Entity r = ref.getEntity(); ResourceProperties props = ref.getProperties(); String siteId = (getSite() != null) ? getSite() : ref.getContext(); String dropboxId = contentHostingService.getIndividualDropboxId(ref.getId()); String dropboxTitle = null; try
/** * Update the site security when an AuthzGroup is deleted, if it is a site AuthzGroup. * * @param azGroup * The AuthzGroup. */ protected void removeSiteSecurity(AuthzGroup azGroup) { // Special code for the site service Reference ref = entityManager().newReference(azGroup.getId()); if (SiteService.APPLICATION_ID.equals(ref.getType()) && SiteService.SITE_SUBTYPE.equals(ref.getSubType())) { // no azGroup, no users Set empty = new HashSet(); siteService.setSiteSecurity(ref.getId(), empty, empty, empty); } }
AnnouncementMessage msg = (AnnouncementMessage) ref.getEntity(); AnnouncementMessageHeader hdr = (AnnouncementMessageHeader) msg.getAnnouncementHeader(); String siteId = (getSite() != null) ? getSite() : ref.getContext(); String attachmentTitle = attachment.getProperties().getPropertyFormatted(ResourceProperties.PROP_DISPLAY_NAME); buf.append("<a href=\"" + attachment.getUrl() + "\">"); buf.append(attachmentTitle); buf.append("</a>" + newline);
/** * {@inheritDoc} */ public Group getGroup(String id) { if (id == null) return null; // if this is a reference, starting with a "/", parse it, make sure it's // a group, in this site, and pull the id if (id.startsWith(Entity.SEPARATOR)) { Reference ref = siteService .entityManager().newReference(id); if ((SiteService.APPLICATION_ID.equals(ref.getType())) && (SiteService.GROUP_SUBTYPE.equals(ref.getSubType())) && (m_id.equals(ref.getContainer()))) { return (Group) ((ResourceVector) getGroups()).getById(ref.getId()); } return null; } return (Group) ((ResourceVector) getGroups()).getById(id); }
/** * {@inheritDoc} */ public ResourceProperties getEntityResourceProperties(Reference ref) { // double check that it's mine if (!APPLICATION_ID.equals(ref.getType())) return null; ResourceProperties props = null; try { props = getProperties(ref.getId()); } catch (PermissionException e) { } catch (IdUnusedException e) { } return props; }
public List<String> getSitesForUser(String userId, String permission) { log.debug("userId: " + userId + ", permission: " + permission); List<String> l = new ArrayList<String>(); // get the groups from Sakai Set<String> authzGroupIds = authzGroupService.getAuthzGroupsIsAllowed(userId, permission, null); Iterator<String> it = authzGroupIds.iterator(); while (it.hasNext()) { String authzGroupId = it.next(); Reference r = entityManager.newReference(authzGroupId); if (r.isKnownType()) { // check if this is a Sakai Site or Group if (r.getType().equals(SiteService.APPLICATION_ID)) { String type = r.getSubType(); if (SAKAI_SITE_TYPE.equals(type)) { // this is a Site String siteId = r.getId(); l.add(siteId); } } } } if (l.isEmpty()) log.info("Empty list of siteIds for user:" + userId + ", permission: " + permission); return l; }
public String initializeAction(Reference reference) { ToolSession toolSession = SessionManager.getCurrentToolSession(); toolSession.setAttribute(PermissionsHelper.TARGET_REF, reference.getReference()); // use the folder's context (as a site and as a resource) for roles Collection<String> rolesRefs = new ArrayList<String>(); rolesRefs.add(SiteService.siteReference(reference.getContext())); rolesRefs.add(reference.getReference()); toolSession.setAttribute(PermissionsHelper.ROLES_REF, rolesRefs); // ... with this description String title = reference.getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME); String[] args = { title }; toolSession.setAttribute(PermissionsHelper.DESCRIPTION, rb.getFormattedMessage("title.permissions", args)); // ... showing only locks that are prpefixed with this toolSession.setAttribute(PermissionsHelper.PREFIX, "content."); return BaseInteractionAction.getInitializationId(reference.getReference(), this.getTypeId(), this.getId()); }
/** * {@inheritDoc} */ public Collection getEntityAuthzGroups(Reference ref, String userId) { // double check that it's mine if (!APPLICATION_ID.equals(ref.getType())) return null; Collection rv = new Vector(); // if the reference is an AuthzGroup, and not a special one // get the list of realms for the azGroup-referenced resource if ((ref.getId() != null) && (ref.getId().length() > 0) && (!ref.getId().startsWith("!"))) { // add the current user's azGroup (for what azGroup stuff everyone can do, i.e. add) ref.addUserAuthzGroup(rv, sessionManager().getCurrentSessionUserId()); // make a new reference on the azGroup's id Reference refnew = entityManager().newReference(ref.getId()); rv.addAll(refnew.getAuthzGroups(userId)); } return rv; }
public void handleAccess(HttpServletRequest req, HttpServletResponse res, Reference ref, Collection copyrightAcceptedRefs) throws EntityPermissionException, EntityNotDefinedException, EntityAccessOverloadException, EntityCopyrightException { ReferenceParser parser = createParser(ref); checkSource(ref, parser); ContentEntityWrapper wrapper = (ContentEntityWrapper) ref.getEntity(); if (wrapper == null || wrapper.getBase() == null) { throw new EntityNotDefinedException(ref.getReference()); } else { Reference realRef = EntityManager.newReference(wrapper.getBase().getReference()); EntityProducer producer = realRef.getEntityProducer(); producer.getHttpAccess().handleAccess(req, res, realRef, copyrightAcceptedRefs); } }
/** * @inheritDoc */ public String getRssUrl(Reference ref) { String alias = null; List aliasList = aliasService.getAliases( ref.getReference() ); if ( ! aliasList.isEmpty() ) alias = ((Alias)aliasList.get(0)).getId(); StringBuilder rssUrlString = new StringBuilder(); rssUrlString.append( m_serverConfigurationService.getAccessUrl() ); rssUrlString.append(getAccessPoint(true)); rssUrlString.append(Entity.SEPARATOR); rssUrlString.append(REF_TYPE_ANNOUNCEMENT_RSS); rssUrlString.append(Entity.SEPARATOR); if ( alias != null) rssUrlString.append(alias); else rssUrlString.append(ref.getContext()); return rssUrlString.toString(); }
/** * From EntityProducer */ public boolean parseEntityReference(String referenceString, Reference reference) { String[] parts = referenceString.split(Entity.SEPARATOR); if (parts.length < 2 || !parts[1].equals("commons")) // Leading slash adds // an empty element return false; if (parts.length == 2) { reference.set("sakai:commons", "", "", null, ""); return true; } String siteId = parts[2]; String subType = parts[3]; /*String entityId = parts[4]; if ("posts".equals(subType)) { reference.set("commons", "posts", entityId, null, siteId); return true; }*/ return false; }
@Override protected String htmlContent(Event event) { StringBuilder buf = new StringBuilder(); // get the message Reference ref = EntityManager.newReference(event.getResource()); MailArchiveMessage msg = (MailArchiveMessage) ref.getEntity(); MailArchiveMessageHeader hdr = (MailArchiveMessageHeader) msg.getMailArchiveHeader(); // if html isn't available, convert plain-text into html buf.append( msg.getFormattedBody() ); // add any attachments List attachments = hdr.getAttachments(); if (attachments.size() > 0) { buf.append("<br/>" + "Attachments:<br/>"); for (Iterator iAttachments = attachments.iterator(); iAttachments.hasNext();) { Reference attachment = (Reference) iAttachments.next(); String attachmentTitle = attachment.getProperties().getPropertyFormatted(ResourceProperties.PROP_DISPLAY_NAME); buf.append("<br/><a href=\"" + attachment.getUrl() + "\" >" + attachmentTitle + "</a><br/>"); } } return buf.toString(); }
protected ContentEntityWrapper getContentEntityWrapper(Reference ref) { String wholeRef = ref.getReference(); ReferenceParser parser = parseReference(wholeRef); ContentResource base = (ContentResource) entityManager.newReference(parser.getRef()).getEntity(); //base could be null because we have a second level of wrapping if (base == null) { parser = parseReference(ref.getReference()); base = (ContentResource) entityManager.newReference(parser.getRef()).getEntity(); } return new ContentEntityWrapper(base, wholeRef); }
private String getSiteId(Reference ref) { return ref.getContext(); }