use of org.pentaho.platform.plugin.services.metadata.IModelAnnotationsAwareMetadataDomainRepositoryImporter in project pentaho-platform by pentaho.
the class MetadataImportHandler method processMetadataFile.
/**
* Processes the file as a metadata file and returns the domain name. It will import the file into the Pentaho
* Metadata Domain Repository.
*
* @param bundle
* @return
*/
protected String processMetadataFile(final IPlatformImportBundle bundle) throws PlatformImportException {
final String domainId = (String) bundle.getProperty("domain-id");
if (domainId == null) {
throw new PlatformImportException("Bundle missing required domain-id property");
}
try {
log.debug("Importing as metadata - [domain=" + domainId + "]");
final InputStream inputStream;
if (bundle.isPreserveDsw()) {
// storeDomain needs to be able to close the stream
inputStream = cloneStream(bundle.getInputStream());
} else {
inputStream = StripDswFromStream(bundle.getInputStream());
}
if (metadataRepositoryImporter instanceof IAclAwarePentahoMetadataDomainRepositoryImporter) {
IAclAwarePentahoMetadataDomainRepositoryImporter importer = (IAclAwarePentahoMetadataDomainRepositoryImporter) metadataRepositoryImporter;
importer.storeDomain(inputStream, domainId, bundle.overwriteInRepository(), bundle.isApplyAclSettings() ? bundle.getAcl() : null);
} else {
metadataRepositoryImporter.storeDomain(inputStream, domainId, bundle.overwriteInRepository());
}
if (metadataRepositoryImporter instanceof IModelAnnotationsAwareMetadataDomainRepositoryImporter) {
// Store annotations xml with the domain if it exists
final String annotationsXml = (String) bundle.getProperty(IModelAnnotationsAwareMetadataDomainRepositoryImporter.PROPERTY_NAME_ANNOTATIONS);
if (StringUtils.isNotBlank(annotationsXml)) {
// Save annotations
IModelAnnotationsAwareMetadataDomainRepositoryImporter importer = (IModelAnnotationsAwareMetadataDomainRepositoryImporter) metadataRepositoryImporter;
importer.storeAnnotationsXml(domainId, annotationsXml);
}
}
return domainId;
} catch (DomainIdNullException dine) {
throw new PlatformImportException(dine.getMessage(), PlatformImportException.PUBLISH_TO_SERVER_FAILED, dine);
} catch (DomainStorageException dse) {
throw new PlatformImportException(dse.getMessage(), PlatformImportException.PUBLISH_TO_SERVER_FAILED, dse);
} catch (DomainAlreadyExistsException daee) {
throw new PlatformImportException(messages.getString("PentahoPlatformImporter.ERROR_0007_PUBLISH_SCHEMA_EXISTS_ERROR"), PlatformImportException.PUBLISH_SCHEMA_EXISTS_ERROR, daee);
} catch (Exception e) {
final String errorMessage = messages.getErrorString("MetadataImportHandler.ERROR_0001_IMPORTING_METADATA", domainId, e.getLocalizedMessage());
log.error(errorMessage, e);
throw new PlatformImportException(errorMessage, e);
}
}
Aggregations