Object fromModelNode(final ModelNode node) { // The only use of this is BYTES_NO_EXPR so skip resolution. // If that changes, use ExpressionResolver.SIMPLER I guess //return node.resolve().asBytes(); return node.asBytes(); }
/** * {@inheritDoc} */ @Override protected InputStream getContentInputStream(OperationContext operationContext, ModelNode operation) throws OperationFailedException { byte[] bytes = operation.get(BYTES).asBytes(); return new ByteArrayInputStream(bytes); }
/** * {@inheritDoc} */ @Override protected InputStream getContentInputStream(OperationContext operationContext, ModelNode operation) throws OperationFailedException { byte[] bytes = attribute.resolveModelAttribute(operationContext, operation).asBytes(); return new ByteArrayInputStream(bytes); }
/** * {@inheritDoc} */ @Override protected InputStream getContentInputStream(OperationContext operationContext, ModelNode operation) throws OperationFailedException { byte[] bytes = attribute.resolveModelAttribute(operationContext, operation).asBytes(); return new ByteArrayInputStream(bytes); }
/** * {@inheritDoc} */ @Override protected InputStream getContentInputStream(OperationContext operationContext, ModelNode operation) throws OperationFailedException { byte[] bytes = attribute.resolveModelAttribute(operationContext, operation).asBytes(); return new ByteArrayInputStream(bytes); }
/** * {@inheritDoc} */ @Override protected InputStream getContentInputStream(OperationContext operationContext, ModelNode operation) throws OperationFailedException { byte[] bytes = attribute.resolveModelAttribute(operationContext, operation).asBytes(); return new ByteArrayInputStream(bytes); }
public static List<byte[]> getDeploymentHash(ModelNode deployment){ List<byte[]> hashes = new ArrayList<byte[]>(); if (deployment.hasDefined(CONTENT)) { for (ModelNode contentElement : deployment.get(CONTENT).asList()) { if (contentElement.hasDefined(HASH)) { final byte[] hash = contentElement.get(HASH).asBytes(); hashes.add(hash); } } } return hashes; }
public static List<byte[]> getDeploymentHash(ModelNode deployment){ List<byte[]> hashes = new ArrayList<byte[]>(); if (deployment.hasDefined(CONTENT)) { for (ModelNode contentElement : deployment.get(CONTENT).asList()) { if (contentElement.hasDefined(HASH)) { final byte[] hash = contentElement.get(HASH).asBytes(); hashes.add(hash); } } } return hashes; }
public static List<byte[]> getDeploymentHash(ModelNode deployment){ List<byte[]> hashes = new ArrayList<byte[]>(); if (deployment.hasDefined(CONTENT)) { for (ModelNode contentElement : deployment.get(CONTENT).asList()) { if (contentElement.hasDefined(HASH)) { final byte[] hash = contentElement.get(HASH).asBytes(); hashes.add(hash); } } } return hashes; }
public static List<byte[]> getDeploymentHash(ModelNode deployment){ List<byte[]> hashes = new ArrayList<byte[]>(); if (deployment.hasDefined(CONTENT)) { for (ModelNode contentElement : deployment.get(CONTENT).asList()) { if (contentElement.hasDefined(HASH)) { final byte[] hash = contentElement.get(HASH).asBytes(); hashes.add(hash); } } } return hashes; }
@Override public void writeModel(ModelNode newModel) { // ApplyRemoteMasterDomainModelHandler is writing us byte[] initialHash = newModel.hasDefined(ModelDescriptionConstants.HASH) ? newModel.get(ModelDescriptionConstants.HASH).asBytes() : null; if (initialHash != null) { loadContent(initialHash); } }
@Override public byte[] addDeploymentContent(InputStream stream) { ModelNode op = new ModelNode(); op.get("operation").set("upload-deployment-stream"); op.get("input-stream-index").set(0); Operation operation = new OperationBuilder(op).addInputStream(stream).build(); ModelNode result = executeForResult(operation); return result.asBytes(); }
public static Set<String> getDeploymentHexHash(ModelNode deployment){ Set<String> hashes = new HashSet<String>(); if (deployment.hasDefined(CONTENT)) { for (ModelNode contentElement : deployment.get(CONTENT).asList()) { if (contentElement.hasDefined(HASH)) { hashes.add(HashUtil.bytesToHexString(contentElement.get(HASH).asBytes())); } } } return hashes; } /**
@SuppressWarnings("unchecked") private T convertToBaseType(ModelNode dmr) { if (getType() == String.class) return (T) dmr.asString(); if (getType() == Long.class) return (T) Long.valueOf(dmr.asLong()); if (getType() == Integer.class) return (T) Integer.valueOf(dmr.asInt()); if (getType() == Boolean.class) return (T) Boolean.valueOf(dmr.asBoolean()); if (getType() == Double.class) return (T) Double.valueOf(dmr.asDouble()); if (getType() == BigDecimal.class) return (T) BigDecimal.valueOf(dmr.asDouble()); if (getType() == byte[].class) return (T) dmr.asBytes(); throw new IllegalArgumentException("Can not convert. This node is not of a base type. Actual type is " + type.getName()); }
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String path = address.getLastElement().getValue(); final String name = address.getElement(address.size() - 2).getValue(); final byte[] content = model.get(ModelDescriptionConstants.CONTENT).asBytes(); installServices(context, verificationHandler, newControllers, name, path, content); }
@Override protected void recoverServices(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String path = address.getLastElement().getValue(); final String name = address.getElement(address.size() - 2).getValue(); final byte[] content = model.get(ModelDescriptionConstants.CONTENT).asBytes(); ContentAdd.installServices(context, null, null, name, path, content); } }
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String path = address.getLastElement().getValue(); final String name = address.getElement(address.size() - 2).getValue(); final byte[] content = model.get(ModelDescriptionConstants.CONTENT).asBytes(); installServices(context, verificationHandler, newControllers, name, path, content); }
@Override protected void recoverServices(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String path = address.getLastElement().getValue(); final String name = address.getElement(address.size() - 2).getValue(); final byte[] content = model.get(ModelDescriptionConstants.CONTENT).asBytes(); ContentAdd.installServices(context, null, null, name, path, content); } }
private void writeManagementClientContent(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException { boolean hasRolloutPlans = modelNode.hasDefined(ROLLOUT_PLANS) && modelNode.get(ROLLOUT_PLANS).hasDefined(HASH); boolean mustWrite = hasRolloutPlans; // || other elements we may add later if (mustWrite) { writer.writeStartElement(Element.MANAGEMENT_CLIENT_CONTENT.getLocalName()); if (hasRolloutPlans) { writer.writeEmptyElement(Element.ROLLOUT_PLANS.getLocalName()); writer.writeAttribute(Attribute.SHA1.getLocalName(), HashUtil.bytesToHexString(modelNode.get(ROLLOUT_PLANS).get(HASH).asBytes())); } writer.writeEndElement(); } }
private void writeManagementClientContent(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException { boolean hasRolloutPlans = modelNode.hasDefined(ROLLOUT_PLANS) && modelNode.get(ROLLOUT_PLANS).hasDefined(HASH); boolean mustWrite = hasRolloutPlans; // || other elements we may add later if (mustWrite) { writer.writeStartElement(Element.MANAGEMENT_CLIENT_CONTENT.getLocalName()); if (hasRolloutPlans) { writer.writeEmptyElement(Element.ROLLOUT_PLANS.getLocalName()); writer.writeAttribute(Attribute.SHA1.getLocalName(), HashUtil.bytesToHexString(modelNode.get(ROLLOUT_PLANS).get(HASH).asBytes())); } writer.writeEndElement(); } }