private void checkReference(Reference ref) { if (!APPLICATION_ID.equals(ref.getType())) throw new RuntimeException( "Wiki page does not exist, sorry "); //$NON-NLS-1$ }
/** * Given a resourceFilter, get the associated type. See {@link org.sakaiproject.entity.impl.ReferenceComponent#getType} * * @param resourceFilter the resourceFilter to get the type from * @return the resourceFilter's type */ protected String getType(String resourceFilter) { return EntityManager.newReference(resourceFilter).getType(); }
/** * {@inheritDoc} */ public String getType(String ref) { try { return getReference(ref).getType(); } catch ( Exception ex ) { return ""; } }
/** * 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 String getType(String reference) { try { String r = getReference(reference).getType(); if (log.isDebugEnabled()) { log.debug("Wiki.getType:" + reference + ":" + r); } return r; } catch (Exception ex) { return ""; } }
public String getType(String reference) { try { String r = getReference(reference).getType(); if (log.isDebugEnabled()) { log.debug("Message." + toolName + ".getContainer" + reference + ":" + r); } return r; } catch (Exception ex) { return ""; } }
/** * {@inheritDoc} */ public Entity getEntity(Reference ref) { // double check that it's mine if (!APPLICATION_ID.equals(ref.getType())) return null; Entity rv = null; try { rv = getSite(ref.getId()); } catch (IdUnusedException e) { log.warn("getEntity(): " + e); } catch (NullPointerException e) { log.warn("getEntity(): " + e); } return rv; }
/** * {@inheritDoc} */ public String getEntityUrl(Reference ref) { // double check that it's mine if (!APPLICATION_ID.equals(ref.getType())) return null; return getUrl(convertIdToUserEid(ref.getId())); }
/** * @inheritDoc */ public Collection<String> getEntityAuthzGroups(Reference ref, String userId) { // double check that it's mine if (!APPLICATION_ID.equals(ref.getType())) return null; Collection<String> rv = new Vector<String>(); // for user access: user and template realms try { rv.add(userReference(ref.getId())); ref.addUserTemplateAuthzGroup(rv, userId); } catch (NullPointerException e) { log.warn("getEntityRealms(): " + e); } return rv; }
/** * {@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; }
/** * @inheritDoc */ public Collection<String> getEntityAuthzGroups(Reference ref, String userId) { // double check that it's mine if (!APPLICATION_ID.equals(ref.getType())) return null; Collection<String> rv = new Vector<String>(); // for preferences access: no additional role realms try { rv.add(userDirectoryService().userReference(ref.getId())); ref.addUserTemplateAuthzGroup(rv, userId); } catch (NullPointerException e) { log.warn("getEntityAuthzGroups(): " + e); } return rv; }
/** * 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); } }
public Entity getEntity(Reference ref) { CoreEntityProvider entityProvider = (CoreEntityProvider) entityProviderManager .getProviderByPrefix(ref.getType()); if (entityProvider != null) { if (entityProvider.entityExists(ref.getId())) { Entity togo = newEntity(ref); return togo; } } return null; }
/** * @inheritDoc */ public String getEntityDescription(Reference ref) { // double check that it's mine if (!APPLICATION_ID.equals(ref.getType())) return null; String rv = "User: " + ref.getReference(); try { User user = getUser(ref.getId()); rv = "User: " + user.getDisplayName(); } catch (UserNotDefinedException e) { } catch (NullPointerException e) { } return rv; }
/** * {@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 static String getImageUrl(String idString) { String refString = getContentHostingService().getReference(idString); Reference ref = EntityManager.newReference(refString); if (ref == null) { return "/library/image/sakai/unknown.gif"; } return "/library/image" + getContentTypeImageService().getContentTypeImage(ref.getType()); }
/** * {@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 void refreshAuthzGroup(BaseAuthzGroup azGroup) { if (azGroup == null) return; if (azGroup.m_isNew) { // refresh new authz groups immediately log.debug("Refresh new authz group: {}", azGroup.getId()); refreshAuthzGroupInternal(azGroup); // refresh parent Reference reference = entityManager.newReference(azGroup.getId()); if (SiteService.APPLICATION_ID.equals(reference.getType()) && SiteService.GROUP_SUBTYPE.equals(reference.getSubType())) { try { refreshAuthzGroupInternal((BaseAuthzGroup) getAuthzGroup(siteService.siteReference(reference.getContainer()))); } catch (Exception e) { log.warn("Cannot refresh parent authz group for authz group: {}", azGroup.getId(), e); } } } else { // Add the AuthzGroup to the queue, keyed on id to eliminate duplicate refreshes log.debug("Queue authz group for refresh " + azGroup.getId()); refreshQueue.put(azGroup.getId(), azGroup); } }
/** * Update the site security based on the values in the AuthzGroup, if it is a site AuthzGroup. * * @param azGroup * The AuthzGroup. */ protected void updateSiteSecurity(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())) { // collect the users Set updUsers = azGroup.getUsersIsAllowed(SiteService.SECURE_UPDATE_SITE); Set unpUsers = azGroup.getUsersIsAllowed(SiteService.SITE_VISIT_UNPUBLISHED); Set visitUsers = azGroup.getUsersIsAllowed(SiteService.SITE_VISIT); siteService.setSiteSecurity(ref.getId(), updUsers, unpUsers, visitUsers); } }