Package com.google.enterprise.connector.spi

Examples of com.google.enterprise.connector.spi.SimpleProperty


  private Document makeDocument(String lastModifiedString) {
    List valueList = new LinkedList();
    valueList.add(Value.getStringValue(lastModifiedString));
    Map propertyMap = new HashMap();
    propertyMap.put(SpiConstants.PROPNAME_LASTMODIFIED,
        new SimpleProperty(valueList));
    return new SimpleDocument(propertyMap);
  }
View Full Code Here


      if (aclGroups != null) {
        List<Value> values = new ArrayList<Value>(aclGroups.size());
        for (Principal group : aclGroups) {
          values.add(Value.getPrincipalValue(group));
        }
        return new SimpleProperty(values);
      } else {
        return null;
      }
    }
    return super.findProperty(name);
View Full Code Here

        List categoryList = new LinkedList();
        for (Iterator ci = entry.getCategories().iterator(); ci.hasNext(); ) {
          Category category = (Category) ci.next();
          categoryList.add( Value.getStringValue(category.getTerm()) );
        }
        map.put(PROPNAME_CATEGORY, new SimpleProperty(categoryList));
      }
     
      if (entry.getAuthors() != null) {
        List authorList = new LinkedList();
        for (Iterator ai = entry.getAuthors().iterator(); ai.hasNext(); ) {
          Person person = (Person) ai.next();
          authorList.add(Value.getStringValue(person.getName()) );
          if (person.getEmail() != null) {
            authorList.add(Value.getStringValue( person.getEmail()) );
          }
        }
        map.put(PROPNAME_AUTHOR, new SimpleProperty(authorList));
      }

      return new SimpleDocument(map);
    }
View Full Code Here

    /** Make a SimpleProperty with one value using the given string. */
    public static Property makeProperty(String str) {
      List strList = new LinkedList();
      strList.add(Value.getStringValue(str));
      return new SimpleProperty(strList);
    }
View Full Code Here

      } catch (IOException ioe) {
        throw new RepositoryException(ioe);
      }
      List list = new LinkedList();
      list.add(Value.getBinaryValue(stream.toByteArray()));
      return new SimpleProperty(list);
    }
View Full Code Here

     * Make a SimpleProperty with one value using the given byte array directly.
     */
    public static Property makeProperty(byte [] bytes) {
      List list = new LinkedList();
      list.add(Value.getBinaryValue(bytes));
      return new SimpleProperty(list);
    }
View Full Code Here

        synchronized (this) {
          if (content == null || content.isConsumed()) {
            content = downloadContents();
          }
          InputStream contentStream = content.getContentStream();
          return (contentStream == null) ? null : new SimpleProperty(
              Value.getBinaryValue(contentStream));
        }
      }
    } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_MIMETYPE)) {
      if (FeedType.CONTENT_FEED == getFeedType()
          && ActionType.ADD.equals(getAction())) {
        synchronized (this) {
          if (content == null || content.getContentType() == null) {
            content = downloadContents();
          }
          String contentType = content.getContentType();
          return (contentType == null) ? null : new SimpleProperty(
              Value.getStringValue(contentType));
        }
      }
    } else if (collator.equals(strPropertyName,
        SPConstants.HTTP_STATUS_CODE)) {
      if (FeedType.CONTENT_FEED == getFeedType()) {
        synchronized (this) {
          if (content == null) {
            content = downloadContents();
          }
          if (content.getStatusCode() != 0) {
            return new SimpleProperty(Value.getLongValue(
                content.getStatusCode()));
          } else {
            return null;
          }
        }
      }
    } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_SEARCHURL)) {
      if (FeedType.CONTENT_FEED != getFeedType()) {
        // TODO Handle ACL feed here.
        return new SimpleProperty(Value.getStringValue(getUrl()));
      }
    } else if (collator.equals(strPropertyName,
            SpiConstants.PROPNAME_ACLINHERITANCETYPE)) {
      if (!isWebAppPolicyDoc() && parentUrl == null) {
        // Returning null as ACL information is not complete.
        // Every Inherited ACL should have parentUrl other than
        // web application policy document.
        return null;
      }
      return new SimpleProperty(Value.getStringValue(
              SpiConstants.AclInheritanceType.PARENT_OVERRIDES.toString()));
    } else if (collator.equals(strPropertyName,
            SpiConstants.PROPNAME_ACLINHERITFROM_DOCID)) {
      String parentUrlToSend = getParentUrl();
      if (parentUrlToSend == null) {
        return null;
      }
      if (getFeedType() == FeedType.CONTENT_FEED) {
        parentUrlToSend = parentUrlToSend + "|" + getParentId().toUpperCase();
      }
      return new SimpleProperty(Value.getStringValue(parentUrlToSend));
    } else if (collator.equals(strPropertyName,
        SpiConstants.PROPNAME_ACLINHERITFROM)) {
      String parentUrlToSend = getParentUrl();
      if (FeedType.CONTENT_FEED == getFeedType()) {
        return null;
      }
      return new SimpleProperty(Value.getStringValue(parentUrlToSend));
    } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_FEEDTYPE)) {
      return new SimpleProperty(Value.getStringValue(feedType.toString()));
    } else if (collator.equals(strPropertyName,
        SpiConstants.PROPNAME_ACLINHERITFROM_FEEDTYPE)) {
      return new SimpleProperty(Value.getStringValue(feedType.toString()));
    } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_DISPLAYURL)) {
      return new SimpleProperty(Value.getStringValue(displayUrl));
    } else if (collator.equals(strPropertyName, SPConstants.PARENT_WEB_TITLE)) {
      return new SimpleProperty(Value.getStringValue(getParentWebTitle()));
    } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_DOCID)) {
      return new SimpleProperty(Value.getStringValue(getDocId()));
    } else if (collator.equals(strPropertyName, SpiConstants.PROPNAME_LASTMODIFIED)) {
      return new SimpleProperty(Value.getDateValue(getLastMod()));
    } else if (collator.equals(strPropertyName, SPConstants.LIST_GUID)) {
      if (null != getParentList()) {
        return new SimpleProperty(Value.getStringValue(
            getParentList().getPrimaryKey()));
      }
    } else if (collator.equals(strPropertyName, SPConstants.SPAUTHOR)) {
      return new SimpleProperty(Value.getStringValue(getAuthor()));
    } else if (strPropertyName.equals(SPConstants.OBJECT_TYPE)) {
      return new SimpleProperty(Value.getStringValue(getObjType()));
    } else if (strPropertyName.equals(SpiConstants.PROPNAME_ISPUBLIC)) {
      return new SimpleProperty(Value.getBooleanValue(publicDocument));
    } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACTION)) {
      return new SimpleProperty(Value.getStringValue(getAction().toString()));
    } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLDENYUSERS)) {
      return getPrincipalProperty(aclDenyUsers);
    } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLDENYGROUPS)) {
      return getPrincipalProperty(aclDenyGroups);
    } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLUSERS)) {
      return getPrincipalProperty(aclUsers);
    } else if (strPropertyName.equals(SpiConstants.PROPNAME_ACLGROUPS)) {
      return getPrincipalProperty(aclGroups);
    } else if (strPropertyName.startsWith(SpiConstants.PROPNAME_TITLE)) {
      return new SimpleProperty(Value.getStringValue(title));
    } else if (strPropertyName.equals(SpiConstants.PROPNAME_DOCUMENTTYPE)) {
      if (documentType != null) {
        return new SimpleProperty(
            Value.getStringValue(documentType.toString()));
      } else {
        return null;
      }
    } else {
      // FIXME: We can get rid of this if-else-if ladder here by setting all
      // the relevant properties (in appropriate type) right at the time of
      // document creation. After doing that, all that will be required is to
      // maintain a map of all the properties with key as the prop name. This
      // will also eliminate maintaining multiple member attributes in this
      // class. All the attribute will be there in a common map.
      for (final Iterator<Attribute> iter = getAllAttrs().iterator(); iter.hasNext();) {
        final Attribute attr = iter.next();
        if (collator.equals(strPropertyName, attr.getName())) {
          String strAttrValue = attr.getValue().toString();
          // Current approach is to parse field values for ;# characters.
          // TODO Utilize SharePoint Field meta-data and process values
          // for only columns with SharePoint Field type as
          // "LookupMulti" or "MultiChoice"
          List<Value> valuesToPass;
          if (null != strAttrValue) {
            List<String> values =  Util.processMultiValueMetadata(strAttrValue);
            valuesToPass = new ArrayList<Value>();
            for (String str : values) {
              valuesToPass.add(Value.getStringValue(str));
            }
          } else {
            valuesToPass = null;         
          }
          return new SimpleProperty(valuesToPass);
        }
      }
    }

    LOGGER.finer("no matches found for[" + strPropertyName + "]");
View Full Code Here

    if (aclPrincipals != null) {
      List<Value> values = new ArrayList<Value>(aclPrincipals.size());
      for (Principal user : aclPrincipals) {
        values.add(Value.getPrincipalValue(user));
      }
      return new SimpleProperty(values);
    } else {
      return null;
    }
  }
View Full Code Here

  public Property findProperty(String name) throws RepositoryException {
    // Delay fetching Content and MimeType until they are actually requested.
    // Retriever might not fetch content in the case of IfModifiedSince.
    if (SpiConstants.PROPNAME_CONTENT.equals(name)) {
      try {
        return new SimpleProperty(Value.getBinaryValue(file.getInputStream()));
      } catch (IOException e) {
        throw new RepositoryDocumentException(
            "Failed to open " + file.getPath(), e);
      }
    } else if (SpiConstants.PROPNAME_MIMETYPE.equals(name) &&
               properties.get(name) == null) {
      fetchMimeType(file);
    }
    List<Value> values = properties.get(name);
    return (values == null) ? null : new SimpleProperty(values);
  }
View Full Code Here

  public Property findProperty(String name) throws RepositoryException {
    List<Value> property = properties.get(name);
    if (name.equals(SpiConstants.PROPNAME_CONTENT) && filterMimeType()) {
        property = null;
    }
    return (property == null) ? null : new SimpleProperty(property);
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.spi.SimpleProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.