/** * Create an instance of {@link Application.Options } * */ public Application.Options createApplicationOptions() { return new Application.Options(); }
/** * Create an instance of {@link Application } * */ public Application createApplication() { return new Application(); }
/** * Create an instance of {@link ApplicationOption } * */ public ApplicationOption createApplicationOption() { return new ApplicationOption(); }
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); for (ApplicationOption option : options.getOption()) { String url = option.getIconUrl(); if (Util.isRelativeURI(url)) { putRefIntoRefMap(targetDir, refMap, repository, id, url); url = option.getPlanInputMessageUrl(); if (Util.isRelativeURI(url)) { putRefIntoRefMap(targetDir, refMap, repository, id, url);
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; } }
@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); }
return Response.status(Status.BAD_REQUEST).entity("file has to be provided").build(); ApplicationOption option = new ApplicationOption(); option.setId(id); option.setName(name); option.setDescription(description); option.setIconUrl(iconFileName); option.setPlanInputMessageUrl(planInputMessageFileName); option.setPlanServiceName(planServiceName);
@Override public Response onDelete() { // delete icon and plan model reference ... // delete icon // we use the URL stored in the data instead of the generated URL to be compatible with manually edits RepositoryFileReference ref = new RepositoryFileReference(this.ssmdId, this.o.getIconUrl()); try { RepositoryFactory.getRepository().forceDelete(ref); } catch (IOException e) { OptionResource.LOGGER.error("Could not remove file", e); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } // delete plan input // we use the URL stored in the data instead of the generated URL to be compatible with manually edits ref = new RepositoryFileReference(this.ssmdId, this.o.getPlanInputMessageUrl()); try { RepositoryFactory.getRepository().forceDelete(ref); } catch (IOException e) { OptionResource.LOGGER.error("Could not remove file", e); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } // after deleting files, continue with list deletion return super.onDelete(); } }
@PUT @Path("displayname") @Consumes(MediaType.APPLICATION_JSON) public Response onPutOnDisplayName(Application value) { this.application.setDisplayName(value.getDisplayName()); return persist(); }
@PUT @Path("description") @Consumes(MediaType.APPLICATION_JSON) public Response onPutOnDescription(Application value) { this.application.setDescription(value.getDescription()); return persist(); }
@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; }
@Override public String getId(ApplicationOption entity) { return entity.getId(); }
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); } }
private String getFileNamePrefix() { return OptionResource.getFileNamePrefix(this.o.getId()); }
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); } }