/** * @return an instance of the requested resource * @throws NotFoundException if resource doesn't exist. */ public static AbstractComponentInstanceResource getComponentInstanceResource(DefinitionsChildId tcId) { String type = Util.getTypeForComponentId(tcId.getClass()); if (!RepositoryFactory.getRepository().exists(tcId)) { AbstractComponentsResource.LOGGER.debug("Definition child id " + tcId.toString() + " not found"); throw new NotFoundException("Definition child id " + tcId.toString() + " not found"); } Class<? extends AbstractComponentInstanceResource> newResource = AbstractComponentsResource.getComponentInstanceResourceClassForType(type); Constructor<?>[] constructors = newResource.getConstructors(); assert (constructors.length == 1); AbstractComponentInstanceResource newInstance; try { newInstance = (AbstractComponentInstanceResource) constructors[0].newInstance(tcId); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { AbstractComponentsResource.LOGGER.error("Could not instantiate sub resource " + tcId); throw new IllegalStateException("Could not instantiate sub resource", e); } return newInstance; }
/** * @param oldId the old id * @param newId the new id */ @Override public void rename(DefinitionsChildId oldId, DefinitionsChildId newId) throws IOException { String pathFragment = IdUtil.getURLPathFragment(oldId); NamespaceAndIdAsString namespaceAndIdAsString = new NamespaceAndIdAsString(); namespaceAndIdAsString.namespace = newId.getNamespace().getDecoded(); namespaceAndIdAsString.id = newId.getXmlId().getDecoded(); for (WebResource wr: this.repositoryResources) { // TODO: Check whether namespaceAndIdAsString is the correct data type expected at the resource ClientResponse response = wr.path(pathFragment).path("id").post(ClientResponse.class, namespaceAndIdAsString); if ((response.getClientResponseStatus() != ClientResponse.Status.NO_CONTENT) || (response.getClientResponseStatus() != ClientResponse.Status.NOT_FOUND)) { LOGGER.debug(String.format("Error %d when renaming DefinitionsChildId %s to %s at %s", response.getStatus(), oldId.toString(), newId.toString(), wr.getURI().toString())); } } }
CsarExporter.LOGGER.trace("Starting CSAR export with {}", entryId.toString());