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

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

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

Reference.isKnownType介绍

[英]Check if the reference's type is known
[中]检查引用的类型是否已知

代码示例

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

/**
 * Return the url unchanged, unless it's a reference, then return the reference url
 */
protected String convertReferenceUrl(String url)
{
  // make a reference
  Reference ref = entityManager().newReference(url);
  // if it didn't recognize this, return it unchanged
  if (!ref.isKnownType()) return url;
  // return the reference's url
  return ref.getUrl();
}

相关文章