本文整理了Java中org.sakaiproject.entity.api.Reference.getContext
方法的一些代码示例,展示了Reference.getContext
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.getContext
方法的具体详情如下:
包路径:org.sakaiproject.entity.api.Reference
类名称:Reference
方法名:getContext
[英]Access the context id, if any. Typically this is the site in which the entity is contained, although other contexts are possible.
[中]访问上下文id(如果有)。通常情况下,这是包含实体的站点,但也可以使用其他上下文。
代码示例来源:origin: org.sakaiproject/sakai-chat-impl
private String getSiteId(Reference ref)
{
return ref.getContext();
}
代码示例来源:origin: org.sakaiproject.mailarchive/sakai-search-adapters-impl
private String getSiteId(Reference ref)
{
return ref.getContext();
}
代码示例来源: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: org.sakaiproject.assignment/sakai-assignment-impl
public String getContext(String ref) {
return entityManager.newReference(ref).getContext();
}
代码示例来源:origin: org.sakaiproject/sakai-rwiki-impl
private String getSiteId(Reference ref)
{
String context = ref.getContext();
if (context.startsWith("/site/"))
{
context = context.substring("/site/".length());
}
if (context.startsWith("/"))
{
context = context.substring(1);
}
int slash = context.indexOf("/");
if (slash > 0)
{
context = context.substring(0, slash);
}
if (log.isDebugEnabled())
{
log.debug("Wiki.getSiteId" + ref + ":" + context);
}
return context;
}
代码示例来源:origin: org.sakaiproject.basiclti/basiclti-impl
/**
* Check security for this entity.
*
* @param ref
* The Reference to the entity.
* @return true if allowed, false if not.
*/
protected boolean checkSecurity(Reference ref)
{
String contextId = ref.getContext();
try
{
Site site = SiteService.getSiteVisit(contextId);
if ( site != null ) return true;
}
catch(IdUnusedException ex)
{
return false;
}
catch(PermissionException ex)
{
return false;
}
// System.out.println("ID="+ref.getId());
// System.out.println("Type="+ref.getType());
// System.out.println("SubType="+ref.getSubType());
return false;
}
/*******************************************************************************
代码示例来源:origin: org.sakaiproject/sakai-rwiki-impl
public String getSiteId()
{
RWikiObjectService rwobjService = getObjectService();
RWikiObject rwobj = getRWikiObject();
Reference ref = rwobjService.getReference(rwobj);
String siteContext = ref.getContext();
if (siteContext.startsWith("/site/")) //$NON-NLS-1$
{
String siteId = siteContext.substring(6);
int slash = siteId.indexOf("/"); //$NON-NLS-1$
if (slash != -1)
{
siteId = siteId.substring(0, slash - 1);
}
return siteId;
}
return null;
}
代码示例来源: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: org.sakaiproject.kernel/sakai-kernel-impl
/**
* Checks if a dropbox owner is in any group with current user, so AUTH_DROPBOX_GROUPS is rightly applied.
* @return true if the dropbox owner is in the group, false otherwise.
*/
public boolean isDropboxOwnerInCurrentUserGroups(String refString, String userId)
{
String currentUser = sessionManager.getCurrentSessionUserId();
List<Group> site_groups = new ArrayList<Group>();
Reference ref = m_entityManager.newReference(refString);
try
{
Site site = m_siteService.getSite(ref.getContext());
site_groups.addAll(site.getGroupsWithMembers(new String[]{currentUser,userId}));
if (site_groups.size()>0)
{
return true;
}
}
catch (IdUnusedException e)
{
}
return false;
}
代码示例来源:origin: org.sakaiproject.message/sakai-message-impl
/**
* Construct with a reference.
*
* @param ref
* The channel reference.
*/
public BaseMessageChannelEdit(String ref)
{
// set the ids
Reference r = m_entityManager.newReference(ref);
m_context = r.getContext();
m_id = r.getId();
// setup for properties
m_properties = new BaseResourcePropertiesEdit();
} // BaseMessageChannelEdit
代码示例来源:origin: sakaiproject/sakai
/**
* Construct with a reference.
*
* @param ref
* The channel reference.
*/
public BaseMessageChannelEdit(String ref)
{
// set the ids
Reference r = m_entityManager.newReference(ref);
m_context = r.getContext();
m_id = r.getId();
// setup for properties
m_properties = new BaseResourcePropertiesEdit();
} // BaseMessageChannelEdit
代码示例来源: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.message/sakai-message-util
/**
* Construct with a reference.
*
* @param ref
* The channel reference.
*/
public BaseMessageChannelEdit(String ref)
{
// set the ids
Reference r = m_entityManager.newReference(ref);
m_context = r.getContext();
m_id = r.getId();
// setup for properties
m_properties = new BaseResourcePropertiesEdit();
} // BaseMessageChannelEdit
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
Reference siteRef = entityManager.newReference(Entity.SEPARATOR+ SiteService.SITE_SUBTYPE+ Entity.SEPARATOR+ contentRef.getContext());
Entity entity = siteRef.getEntity();
代码示例来源:origin: org.sakaiproject.content/content-types
public boolean available(ContentEntity entity) {;
return ServerConfigurationService.getBoolean("content.make.site.page",true)
// Not in a dropbox
&& !ContentHostingService.isInDropbox(entity.getId())
// Not in a user site.
&& !SiteService.isUserSite(EntityManager.newReference(entity.getReference()).getContext());
}
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
private String generateContentForType(boolean shouldProduceHtml, Event event) {
// get the content & properties
Reference ref = entityManager.newReference(event.getResource());
// TODO: ResourceProperties props = ref.getProperties();
// get the function
String function = event.getEvent();
String subject = getSubject(event);
// 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)
{
}
StringBuilder buf = new StringBuilder();
addMessageText(buf, ref, subject, title, function, shouldProduceHtml);
return buf.toString();
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
private String generateContentForType(boolean shouldProduceHtml, Event event)
{
// get the content & properties
Reference ref = entityManager.newReference(event.getResource());
// TODO: ResourceProperties props = ref.getProperties();
// get the function
String function = event.getEvent();
String subject = getSubject(event);
// 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)
{
}
StringBuilder buf = new StringBuilder();
addMessageText(buf, ref, subject, title, function, shouldProduceHtml);
return buf.toString();
}
代码示例来源: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: sakaiproject/sakai
/**
* Format a to address, to the related site, but with no reply.
*
* @param event
* The event that matched criteria to cause the notification.
* @return a to address, to the related site, but with no reply.
*/
protected String getToSiteNoReply(Event event)
{
Reference ref = EntityManager.newReference(event.getResource());
// 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)
{
}
return "\"" + title + "\" <"+ ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()) + ">";
}
代码示例来源: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()});
}
内容来源于网络,如有侵权,请联系作者删除!