/** * Builds the references of the PublicPlans of a CSAR and a plan type defined due the constructor. * * @param uriInfo * @return Response */ @GET @Produces(ResourceConstants.LINKED_XML) public Response getReferences(@Context UriInfo uriInfo) { if (this.csarID == null) { return Response.status(404).build(); } CSARPublicPlansResource.LOG.debug( "Return available management plans for CSAR {} and type {} .", this.csarID, this.publicPlanType); References refs = new References(); PublicPlanTypes type = PublicPlanTypes.isPlanTypeEnumRepresentation(this.publicPlanType); LinkedHashMap<Integer, PublicPlan> linkedMapOfPublicPlans = ToscaServiceHandler.getToscaEngineService() .getToscaReferenceMapper() .getCSARIDToPublicPlans(this.csarID) .get(type); CSARPublicPlansResource.LOG.debug( "Getting the list of PublicPlan of the type \"" + type + "\" for CSAR \"" + this.csarID.getFileName() + "\"."); for (Integer itr : linkedMapOfPublicPlans.keySet()) { PublicPlan plan = linkedMapOfPublicPlans.get(itr); refs.getReference() .add( new Reference( Utilities.buildURI(uriInfo.getAbsolutePath().toString(), Integer.toString(itr)), XLinkConstants.SIMPLE, plan.getPlanID().toString())); } CSARPublicPlansResource.LOG.info( "Number of References in Root: {}", refs.getReference().size()); // selflink refs.getReference() .add( new Reference( uriInfo.getAbsolutePath().toString(), XLinkConstants.SIMPLE, XLinkConstants.SELF)); return Response.ok(refs.getXMLString()).build(); }
@Override public String execute() { // set all the needed informations PublicPlan publicPlan = new PublicPlan(); publicPlan.setCSARID(this.csarID); publicPlan.setPlanType(this.planType); publicPlan.setInternalPlanID(this.internalID); publicPlan.setPlanID( new QName( planID.substring(1, planID.indexOf("}")), planID.substring(planID.indexOf("}") + 1, planID.length()))); // split the parameters, they are stored inside one String due the AJAX // call for (String str : this.parameters.split("\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$!")) { Parameter param = new Parameter(); String[] str2 = str.split("\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$\\$"); param.setName(str2[0]); param.setValue(str2[1]); publicPlan.getInputParameter().add(param); } System.out.println("invoke build plan " + publicPlan.getPlanID().toString()); // PUT ContainerClient client = ContainerClient.getInstance(); List<String> result = client.putPublicPlanBUILDInvocation(publicPlan); for (String str : result) { System.out.println(str); } return result.get(0); }