/** * Create an instance of {@link Application } * */ public Application createApplication() { return new Application(); }
@Path("options/") public OptionsResource getOptionsResource() { Options options = this.application.getOptions(); if (options == null) { options = new Options(); this.application.setOptions(options); } return new OptionsResource(options.getOption(), serviceTemplateResource, this.id); }
@PUT @Path("description") @Consumes(MediaType.APPLICATION_JSON) public Response onPutOnDescription(Application value) { this.application.setDescription(value.getDescription()); return persist(); }
@PUT @Path("displayname") @Consumes(MediaType.APPLICATION_JSON) public Response onPutOnDisplayName(Application value) { this.application.setDisplayName(value.getDisplayName()); return persist(); }
private static Application getDefaultApplicationData(SelfServiceMetaDataId id) { Application app = new Application(); app.setIconUrl("icon.jpg"); app.setImageUrl("image.jpg"); final TServiceTemplate serviceTemplate = RepositoryFactory.getRepository().getElement((ServiceTemplateId) id.getParent()); app.setDisplayName(serviceTemplate.getName()); List<TDocumentation> documentation = serviceTemplate.getDocumentation(); if ((documentation != null) && (!documentation.isEmpty())) { TDocumentation doc = documentation.get(0); List<Object> content = doc.getContent(); if ((content != null) && (!content.isEmpty())) { app.setDescription(content.get(0).toString()); } } return app; } }
if (application.getCsarName() != null) { application.setCsarName(null); isApplicationChanged = true; if (application.getVersion() == null || !application.getVersion().equals("1.0")) { application.setVersion("1.0"); isApplicationChanged = true; List<String> authors = application.getAuthors(); if (authors.isEmpty()) { authors.add("Winery"); Options options = application.getOptions(); if (options != null) { SelfServiceMetaDataId id = new SelfServiceMetaDataId(entryId);
@PUT @Path("image.jpg") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putImage(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { try { SelfServiceMetaDataUtils.ensureDataXmlExists(this.id); } catch (IOException e) { throw new WebApplicationException(e); } RepositoryFileReference ref = new RepositoryFileReference(this.id, "image.jpg"); Response response = RestUtils.putContentToFile(ref, uploadedInputStream, body.getMediaType()); if (StringUtils.isEmpty(this.application.getImageUrl())) { this.application.setImageUrl("image.jpg"); persist(); } return response; }
@PUT @Path("icon.jpg") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putIcon(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { try { SelfServiceMetaDataUtils.ensureDataXmlExists(this.id); } catch (IOException e) { throw new WebApplicationException(e); } RepositoryFileReference ref = new RepositoryFileReference(this.id, "icon.jpg"); Response response = RestUtils.putContentToFile(ref, uploadedInputStream, body.getMediaType()); if (StringUtils.isEmpty(this.application.getIconUrl())) { this.application.setIconUrl("icon.jpg"); persist(); } return response; }
public static void ensureDataXmlExists(SelfServiceMetaDataId id) throws IOException { RepositoryFileReference data_xml_ref = getDataXmlRef(id); if (!RepositoryFactory.getRepository().exists(data_xml_ref)) { final Application application = new Application(); BackendUtils.persist(application, data_xml_ref, MediaTypes.MEDIATYPE_TEXT_XML); } }
public static Application getApplication(SelfServiceMetaDataId id) { RepositoryFileReference data_xml_ref = getDataXmlRef(id); if (RepositoryFactory.getRepository().exists(data_xml_ref)) { Unmarshaller u = JAXBSupport.createUnmarshaller(); try (InputStream is = RepositoryFactory.getRepository().newInputStream(data_xml_ref)) { return (Application) u.unmarshal(is); } catch (IOException | JAXBException e) { LOGGER.error("Could not read from " + data_xml_ref, e); return new Application(); } } else { return getDefaultApplicationData(id); } }