public static final ContentReference fromDeploymentName(String name, byte[] hash) { return fromDeploymentName(name, HashUtil.bytesToHexString(hash)); }
public static final ContentReference fromDeploymentName(String name, byte[] hash) { return fromDeploymentName(name, HashUtil.bytesToHexString(hash)); }
@Override public File getDeploymentRoot(byte[] deploymentHash) { String hex = deploymentHash == null ? "" : HashUtil.bytesToHexString(deploymentHash); final File file = localRepository.getDeploymentRoot(deploymentHash); if(! file.exists()) { return getFile(hex, DomainServerProtocol.PARAM_ROOT_ID_DEPLOYMENT); } return file; }
@Override public File getDeploymentRoot(byte[] deploymentHash) { String hex = deploymentHash == null ? "" : HashUtil.bytesToHexString(deploymentHash); final File file = localFileRepository.getDeploymentRoot(deploymentHash); if(! file.exists()) { return getFile(hex, DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT); } return file; }
@Override public File getDeploymentRoot(byte[] deploymentHash) { String hex = deploymentHash == null ? "" : HashUtil.bytesToHexString(deploymentHash); final File file = localRepository.getDeploymentRoot(deploymentHash); if(! file.exists()) { return getFile(hex, DomainServerProtocol.PARAM_ROOT_ID_DEPLOYMENT); } return file; }
protected void addFromHash(byte[] hash) throws OperationFailedException { if (!contentRepository.syncContent(hash)) { throw ServerMessages.MESSAGES.noSuchDeploymentContent(HashUtil.bytesToHexString(hash)); } }
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; } /**
protected void addFromHash(byte[] hash) throws OperationFailedException { if (!contentRepository.syncContent(hash)) { throw ServerMessages.MESSAGES.noSuchDeploymentContent(HashUtil.bytesToHexString(hash)); } }
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; } /**
DeploymentHandlerUtil.ContentItem addFromHash(byte[] hash, String deploymentName, OperationContext context) throws OperationFailedException { if (!contentRepository.syncContent(hash)) { if (context.isBooting()) { if (context.getRunningMode() == RunningMode.ADMIN_ONLY) { // The deployment content is missing, which would be a fatal boot error if we were going to actually // install services. In ADMIN-ONLY mode we allow it to give the admin a chance to correct the problem ServerLogger.DEPLOYMENT_LOGGER.reportAdminOnlyMissingDeploymentContent(HashUtil.bytesToHexString(hash), deploymentName); } else { throw ServerMessages.MESSAGES.noSuchDeploymentContentAtBoot(HashUtil.bytesToHexString(hash), deploymentName); } } else { throw ServerMessages.MESSAGES.noSuchDeploymentContent(HashUtil.bytesToHexString(hash)); } } return new DeploymentHandlerUtil.ContentItem(hash); }
DeploymentHandlerUtil.ContentItem addFromHash(byte[] hash) throws OperationFailedException { if (!contentRepository.syncContent(hash)) { throw ServerMessages.MESSAGES.noSuchDeploymentContent(HashUtil.bytesToHexString(hash)); } return new DeploymentHandlerUtil.ContentItem(hash); }
DeploymentHandlerUtil.ContentItem addFromHash(byte[] hash) throws OperationFailedException { if (!contentRepository.syncContent(hash)) { throw ServerMessages.MESSAGES.noSuchDeploymentContent(HashUtil.bytesToHexString(hash)); } return new DeploymentHandlerUtil.ContentItem(hash); }
@Override void removeContent(PathAddress address, Set<String> newHashes, List<byte[]> hashes) { for (byte[] hash : hashes) { try { if (contentRepository != null && (newHashes.isEmpty() || !newHashes.contains(HashUtil.bytesToHexString(hash)))) { contentRepository.removeContent(ModelContentReference.fromModelAddress(address, hash)); } else if(contentRepository != null) { ROOT_LOGGER.undeployingDeploymentHasBeenRedeployed(address.getLastElement().getValue()); } } catch (Exception e) { ROOT_LOGGER.debugf(e, "Exception occurred removing %s", Arrays.asList(hash)); } } }
@Override void removeContent(PathAddress address, Set<String> newHashes, List<byte[]> hashes) { for (byte[] hash : hashes) { try { if (contentRepository != null && (newHashes.isEmpty() || !newHashes.contains(HashUtil.bytesToHexString(hash)))) { contentRepository.removeContent(ModelContentReference.fromModelAddress(address, hash)); } else if(contentRepository != null) { ROOT_LOGGER.undeployingDeploymentHasBeenRedeployed(address.getLastElement().getValue()); } } catch (Exception e) { ROOT_LOGGER.debugf(e, "Exception occurred removing %s", Arrays.asList(hash)); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final byte[] oldHash = ManagedDMRContentResourceDefinition.HASH.validateOperation(operation).asBytes(); final byte[] currentHash = resource.getModel().get(ManagedDMRContentResourceDefinition.HASH.getName()).asBytes(); if (!Arrays.equals(oldHash, currentHash)) { throw ManagedDMRContentLogger.ROOT_LOGGER.invalidHash(HashUtil.bytesToHexString(oldHash), PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)), HashUtil.bytesToHexString(currentHash)); } ModelNode model = new ModelNode(); contentAttribute.validateAndSet(operation, model); // IMPORTANT: Use writeModel, as this is what causes the content to be flushed to the content repo! resource.writeModel(model); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final byte[] oldHash = ManagedDMRContentResourceDefinition.HASH.validateOperation(operation).asBytes(); final byte[] currentHash = resource.getModel().get(ManagedDMRContentResourceDefinition.HASH.getName()).asBytes(); if (!Arrays.equals(oldHash, currentHash)) { throw ManagedDMRContentLogger.ROOT_LOGGER.invalidHash(HashUtil.bytesToHexString(oldHash), PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)), HashUtil.bytesToHexString(currentHash)); } ModelNode model = new ModelNode(); contentAttribute.validateAndSet(operation, model); // IMPORTANT: Use writeModel, as this is what causes the content to be flushed to the content repo! resource.writeModel(model); } }
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(); } }
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(); } } }
@Override void removeContent(PathAddress address, Set<String> newHashes, List<byte[]> hashes) { for (byte[] hash : hashes) { try { if (contentRepository.hasContent(hash)) { contentRepository.removeContent(ModelContentReference.fromModelAddress(address, hash)); } else if (newHashes.isEmpty() || !newHashes.contains(HashUtil.bytesToHexString(hash))) { fileRepository.deleteDeployment(ModelContentReference.fromModelAddress(address, hash)); } else { ROOT_LOGGER.undeployingDeploymentHasBeenRedeployed(address.getLastElement().getValue()); } } catch (Exception e) { ROOT_LOGGER.debugf(e, "Exception occurred removing %s", Arrays.asList(hash)); } } } }