/** * Create an instance of {@link Application } * */ public Application createApplication() { return new Application(); }
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); } }
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; } }