Search in sources :

Example 1 with NodeBinaryReferenceException

use of com.enonic.xp.node.NodeBinaryReferenceException in project xp by enonic.

the class CreateNodeCommand method storeAndAttachBinaries.

private AttachedBinaries storeAndAttachBinaries() {
    final PropertyTree data = params.getData();
    final AttachedBinaries.Builder builder = AttachedBinaries.create();
    final ImmutableList<Property> binaryReferences = data.getProperties(ValueTypes.BINARY_REFERENCE);
    for (final Property binaryRef : binaryReferences) {
        final BinaryAttachment binaryAttachment = this.params.getBinaryAttachments().get(binaryRef.getBinaryReference());
        if (binaryAttachment == null) {
            throw new NodeBinaryReferenceException("No binary with reference " + binaryRef + " attached in createNodeParams");
        }
        final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
        final AttachedBinary attachedBinary = this.binaryService.store(repositoryId, binaryAttachment);
        builder.add(attachedBinary);
    }
    return builder.build();
}
Also used : NodeBinaryReferenceException(com.enonic.xp.node.NodeBinaryReferenceException) PropertyTree(com.enonic.xp.data.PropertyTree) AttachedBinaries(com.enonic.xp.node.AttachedBinaries) Property(com.enonic.xp.data.Property) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) RepositoryId(com.enonic.xp.repository.RepositoryId) AttachedBinary(com.enonic.xp.node.AttachedBinary)

Aggregations

Property (com.enonic.xp.data.Property)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 AttachedBinaries (com.enonic.xp.node.AttachedBinaries)1 AttachedBinary (com.enonic.xp.node.AttachedBinary)1 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)1 NodeBinaryReferenceException (com.enonic.xp.node.NodeBinaryReferenceException)1 RepositoryId (com.enonic.xp.repository.RepositoryId)1