org.sakaiproject.entity.api.Reference.getEntity()方法的使用及代码示例

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

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

Reference.getEntity介绍

[英]Find the Entity that is referenced.
[中]查找被引用的实体。

代码示例

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

public Object fetchEntity(String reference) {
  Object entity = null;
  try {
    // cannot test this in a meaningful way so the tests are designed to not get here -AZ
    entity = entityManager.newReference(reference).getEntity();
  } catch (Exception e) {
    log.warn("Failed to look up reference '" + reference
        + "' to an entity in Sakai legacy entity system", e);
  }
  return entity;
}

代码示例来源: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.assignment/sakai-assignment-impl

private ContentResource getFirstAcceptableAttachement() {
  String contentId = null;
  try {
  for( int i =0; i < m_submittedAttachments.size();i++ ) {
    Reference ref = (Reference)m_submittedAttachments.get(i);
    ContentResource contentResource = (ContentResource)ref.getEntity();
    if (contentReviewService.isAcceptableContent(contentResource)) {
      return (ContentResource)contentResource;
    }
  }
  }
  catch (Exception e) {
    M_log.warn(":getFirstAcceptableAttachment() " + e.getMessage());
    e.printStackTrace();
  }
  return null;
}

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

/**
 * SAK-26322 - Gets all attachments in m_submittedAttachments that are acceptable to the content review service
 */
private List<ContentResource> getAllAcceptableAttachments()
{
  List<ContentResource> attachments = new ArrayList<ContentResource>();
  for (int i = 0; i< m_submittedAttachments.size(); i++)
  {
    try
    {
      Reference ref = (Reference)m_submittedAttachments.get(i);
      ContentResource contentResource = (ContentResource)ref.getEntity();
      if (contentReviewService.isAcceptableContent(contentResource))
      {
        attachments.add((ContentResource)contentResource);
      }
    }
    catch (Exception e)
    {
      M_log.warn(":getAllAcceptableAttachments() " + e.getMessage());
      e.printStackTrace();
    }
  }
  return attachments;
}

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

try
  ContentResource resource = (ContentResource) ref.getEntity();

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

public void finalizeAction(Reference reference)
  {
    try
    {
      ContentResource resource = (ContentResource) reference.getEntity();
      String collectionId = new String(resource.getContent());
      CitationCollection collection = getCollection(collectionId);
      removeCollection(collection);
    }
    catch(IdUnusedException e)
    {
      M_log.warn("IdUnusedException ", e);
    }
    catch(ServerOverloadException e)
    {
      M_log.warn("ServerOverloadException ", e);
    }
  }
}

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

public String getTitle(String reference)
{
  Reference ref = getReference(reference);
  Entity cr = ref.getEntity();
  RWikiEntity rwe = (RWikiEntity) cr;
  RWikiObject rwo = rwe.getRWikiObject();
  String r = SearchUtils.appendCleanString(rwo.getName(), null).toString();
  if (log.isDebugEnabled())
  {
    log.debug("Wiki.getTitle:" + reference + ":" + r);
  }
  return r;
}

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

/**
 * @inheritDoc
 */
protected List getHeaders(Event event)
{
  // send most of the headers from the original message, removing some
  Reference ref = EntityManager.newReference(event.getResource());
  MailArchiveMessage msg = (MailArchiveMessage) ref.getEntity();
  MailArchiveMessageHeader hdr = (MailArchiveMessageHeader) msg.getMailArchiveHeader();
  List headers = hdr.getMailHeaders();
  List filteredHeaders = super.getHeaders(event);
  for (int i = 0; i < headers.size(); i++)
  {
    String headerStr = (String) headers.get(i);
    if (headerStr.regionMatches(true, 0, MailArchiveService.HEADER_RETURN_PATH, 0, MailArchiveService.HEADER_RETURN_PATH.length())) 
      continue;
    if (headerStr.regionMatches(true, 0, MailArchiveService.HEADER_CONTENT_TRANSFER_ENCODING, 0, MailArchiveService.HEADER_CONTENT_TRANSFER_ENCODING.length())) 
      continue;
    if (headerStr.regionMatches(true, 0, MailArchiveService.HEADER_CONTENT_TYPE, 0, MailArchiveService.HEADER_CONTENT_TYPE.length())) 
      continue;
    
    filteredHeaders.add(headerStr);
  }
  return filteredHeaders;
}

代码示例来源: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/sakai-rwiki-impl

public boolean canRead(String reference)
{
  try
  {
    Reference ref = getReference(reference);
    RWikiEntity rwe = (RWikiEntity) ref.getEntity();
    RWikiObject rwo = rwe.getRWikiObject();
    return objectService.checkRead(rwo);
  }
  catch (Exception ex)
  {
  }
  return false;
}

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

MailArchiveMessage msg = (MailArchiveMessage) ref.getEntity();
MailArchiveMessageHeader hdr = (MailArchiveMessageHeader) msg.getMailArchiveHeader();

代码示例来源: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.metaobj/sakai-metaobj-tool-lib

public static String getReferenceName(String idString, String decoration) {
 String refString = getContentHostingService().getReference(idString);
 String contentRef = refString;
 if (decoration != null && !decoration.equals("")) {
   refString = decoration + refString;
 }
 Reference ref = EntityManager.newReference(refString);
 getSecurityService().pushAdvisor(
     new LocalSecurityAdvisor(ContentHostingService.EVENT_RESOURCE_READ,
         contentRef));
 
 if (ref == null || ref.getEntity() == null) {
   return "";
 }
 
 ResourceProperties props = ref.getEntity().getProperties();
 String prop = props.getNamePropDisplayName();
 return props.getProperty(prop);
}

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

Entity entity = siteRef.getEntity();

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

public static String getReferenceUrl(String idString, String decoration) {
 String refString = getContentHostingService().getReference(idString);
 String contentRef = refString;
 if (decoration != null && !decoration.equals("")) {
   refString = decoration + refString;
 }
 
 getSecurityService().pushAdvisor(
     new LocalSecurityAdvisor(ContentHostingService.EVENT_RESOURCE_READ,
         contentRef));
 
 Reference ref = EntityManager.newReference(refString);
 if (ref == null || ref.getEntity() == null) {
   return "";
 }
 return ref.getUrl();
}

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

public String getContent(String reference)
{
  Reference ref = getReference(reference);
  Entity cr = ref.getEntity();
  RWikiEntity rwe = (RWikiEntity) cr;
  RWikiObject rwo = rwe.getRWikiObject();
  String pageName = rwo.getName();
  String pageSpace = NameHelper.localizeSpace(pageName, rwo.getRealm());
  String renderedPage = renderService.renderPage(rwo, pageSpace, objectService
      .getComponentPageLinkRender(pageSpace,true));
  StringBuilder sb = new StringBuilder();
  for (HTMLParser hp = new HTMLParser(renderedPage); hp.hasNext();)
  {
    SearchUtils.appendCleanString(hp.next(), sb);
  }
  String r = sb.toString();
  if (log.isDebugEnabled())
  {
    log.debug("Wiki.getContent:" + reference + ":" + r);
  }
  return r;
}

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

public boolean isForIndex(String reference)
{
  try
  {
    Reference ref = getReference(reference);
    RWikiEntity rwe = (RWikiEntity) ref.getEntity();
    RWikiObject rwo = rwe.getRWikiObject();
    String pageName = rwo.getName();
    String pageSpace = NameHelper.localizeSpace(pageName, rwo.getRealm());
    if (objectService.exists(pageName, pageSpace))
    {
      return true;
    }
  }
  catch (Exception ex)
  {
  }
  return false;
}

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

protected String getField(String column) {
  String field;
  Reference ref = EntityManager.newReference(link.getTagCriteriaRef());
  Entity entity = ref.getEntity();

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

/**
 * @inheritDoc
 */
public void notify(Notification notification, Event event)
{
  // get the message
  Reference ref = entityManager.newReference(event.getResource());
  AnnouncementMessageEdit msg = (AnnouncementMessageEdit) ref.getEntity();
  AnnouncementMessageHeader hdr = (AnnouncementMessageHeader) msg.getAnnouncementHeader();
  // do not do notification for hidden (draft) messages
  if (hdr.getDraft()) return;
  // Put here since if release date after now, do not notify
  // since scheduled notification has been set.
  Time now = timeService.newTime();
  
  if (now.after(hdr.getDate()))
  {
    super.notify(notification, event);
  }
}

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

/**
 * Format the announcement notification subject line.
 * 
 * @param event
 *        The event that matched criteria to cause the notification.
 * @return the announcement notification subject line.
 */
protected String getSubject(Event event)
{
  // get the message
  Reference ref = entityManager.newReference(event.getResource());
  AnnouncementMessage msg = (AnnouncementMessage) ref.getEntity();
  AnnouncementMessageHeader hdr = (AnnouncementMessageHeader) msg.getAnnouncementHeader();
  // use either the configured site, or if not configured, the site (context) of the resource
  String siteId = (getSite() != null) ? getSite() : ref.getContext();
  // get a site title
  String title = siteId;
  try
  {
    Site site = siteService.getSite(siteId);
    title = site.getTitle();
  }
  catch (Exception ignore)
  {
  }
  // use the message's subject
  return rb.getFormattedMessage("noti.subj", new Object[]{title, hdr.getSubject()});
}

相关文章