当前位置: 首页>>代码示例>>Java>>正文


Java Response.addMetadata方法代码示例

本文整理汇总了Java中com.google.enterprise.adaptor.Response.addMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Response.addMetadata方法的具体用法?Java Response.addMetadata怎么用?Java Response.addMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.enterprise.adaptor.Response的用法示例。


在下文中一共展示了Response.addMetadata方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDocContent

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
@Override
public void getDocContent(Request req, Response resp) throws IOException {
  log.entering("LdapAdaptor", "getDocContent", new Object[] {req, resp});
  DocId id = req.getDocId();
  ParsedDocId parsed = parseDocId(id);

  if (parsed == null
      || !id.equals(makeDocId(parsed.serverNumber, parsed.dn))) {
    log.warning(id + " is not a valid id generated by this adaptor.");
    resp.respondNotFound();
    return;
  }

  LdapPerson fetched;
  try {
    LdapServer server = servers.get(parsed.serverNumber);
    fetched = server.fetchOne(parsed.dn);
    if (null == fetched) {
      log.finer("No results found for DN " + parsed.dn + "");
      resp.respondNotFound();
      log.exiting("LdapAdaptor", "getDocContent", 0);
      return;
    }
    for (Entry<String, String> metadatum : fetched.asMetadata().entrySet()) {
      resp.addMetadata(metadatum.getKey(), metadatum.getValue());
    }
    InputStream input = new ByteArrayInputStream(fetched.asDoc(
        server.getDisplayTemplate()).getBytes(CHARSET));
    resp.setContentType("text/html; charset=" + CHARSET.name() + "");
    IOHelper.copyStream(input, resp.getOutputStream());
    log.exiting("LdapAdaptor", "getDocContent", 1);
  } catch (InterruptedNamingException e) {
    log.exiting("LdapAdaptor", "getDocContent", 2);
    throw new IOException(e);
  }
}
 
开发者ID:googlegsa,项目名称:ldap,代码行数:37,代码来源:LdapAdaptor.java

示例2: doCategories

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
@VisibleForTesting
void doCategories(DocumentManagement documentManagement, Node node,
    Response response) {
  if (!this.indexCategories) {
    return;
  }
  Metadata metadata = node.getMetadata();
  if (metadata == null) {
    return;
  }
  List<AttributeGroup> attributeGroups = metadata.getAttributeGroups();
  if (attributeGroups == null) {
    return;
  }

  for (AttributeGroup attributeGroup : attributeGroups) {
    if (!shouldIndex(attributeGroup)) {
      continue;
    }
    cacheCategoryDefinition(attributeGroup, documentManagement);
    // Check to see if we'll need to do user lookups.
    MemberService memberService = null;
    if (this.categoriesWithUserAttributes
        .contains(attributeGroup.getKey())) {
      memberService = this.soapFactory.newMemberService(documentManagement);
    }
    if (this.indexCategoryNames && attributeGroup.getDisplayName() != null) {
      response.addMetadata("Category", attributeGroup.getDisplayName());
    }
    doAttributeGroup(
        response, memberService, attributeGroup, this.attributeDefinitions);
  }
}
 
开发者ID:googlegsa,项目名称:opentext,代码行数:34,代码来源:OpentextAdaptor.java

示例3: doMilestone

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
@VisibleForTesting
void doMilestone(DocumentManagement documentManagement,
    OpentextDocId opentextDocId, Node node, Response response)
    throws IOException {
  Collaboration collaboration =
      this.soapFactory.newCollaboration(documentManagement);
  MilestoneInfo milestoneInfo = null;
  try {
    milestoneInfo = collaboration.getMilestone(node.getID());
  } catch (SOAPFaultException soapFaultException) {
    log.log(Level.WARNING,
        "Error retrieving milestone: " + opentextDocId, soapFaultException);
    // If we can't fetch the MilestoneInfo, at least treat the
    // node as a generic container.
    doContainer(documentManagement, opentextDocId, node, response);
    return;
  }
  addChildAnchors(documentManagement, opentextDocId, response);
  addDateMetadata("ActualDate", milestoneInfo.getActualDate(), response);
  addDateMetadata("OriginalTargetDate",
      milestoneInfo.getOriginalTargetDate(), response);
  addDateMetadata("TargetDate", milestoneInfo.getTargetDate(), response);
  response.addMetadata("Duration",
      String.valueOf(milestoneInfo.getDuration()));
  response.addMetadata("NumActive",
      String.valueOf(milestoneInfo.getNumActive()));
  response.addMetadata("NumCancelled",
      String.valueOf(milestoneInfo.getNumCancelled()));
  response.addMetadata("NumCompleted",
      String.valueOf(milestoneInfo.getNumCompleted()));
  response.addMetadata("NumInProcess",
      String.valueOf(milestoneInfo.getNumInprocess()));
  response.addMetadata("NumIssue",
      String.valueOf(milestoneInfo.getNumIssue()));
  response.addMetadata("NumLate",
      String.valueOf(milestoneInfo.getNumLate()));
  response.addMetadata("NumOnHold",
      String.valueOf(milestoneInfo.getNumOnHold()));
  response.addMetadata("NumPending",
      String.valueOf(milestoneInfo.getNumPending()));
  response.addMetadata("NumTasks",
      String.valueOf(milestoneInfo.getNumTasks()));
  response.addMetadata("PercentCancelled",
      String.valueOf(milestoneInfo.getPercentCancelled()));
  response.addMetadata("PercentComplete",
      String.valueOf(milestoneInfo.getPercentComplete()));
  response.addMetadata("PercentInProcess",
      String.valueOf(milestoneInfo.getPercentInprocess()));
  response.addMetadata("PercentIssue",
      String.valueOf(milestoneInfo.getPercentIssue()));
  response.addMetadata("PercentLate",
      String.valueOf(milestoneInfo.getPercentLate()));
  response.addMetadata("PercentOnHold",
      String.valueOf(milestoneInfo.getPercentOnHold()));
  response.addMetadata("PercentPending",
      String.valueOf(milestoneInfo.getPercentPending()));
  response.addMetadata("Resources",
      String.valueOf(milestoneInfo.getResources()));
  writeHtmlResponse(response, node, node.getName());
}
 
开发者ID:googlegsa,项目名称:opentext,代码行数:61,代码来源:OpentextAdaptor.java

示例4: addStringMetadata

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
private void addStringMetadata(
    String name, String value, Response response) {
  if (!Strings.isNullOrEmpty(value)) {
    response.addMetadata(name, value);
  }
}
 
开发者ID:googlegsa,项目名称:opentext,代码行数:7,代码来源:OpentextAdaptor.java

示例5: addDateMetadata

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
private void addDateMetadata(
    String name, XMLGregorianCalendar xmlCalendar, Response response) {
  if (xmlCalendar != null) {
    response.addMetadata(name, getDateAsString(xmlCalendar));
  }
}
 
开发者ID:googlegsa,项目名称:opentext,代码行数:7,代码来源:OpentextAdaptor.java

示例6: doPrimitiveValue

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
@VisibleForTesting
void doPrimitiveValue(PrimitiveValue primitiveValue, Response response,
    Map<String, Attribute> attributeDefinitions,
    MemberService memberService) {

  String name = primitiveValue.getDescription();
  if (name == null) {
    log.log(Level.FINEST,
        "No name for attribute {0}; skipping", primitiveValue.getKey());
    return;
  }

  boolean isUserAttribute = false;
  boolean isSearchable = false;
  Attribute attribute = attributeDefinitions.get(primitiveValue.getKey());
  if (attribute != null) {
    isUserAttribute = (attribute instanceof UserAttribute);
    if (attribute.isSearchable() != null) {
      isSearchable = attribute.isSearchable();
    }
  }
  if (this.indexSearchableAttributesOnly && !isSearchable) {
    return;
  }

  List<? extends Object> values = null;
  if (primitiveValue instanceof StringValue) {
    values = ((StringValue) primitiveValue).getValues();
  } else if (primitiveValue instanceof BooleanValue) {
    values = ((BooleanValue) primitiveValue).getValues();
  } else if (primitiveValue instanceof RealValue) {
    values = ((RealValue) primitiveValue).getValues();
  } else if (primitiveValue instanceof DateValue) {
    List<XMLGregorianCalendar> dateValues =
        ((DateValue) primitiveValue).getValues();
    List<String> dateStrings = new ArrayList<String>(dateValues.size());
    for (XMLGregorianCalendar xmlCalendar : dateValues) {
      if (xmlCalendar != null) {
        dateStrings.add(getDateAsString(xmlCalendar));
      }
    }
    values = dateStrings;
  } else if (primitiveValue instanceof IntegerValue) {
    // IntegerValue's enclosed type is Long.
    if (isUserAttribute && memberService != null) {
      try {
        List<Member> members = memberService.getMembersByID(
            ((IntegerValue) primitiveValue).getValues());
        List<String> usernames = new ArrayList<String>(members.size());
        for (Member member : members) {
          if (member != null && member.getName() != null) {
            usernames.add(member.getName());
          }
        }
        values = usernames;
      } catch (SOAPFaultException soapFaultException) {
        log.log(Level.FINER,
            "Failed to look up member names for attribute " + name,
            soapFaultException);
      }
    } else {
      values = ((IntegerValue) primitiveValue).getValues();
    }
  }

  if (values != null) {
    for (Object value : values) {
      if (value != null) {
        response.addMetadata(name, value.toString());
      }
    }
  }
}
 
开发者ID:googlegsa,项目名称:opentext,代码行数:74,代码来源:OpentextAdaptor.java

示例7: doNodeFeatures

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
void doNodeFeatures(Node node, Response response) {
  List<NodeFeature> features = node.getFeatures();
  if (features == null || features.size() == 0) {
    return;
  }
  List<String> includedFeatures =
      this.includedNodeFeatures.get(node.getType());
  if (includedFeatures == null) {
    // NodeFeatures to index must be explicitly configured.
    // TODO: we're not logging this case for every node
    // encountered; in future, try to log a message once for
    // each type with NodeFeatures that aren't being indexed.
    return;
  }

  for (NodeFeature feature : features) {
    String name = feature.getName();
    if (name == null) {
      continue;
    }
    if (!includedFeatures.contains(name)) {
      continue;
    }
    String value = null;
    switch (feature.getType()) {
      case "String":
        value = feature.getStringValue();
        break;
      case "Integer":
        if (feature.getIntegerValue() != null) {
          value = feature.getIntegerValue().toString();
        }
        break;
      case "Long":
        if (feature.getLongValue() != null) {
          value = feature.getLongValue().toString();
        }
        break;
      case "Date":
        if (feature.getDateValue() != null) {
          value = getDateAsString(feature.getDateValue());
        }
        break;
      case "Boolean":
        // The getter for boolean features really is "isBooleanValue".
        if (feature.isBooleanValue() != null) {
          value = feature.isBooleanValue().toString();
        }
        break;
      default:
        log.log(Level.FINEST,
            "Unknown feature type " + feature.getType()
            + " in NodeFeature " + name
            + " for object " + node.getID());
    }
    if (value != null) {
      response.addMetadata(name, value);
    }
  }
}
 
开发者ID:googlegsa,项目名称:opentext,代码行数:61,代码来源:OpentextAdaptor.java

示例8: doNodeProperties

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
@VisibleForTesting
void doNodeProperties(DocumentManagement documentManagement,
    Node node, Response response) {

  response.addMetadata("ID", String.valueOf(node.getID()));

  String name = node.getName();
  if (!Strings.isNullOrEmpty(name)) {
    response.addMetadata("Name", name);
  }

  String comment = node.getComment();
  if (!Strings.isNullOrEmpty(comment)) {
    response.addMetadata("Comment", comment);
  }

  XMLGregorianCalendar xmlCalendar = node.getCreateDate();
  if (xmlCalendar != null) {
    response.addMetadata("CreateDate", getDateAsString(xmlCalendar));
  }
  xmlCalendar = node.getModifyDate();
  if (xmlCalendar != null) {
    response.addMetadata("ModifyDate", getDateAsString(xmlCalendar));
    Date lastModifiedDate = xmlCalendar.toGregorianCalendar().getTime();
    response.setLastModified(lastModifiedDate);
  }

  if (node.getCreatedBy() != null) {
    MemberService memberService =
        this.soapFactory.newMemberService(documentManagement);
    try {
      Member member = memberService.getMemberById(node.getCreatedBy());
      if (member.getName() != null) {
        response.addMetadata("CreatedBy", member.getName());
      }
    } catch (SOAPFaultException soapFaultException) {
      log.log(Level.FINE,
          "Failed to look up node creator for " + node.getID(),
          soapFaultException);
    }
  }

  response.addMetadata("SubType", node.getType());
  String displayType = node.getDisplayType();
  if (!Strings.isNullOrEmpty(displayType)) {
    response.addMetadata("DisplayType", displayType);
  }

  response.addMetadata("VolumeID", String.valueOf(node.getVolumeID()));

  if (node.isIsVersionable()) {
    NodeVersionInfo versionInfo = node.getVersionInfo();
    if (versionInfo != null) {
      String mimeType = versionInfo.getMimeType();
      if (!Strings.isNullOrEmpty(mimeType)) {
        response.addMetadata("MimeType", mimeType);
      }
      Long dataSize = versionInfo.getFileDataSize();
      if (dataSize != null) {
        response.addMetadata("DataSize", dataSize.toString());
      }
    }
  }
}
 
开发者ID:googlegsa,项目名称:opentext,代码行数:65,代码来源:OpentextAdaptor.java

示例9: getListDocContent

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
private void getListDocContent(Request request, Response response,
    String id) throws IOException {
  log.entering("SiteAdaptor", "getListDocContent",
      new Object[] {request, response, id});
  com.microsoft.schemas.sharepoint.soap.List l
      = siteDataClient.getContentList(id);
  Web w = siteDataClient.getContentWeb();

  if (TrueFalseType.TRUE.equals(l.getMetadata().getNoIndex())
      || isWebNoIndex(new CachedWeb(w))) {
    log.fine("Document marked for NoIndex");
    response.respondNotFound();
    log.exiting("SiteAdaptor", "getListDocContent");
    return;
  }

  boolean allowAnonymousAccess
      = isAllowAnonymousReadForList(new CachedList(l))
      && isAllowAnonymousPeekForWeb(new CachedWeb(w))
      && (!isDenyAnonymousAccessOnVirtualServer());

  if (!allowAnonymousAccess) {
    String scopeId
        = l.getMetadata().getScopeID().toLowerCase(Locale.ENGLISH);
    String webScopeId
        = w.getMetadata().getScopeID().toLowerCase(Locale.ENGLISH);

    DocId rootFolderDocId
        = encodeDocId(l.getMetadata().getRootFolder());

    Acl.Builder acl;
    if (scopeId.equals(webScopeId)) {
      acl = new Acl.Builder().setInheritFrom(new DocId(webUrl));
    } else {
      List<Permission> permissions
          = l.getACL().getPermissions().getPermission();
      acl = generateAcl(permissions, LIST_ITEM_MASK)
          .setInheritFrom(siteDocId, SITE_COLLECTION_ADMIN_FRAGMENT);
    }
    response.setAcl(new Acl.Builder().setInheritFrom(rootFolderDocId)
        .setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES)
        .build());
    context.getAsyncDocIdPusher().pushNamedResource(rootFolderDocId,
            acl.setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES)
                .build());
  }

  response.addMetadata(METADATA_OBJECT_TYPE,
      ObjectType.LIST.value());
  response.addMetadata(METADATA_PARENT_WEB_TITLE,
      w.getMetadata().getTitle());
  response.addMetadata(METADATA_LIST_GUID, l.getMetadata().getID());

  response.setDisplayUrl(sharePointUrlToUri(
        "/".equals(l.getMetadata().getDefaultViewUrl()) 
        ? l.getMetadata().getRootFolder() 
        : l.getMetadata().getDefaultViewUrl()));
  String lastModified = l.getMetadata().getLastModified();
  try {
    response.setLastModified(
        listLastModifiedDateFormat.get().parse(lastModified));
  } catch (ParseException ex) {
    log.log(Level.INFO, "Could not parse LastModified: {0}", lastModified);
  }
  HtmlResponseWriter writer = createHtmlResponseWriter(response);
  writer.start(request.getDocId(), ObjectType.LIST,
      l.getMetadata().getTitle());
  processFolder(id, "", writer);
  writer.finish();
  log.exiting("SiteAdaptor", "getListDocContent");
}
 
开发者ID:googlegsa,项目名称:sharepoint,代码行数:72,代码来源:SharePointAdaptor.java

示例10: addMetadata

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
private long addMetadata(Response response, String name, String value,
    Multimap<String, String> addedMetadata) {
  long size = 0;
  if ("ows_MetaInfo".equals(name)) {
    // ows_MetaInfo is parsed out into other fields for us by SharePoint.
    // We filter it since it only duplicates those other fields.
    return 0;
  }
  if (name.startsWith("ows_")) {
    name = name.substring("ows_".length());
  }
  name = decodeMetadataName(name);
  if (ALTERNATIVE_VALUE_PATTERN.matcher(value).find()) {
    // This is a lookup field. We need to take alternative values only.
    // Ignore the integer part. 314;#pi;#42;#the answer
    String[] parts = value.split(";#", 0);
    for (int i = 1; i < parts.length; i += 2) {
      if (parts[i].isEmpty()) {
        continue;
      }
      response.addMetadata(name, parts[i]);
      if (addedMetadata != null) {
        addedMetadata.put(name, parts[i]);
      }
      // +30 for per-metadata-possible overhead, just to make sure that we
      // don't count too few.
      size += name.length() + parts[i].length() + 30;
    }
  } else if (value.startsWith(";#") && value.endsWith(";#")) {
    // This is a multi-choice field. Values will be in the form:
    // ;#value1;#value2;#
    for (String part : value.split(";#", 0)) {
      if (part.isEmpty()) {
        continue;
      }
      response.addMetadata(name, part);
      if (addedMetadata != null) {
        addedMetadata.put(name, part);
      }
      // +30 for per-metadata-possible overhead, just to make sure that we
      // don't count too few.
      size += name.length() + part.length() + 30;
    }
  } else {
    response.addMetadata(name, value);
    if (addedMetadata != null) {
      addedMetadata.put(name, value);
    }
    // +30 for per-metadata-possible overhead, just to make sure that we
    // don't count too few.
    size += name.length() + value.length() + 30;
  }
  return size;
}
 
开发者ID:googlegsa,项目名称:sharepoint,代码行数:55,代码来源:SharePointAdaptor.java

示例11: getAspxDocContent

import com.google.enterprise.adaptor.Response; //导入方法依赖的package包/类
private void getAspxDocContent(Request request, Response response)
    throws IOException {
  log.entering("SiteAdaptor", "getAspxDocContent",
      new Object[] {request, response});

  CachedWeb w = rareModCache.getWeb(siteDataClient);
  if (isWebNoIndex(w)) {
    log.fine("Document marked for NoIndex");
    response.respondNotFound();
    log.exiting("SiteAdaptor", "getAspxDocContent");
    return;
  }

  String aspxId = request.getDocId().getUniqueId();
  String parentId = aspxId.substring(0, aspxId.lastIndexOf('/'));
  boolean isDirectChild = webUrl.equalsIgnoreCase(parentId);
  // Check for valid ASPX pages
  // Process only direct child for current web
  if (!isDirectChild) {
    // Alternative approach to this string comparison is to make a
    // additional web service call for SiteData.GetContentWeb and
    // check if ASPX page is available under Web.getFPFolder().getFiles()
    log.log(Level.FINE, "Document [{0}] is not a direct child of Web [{1}]",
        new Object[] {aspxId, webUrl});
    response.respondNotFound();
    log.exiting("SiteAdaptor", "getAspxDocContent");
    return;
  }

  boolean allowAnonymousAccess
      = isAllowAnonymousReadForWeb(w)
      // Check if anonymous access is denied by web application policy
      && (!isDenyAnonymousAccessOnVirtualServer());
  if (!allowAnonymousAccess) {
    response.setAcl(new Acl.Builder()
        .setInheritFrom(new DocId(parentId))
        .build());
  }
  response.addMetadata(METADATA_OBJECT_TYPE, "Aspx");      
  response.addMetadata(METADATA_PARENT_WEB_TITLE, w.webTitle);
  getFileDocContent(request, response, true);
  log.exiting("SiteAdaptor", "getAspxDocContent");
}
 
开发者ID:googlegsa,项目名称:sharepoint,代码行数:44,代码来源:SharePointAdaptor.java


注:本文中的com.google.enterprise.adaptor.Response.addMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。