Beispiel #1
0
  protected Node createNode(final NodePath parentPath, final String name) {
    final PropertyTree data = new PropertyTree();
    data.setString("displayName", "This is brand new node");
    final PropertySet someData = data.addSet("someData");
    someData.setString("cars", "skoda");
    someData.addString("cars", "tesla model x");
    someData.setString("likes", "plywood");
    someData.setLong("numberOfUselessGadgets", 123L);

    final PatternIndexConfigDocument indexConfig =
        PatternIndexConfigDocument.create()
            .defaultConfig(IndexConfig.MINIMAL)
            .add("displayName", IndexConfig.FULLTEXT)
            .build();

    return Node.create()
        .id(NodeId.from("nodeId"))
        .parentPath(parentPath)
        .name(name)
        .data(data)
        .indexConfigDocument(indexConfig)
        .permissions(
            AccessControlList.create()
                .add(
                    AccessControlEntry.create()
                        .principal(PrincipalKey.ofRole("admin"))
                        .allowAll()
                        .build())
                .build())
        .nodeState(NodeState.DEFAULT)
        .nodeVersionId(NodeVersionId.from("versionKey"))
        .timestamp(Instant.parse("2010-10-10T10:10:10.10Z"))
        .build();
  }
Beispiel #2
0
  protected Content(final Builder builder) {
    Preconditions.checkNotNull(builder.name, "name is required for a Content");
    Preconditions.checkNotNull(builder.parentPath, "parentPath is required for a Content");
    Preconditions.checkNotNull(builder.data, "data is required for a Content");

    if (builder.page != null) {
      Preconditions.checkArgument(
          !(builder.page.getController() != null && builder.page.getTemplate() != null),
          "A Page cannot have both have a controller and a template set");
    }

    if (builder.type == null) {
      builder.type = ContentTypeName.unstructured();
    }

    this.valid = builder.valid;
    this.displayName = builder.displayName;
    this.type = builder.type;
    this.name = builder.name;
    this.parentPath = builder.parentPath;
    this.path = ContentPath.from(builder.parentPath, builder.name.toString());
    this.id = builder.id;
    this.data = builder.data;
    this.attachments = builder.attachments;
    this.extraDatas = builder.extraDatas;
    this.createdTime = builder.createdTime;
    this.modifiedTime = builder.modifiedTime;
    this.creator = builder.creator;
    this.modifier = builder.modifier;
    this.owner = builder.owner;
    this.page = builder.page;
    this.thumbnail = builder.thumbnail;
    this.hasChildren = builder.hasChildren;
    this.childOrder = builder.childOrder;
    this.permissions =
        builder.permissions == null ? AccessControlList.empty() : builder.permissions;
    this.inheritPermissions = builder.inheritPermissions;
    this.language = builder.language;
    this.contentState = builder.contentState == null ? ContentState.DEFAULT : builder.contentState;
  }