org.sakaiproject.entity.api.Reference类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中org.sakaiproject.entity.api.Reference类的一些代码示例,展示了Reference类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference类的具体详情如下:
包路径:org.sakaiproject.entity.api.Reference
类名称:Reference

Reference介绍

[英]Reference holds an immutable(?) reference to a Sakai entity.
[中]引用包含一个不可变的(?)对酒井实体的引用。

代码示例

代码示例来源:origin: sakaiproject/sakai

/**
 * 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;
}

代码示例来源:origin: sakaiproject/sakai

@Override
public String getReference() {
  return (reference != null) ? reference.getReference() : null;
}

代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-impl

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;
}

代码示例来源:origin: org.sakaiproject/sakai-rwiki-impl

/**
 * 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);
}

代码示例来源:origin: org.sakaiproject.polls/polls-impl

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;
}

代码示例来源:origin: sakaiproject/sakai

@Override
public String getId() {
  return (reference != null) ? reference.getId() : null;
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

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

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * 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);
  }
}

代码示例来源:origin: org.sakaiproject.announcement/sakai-announcement-impl

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);

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * {@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);
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * {@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;
}

代码示例来源:origin: org.sakaiproject.polls/polls-impl

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;
 }

代码示例来源:origin: org.sakaiproject.content/content-types

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());
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * {@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;
}

代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-api

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);
 }
}

代码示例来源:origin: org.sakaiproject.announcement/sakai-announcement-impl

/**
 * @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();
}

代码示例来源:origin: sakaiproject/sakai

/**
 * 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;
}

代码示例来源:origin: org.sakaiproject.mailarchive/sakai-mailarchive-impl

@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();
}

代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-impl

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);
}

代码示例来源:origin: org.sakaiproject.mailarchive/sakai-search-adapters-impl

private String getSiteId(Reference ref)
{
  return ref.getContext();
}

相关文章