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();
}
Aggregations