@Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); resourceRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); resourceRegistration.registerOperationHandler(MigrateJsonOperation.DEFINITION, new MigrateJsonOperation()); }
private String readConfig(ModelNode operation) throws IOException { ModelNode file = operation.get(FILE_ATTRIBUTE.getName()); if (file.isDefined() && file.asBytes().length > 0) { return new String(file.asBytes()); } String localConfig = localConfig(); if (localConfig != null) return localConfig; throw new IOException("Can not find json file to migrate"); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { List<ModelNode> ops = null; try { PathAddress currentAddr = context.getCurrentAddress(); ops = JsonConfigConverter.convertJsonConfig(readConfig(operation), currentAddr); } catch (IOException ioe) { throw new OperationFailedException(ioe); } for (ModelNode op : ops) { PathAddress addr = PathAddress.pathAddress(op.get(ADDRESS)); String opName = op.get(OP).asString(); context.addStep(op, context.getRootResourceRegistration().getOperationHandler(addr, opName), OperationContext.Stage.MODEL); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); }