/** * Servico responsavel por obter os dados referentes artifact Classification de um ativo de * software armezenado no repositorio. Consome um XML padronizado (Command) contendo o caminho * absoluto do repositorio que se deseja utilizar em conjunto com o nome do ativo que se busca. * * @param command * @return */ @POST @Path("/getClassification") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) public Response getClassification(Command command) throws IOException { Hidra hidra; Classification classification = new Classification(); String assetName = command.getAssetName(); String path = command.getRepositoryPath(); ResultMessage result = new ResultMessage(); if (path.isEmpty() || assetName.isEmpty()) { throw new DataNotFoundException( "The absolute path of the repository Or Asset Name has not been set"); } if (!new File(path).exists()) { throw new IOException("Could not find the informed repository"); } hidra = new Hidra(path); ClassificationType classificationType = hidra.describeClassification(assetName); if (classificationType != null) { List<Context> contexts = classificationType.getContexts(); List<DescriptionGroup> descriptionGroups = classificationType.getDescriptionGroups(); for (Context context : contexts) { Contexts cont = new Contexts(context.getName(), context.getId(), context.getDescription()); for (DescriptionGroup description : context.getDescriptionGroup()) { cont.getDescriptionGroup() .add( new DescriptionGroups( description.getName(), description.getReference(), description.getDescription())); } classification.getContext().add(cont); } for (DescriptionGroup description : descriptionGroups) { classification .getDescriptionGroup() .add( new DescriptionGroups( description.getName(), description.getReference(), description.getDescription())); } return Response.status(Status.OK).entity(classification).build(); } throw new DataNotFoundException("Could not return to the Asset Classification "); }