use of org.eclipse.winery.model.selfservice.Application.Options in project winery by eclipse.
the class CsarExporter method addSelfServiceMetaData.
/**
* Adds all self service meta data to the targetDir
*
* @param targetDir the directory in the CSAR where to put the content to
* @param refMap is used later to create the CSAR
*/
private void addSelfServiceMetaData(IRepository repository, ServiceTemplateId entryId, String targetDir, Map<RepositoryFileReference, String> refMap) throws IOException {
final SelfServiceMetaDataId selfServiceMetaDataId = new SelfServiceMetaDataId(entryId);
// This method is also called if the directory SELFSERVICE-Metadata exists without content and even if the directory does not exist at all,
// but the ServiceTemplate itself exists.
// The current assumption is that this is enough for an existence.
// Thus, we have to take care of the case of an empty directory and add a default data.xml
SelfServiceMetaDataUtils.ensureDataXmlExists(selfServiceMetaDataId);
refMap.put(SelfServiceMetaDataUtils.getDataXmlRef(selfServiceMetaDataId), targetDir + "data.xml");
// The schema says that the images have to exist
// However, at a quick modeling, there might be no images
// Therefore, we check for existence
final RepositoryFileReference iconJpgRef = SelfServiceMetaDataUtils.getIconJpgRef(selfServiceMetaDataId);
if (repository.exists(iconJpgRef)) {
refMap.put(iconJpgRef, targetDir + "icon.jpg");
}
final RepositoryFileReference imageJpgRef = SelfServiceMetaDataUtils.getImageJpgRef(selfServiceMetaDataId);
if (repository.exists(imageJpgRef)) {
refMap.put(imageJpgRef, targetDir + "image.jpg");
}
Application application = SelfServiceMetaDataUtils.getApplication(selfServiceMetaDataId);
// clear CSAR name as this may change.
application.setCsarName(null);
// hack for the OpenTOSCA container to display something
application.setVersion("1.0");
List<String> authors = application.getAuthors();
if (authors.isEmpty()) {
authors.add("Winery");
}
// make the patches to data.xml permanent
try {
BackendUtils.persist(application, SelfServiceMetaDataUtils.getDataXmlRef(selfServiceMetaDataId), MediaTypes.MEDIATYPE_TEXT_XML);
} catch (IOException e) {
LOGGER.error("Could not persist patches to data.xml", e);
}
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);
}
}
}
}
use of org.eclipse.winery.model.selfservice.Application.Options in project winery by eclipse.
the class SelfServicePortalResource method getOptionsResource.
@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);
}
Aggregations