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; }
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); } }
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; }
/** * 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; }
try ContentResource resource = (ContentResource) ref.getEntity();
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); } } }
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; }
/** * @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; }
@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(); }
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; }
MailArchiveMessage msg = (MailArchiveMessage) ref.getEntity(); MailArchiveMessageHeader hdr = (MailArchiveMessageHeader) msg.getMailArchiveHeader();
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); }
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); }
Entity entity = siteRef.getEntity();
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(); }
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; }
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; }
protected String getField(String column) { String field; Reference ref = EntityManager.newReference(link.getTagCriteriaRef()); Entity entity = ref.getEntity();
/** * @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); } }
/** * 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()}); }