@GET @Path("source/zip") @Produces(MimeTypes.MIMETYPE_ZIP) public Response getSourceDefinitionsAsResponse() { return RestUtils.getZippedContents(this.sourceDirectoryId, this.sourceDirectoryId.getParent().getXmlId().getEncoded() + "-source.zip"); }
public static Response getYamlCSARofSelectedResource(final AbstractComponentInstanceResource resource) { final Converter converter = new Converter(); StreamingOutput so = output -> { try { InputStream is = converter.convertX2Y(resource.getId()); byte[] buffer = new byte[1024]; int bytesRead; //read from is to buffer while ((bytesRead = is.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } is.close(); //flush OutputStream to write any buffered data to file output.flush(); output.close(); } catch (Exception e) { throw new WebApplicationException(e); } }; StringBuilder sb = new StringBuilder(); sb.append("attachment;filename=\""); sb.append(resource.getXmlId().getEncoded()); sb.append(org.eclipse.winery.repository.Constants.SUFFIX_CSAR); sb.append("\""); return Response.ok().header("Content-Disposition", sb.toString()).type(MimeTypes.MIMETYPE_ZIP).entity(so).build(); }
/** * Zips the folder reference given by the id. As filename the parent id is used. * * @param id the id of the folder */ public static Response getZippedContents(final GenericId id) { final String name = id.getParent().getXmlId().getEncoded(); return getZippedContents(id, name + Constants.SUFFIX_ZIP); }
resource.getXmlId().getEncoded(), Constants.SUFFIX_CSAR);
/** * Returns a unique name for the given definitions to be used as filename */ private static String getDefinitionsName(IGenericRepository repository, DefinitionsChildId id) { // the prefix is globally unique and the id locally in a namespace // therefore a concatenation of both is also unique return repository.getNamespaceManager().getPrefix(id.getNamespace()) + "__" + id.getXmlId().getEncoded(); }
return "admin/" + id.getXmlId().getEncoded() + "/"; } else if (id instanceof GenericImportId) { GenericImportId i = (GenericImportId) id; res = res + Util.URLencode(i.getType()) + "/"; res = res + i.getNamespace().getEncoded() + "/"; res = res + i.getXmlId().getEncoded() + "/"; return res; } else if (id instanceof DefinitionsChildId) { return getPathInsideRepo(id.getParent()) + id.getXmlId().getEncoded() + "/"; } else { throw new IllegalStateException("Unknown subclass of GenericId " + id.getClass());
location = location + serviceTemplate.getNamespace().getEncoded(); location = location + "&id="; location = location + serviceTemplate.getXmlId().getEncoded(); if (edit == null) {
toInsert = tId.getXmlId().getEncoded(); if (doubleEncode) { toInsert = Util.URLencode(toInsert); return res; } else if (id instanceof ToscaElementId) { toInsert = id.getXmlId().getEncoded(); if (doubleEncode) { toInsert = Util.URLencode(toInsert);
path = tcId.getNamespace().getEncoded() + "/" + tcId.getXmlId().getEncoded() + "/"; path = id.getXmlId().getEncoded() + "/";