private void createRootFolder() {
   FolderImpl rootFolder = new FolderImpl();
   rootFolder.setName("RootFolder");
   rootFolder.setParentId(null);
   rootFolder.setTypeId(BaseTypeId.CMIS_FOLDER.value());
   rootFolder.setCreatedBy("Admin");
   rootFolder.setModifiedBy("Admin");
   rootFolder.setModifiedAtNow();
   rootFolder.setRepositoryId(fRepositoryId);
   rootFolder.setAclId(addAcl(InMemoryAcl.getDefaultAcl()));
   String id = storeObject(rootFolder);
   rootFolder.setId(id);
   fRootFolder = rootFolder;
 }
  private String[] createLevel1Folders() {
    final int num = 2;
    String[] res = new String[num];

    for (int i = 0; i < num; i++) {
      List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
      properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, "Folder " + i));
      properties.add(
          fFactory.createPropertyIdData(
              PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_FOLDER.value()));
      Properties props = fFactory.createPropertiesData(properties);
      String id = fObjSvc.createFolder(fRepositoryId, props, fRootFolderId, null, null, null, null);
      res[i] = id;
    }
    return res;
  }
  private Properties compileProperties(
      Record record, Set<String> orgfilter, ObjectInfoImpl objectInfo) {
    if (record == null) {
      throw new IllegalArgumentException("File must not be null!");
    }

    Set<String> filter = (orgfilter == null ? null : new HashSet<String>(orgfilter));
    String typeId = record.getSchemaCode();
    setupObjectInfo(objectInfo, typeId);

    try {
      PropertiesImpl result = new PropertiesImpl();

      String id = record.getId();
      addPropertyId(result, typeId, filter, PropertyIds.OBJECT_ID, id);
      objectInfo.setId(id);

      String name = record.get(Schemas.TITLE);
      addPropertyString(result, typeId, filter, PropertyIds.NAME, name);
      objectInfo.setName(name);

      addPropertyString(
          result, typeId, filter, PropertyIds.CREATED_BY, (String) record.get(Schemas.CREATED_BY));
      addPropertyString(
          result,
          typeId,
          filter,
          PropertyIds.LAST_MODIFIED_BY,
          (String) record.get(Schemas.MODIFIED_BY));
      objectInfo.setCreatedBy(USER_UNKNOWN);

      GregorianCalendar creationDate = getGregorianCalendar(record.get(Schemas.CREATED_ON));
      GregorianCalendar lastModified = getGregorianCalendar(record.get(Schemas.MODIFIED_ON));
      addPropertyDateTime(result, typeId, filter, PropertyIds.CREATION_DATE, creationDate);
      addPropertyDateTime(result, typeId, filter, PropertyIds.LAST_MODIFICATION_DATE, lastModified);
      objectInfo.setCreationDate(creationDate);
      objectInfo.setLastModificationDate(lastModified);

      addPropertyString(
          result, typeId, filter, PropertyIds.CHANGE_TOKEN, Long.toString(record.getVersion()));

      addPropertyId(
          result, typeId, filter, PropertyIds.BASE_TYPE_ID, BaseTypeId.CMIS_FOLDER.value());
      addPropertyId(result, typeId, filter, PropertyIds.OBJECT_TYPE_ID, typeId);

      // The principal path is always used for now
      String path = record.get(Schemas.PRINCIPAL_PATH);
      if ("collection_default".equals(typeId)) {
        addPropertyString(result, typeId, filter, PropertyIds.PATH, "/");
      } else {
        addPropertyString(result, typeId, filter, PropertyIds.PATH, path);
      }

      if (record.getParentId() != null) {
        addPropertyString(result, typeId, filter, PropertyIds.PARENT_ID, record.getParentId());
      } else if (path != null) {
        // The principal path is used here, also.
        addPropertyString(
            result,
            typeId,
            filter,
            PropertyIds.PARENT_ID,
            path.split("/")[path.split("/").length - 2]);
      }
      addPropertiesForMetadatas(record, orgfilter, typeId, result);

      addPropertyIdList(result, typeId, filter, PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, null);

      return result;
    } catch (CmisBaseException cbe) {
      throw cbe;
    } catch (Exception e) {
      throw new CmisExceptions_Runtime(e.getMessage(), e);
    }
  }
  private Boolean isAllowableBaseType(
      String key, String baseType, Content content, String repositoryId) {
    // NavigationServices
    if (PermissionMapping.CAN_GET_DESCENDENTS_FOLDER.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    if (PermissionMapping.CAN_GET_CHILDREN_FOLDER.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    if (PermissionMapping.CAN_GET_FOLDER_PARENT_OBJECT.equals(key))
      if (contentService.isRoot(repositoryId, content)) {
        return false;
      } else {
        return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
      }
    if (PermissionMapping.CAN_GET_PARENTS_FOLDER.equals(key))
      if (contentService.isRoot(repositoryId, content)) {
        return false;
      } else {
        return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
            || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
            || BaseTypeId.CMIS_POLICY.value().equals(baseType)
            || BaseTypeId.CMIS_ITEM.value().equals(baseType));
      }

    // Object Services
    if (PermissionMapping.CAN_CREATE_DOCUMENT_FOLDER.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    if (PermissionMapping.CAN_CREATE_FOLDER_FOLDER.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    if (PermissionMapping.CAN_CREATE_POLICY_FOLDER.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    if (PermissionMapping.CAN_CREATE_RELATIONSHIP_SOURCE.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.equals(baseType));
    if (PermissionMapping.CAN_CREATE_RELATIONSHIP_TARGET.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_GET_PROPERTIES_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_MOVE_OBJECT.equals(key))
      if (contentService.isRoot(repositoryId, content)) {
        return false;
      } else {
        return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
            || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
            || BaseTypeId.CMIS_POLICY.value().equals(baseType)
            || BaseTypeId.CMIS_ITEM.value().equals(baseType));
      }
    if (PermissionMapping.CAN_MOVE_TARGET.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    if (PermissionMapping.CAN_MOVE_SOURCE.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    if (PermissionMapping.CAN_DELETE_OBJECT.equals(key))
      if (contentService.isRoot(repositoryId, content)) {
        return false;
      } else {
        return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
            || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
            || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
            || BaseTypeId.CMIS_POLICY.value().equals(baseType)
            || BaseTypeId.CMIS_ITEM.value().equals(baseType));
      }
    if (PermissionMapping.CAN_VIEW_CONTENT_OBJECT.equals(key))
      return BaseTypeId.CMIS_DOCUMENT.value().equals(baseType);
    if (PermissionMapping.CAN_SET_CONTENT_DOCUMENT.equals(key))
      return BaseTypeId.CMIS_DOCUMENT.value().equals(baseType);
    if (PermissionMapping.CAN_DELETE_CONTENT_DOCUMENT.equals(key))
      return BaseTypeId.CMIS_DOCUMENT.value().equals(baseType);
    if (PermissionMapping.CAN_DELETE_TREE_FOLDER.equals(key))
      return BaseTypeId.CMIS_FOLDER.value().equals(baseType);
    // Filing Services
    if (PermissionMapping.CAN_ADD_TO_FOLDER_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_ADD_TO_FOLDER_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_REMOVE_FROM_FOLDER_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_REMOVE_FROM_FOLDER_FOLDER.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType));
    // Versioning Services
    if (PermissionMapping.CAN_CHECKOUT_DOCUMENT.equals(key))
      return BaseTypeId.CMIS_DOCUMENT.value().equals(baseType);
    if (PermissionMapping.CAN_CANCEL_CHECKOUT_DOCUMENT.equals(key))
      return BaseTypeId.CMIS_DOCUMENT.value().equals(baseType);
    if (PermissionMapping.CAN_CHECKIN_DOCUMENT.equals(key))
      return BaseTypeId.CMIS_DOCUMENT.value().equals(baseType);
    if (PermissionMapping.CAN_GET_ALL_VERSIONS_VERSION_SERIES.equals(key))
      return BaseTypeId.CMIS_DOCUMENT.value().equals(baseType);
    // Relationship Services
    if (PermissionMapping.CAN_GET_OBJECT_RELATIONSHIPS_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    // Policy Services
    if (PermissionMapping.CAN_ADD_POLICY_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_ADD_POLICY_POLICY.equals(key))
      return BaseTypeId.CMIS_POLICY.value().equals(baseType);
    if (PermissionMapping.CAN_REMOVE_POLICY_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_REMOVE_POLICY_POLICY.equals(key))
      return BaseTypeId.CMIS_POLICY.value().equals(baseType);
    if (PermissionMapping.CAN_GET_APPLIED_POLICIES_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    // ACL Services
    if (PermissionMapping.CAN_GET_ACL_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));
    if (PermissionMapping.CAN_APPLY_ACL_OBJECT.equals(key))
      return (BaseTypeId.CMIS_DOCUMENT.value().equals(baseType)
          || BaseTypeId.CMIS_FOLDER.value().equals(baseType)
          || BaseTypeId.CMIS_RELATIONSHIP.value().equals(baseType)
          || BaseTypeId.CMIS_POLICY.value().equals(baseType)
          || BaseTypeId.CMIS_ITEM.value().equals(baseType));

    return false;
  }