use of com.thinkbiganalytics.feedmgr.rest.model.UploadProgressMessage in project kylo by Teradata.
the class UploadProgressService method addUploadStatus.
public UploadProgressMessage addUploadStatus(String uploadKey, String message, boolean complete, boolean success) {
UploadProgress uploadProgress = getUploadStatus(uploadKey);
if (uploadProgress != null) {
UploadProgressMessage uploadProgressMessage = new UploadProgressMessage(message);
if (complete) {
uploadProgressMessage.complete(success);
}
uploadProgress.getMessages().add(uploadProgressMessage);
return uploadProgressMessage;
}
return null;
}
use of com.thinkbiganalytics.feedmgr.rest.model.UploadProgressMessage in project kylo by Teradata.
the class UploadProgressService method updateUploadStatus.
public UploadProgressMessage updateUploadStatus(String uploadKey, String messageKey, String message, boolean complete) {
UploadProgress uploadProgress = getUploadStatus(uploadKey);
if (uploadProgress != null) {
UploadProgressMessage uploadProgressMessage = uploadProgress.getMessage(messageKey);
if (uploadProgressMessage == null) {
uploadProgressMessage = new UploadProgressMessage();
uploadProgressMessage.setMessageKey(messageKey);
}
uploadProgressMessage.setMessage(message);
uploadProgressMessage.setDateTime(DateTime.now());
uploadProgressMessage.setComplete(complete);
uploadProgress.getMessages().add(new UploadProgressMessage(message));
return uploadProgressMessage;
}
return null;
}
use of com.thinkbiganalytics.feedmgr.rest.model.UploadProgressMessage in project kylo by Teradata.
the class FeedImporter method validateSensitiveProperties.
private boolean validateSensitiveProperties() {
FeedMetadata metadata = importFeed.getFeedToImport();
// detect any sensitive properties and prompt for input before proceeding
UploadProgressMessage statusMessage = uploadProgressService.addUploadStatus(importFeed.getImportOptions().getUploadKey(), "Validating feed properties.");
List<NifiProperty> sensitiveProperties = metadata.getSensitiveProperties();
ImportUtil.addToImportOptionsSensitiveProperties(importFeedOptions, sensitiveProperties, ImportComponent.FEED_DATA);
boolean valid = ImportUtil.applyImportPropertiesToFeed(metadata, importFeed, ImportComponent.FEED_DATA);
if (!valid) {
statusMessage.update("Validation Error. Additional properties are needed before uploading the feed.", false);
importFeed.setValid(false);
} else {
statusMessage.update("Validated feed properties.", valid);
}
uploadProgressService.completeSection(importFeed.getImportOptions(), ImportSection.Section.VALIDATE_PROPERTIES);
return valid;
}
use of com.thinkbiganalytics.feedmgr.rest.model.UploadProgressMessage in project kylo by Teradata.
the class FeedImporter method validateUserDatasources.
/**
* Validates that user data sources can be imported with provided properties.
*
* @return {@code true} if the feed can be imported, or {@code false} otherwise
*/
private boolean validateUserDatasources() {
FeedMetadata metadata = importFeed.getFeedToImport();
final UploadProgressMessage statusMessage = uploadProgressService.addUploadStatus(importFeed.getImportOptions().getUploadKey(), "Validating data sources.");
// Get data sources needing to be created
final Set<String> availableDatasources = metadataAccess.read(() -> datasourceProvider.getDatasources(datasourceProvider.datasetCriteria().type(UserDatasource.class)).stream().map(com.thinkbiganalytics.metadata.api.datasource.Datasource::getId).map(Object::toString).collect(Collectors.toSet()));
final ImportComponentOption componentOption = importFeedOptions.findImportComponentOption(ImportComponent.USER_DATASOURCES);
final List<Datasource> providedDatasources = Optional.ofNullable(metadata.getUserDatasources()).orElse(Collections.emptyList());
if (componentOption.getProperties().isEmpty()) {
componentOption.setProperties(providedDatasources.stream().filter(datasource -> !availableDatasources.contains(datasource.getId())).map(datasource -> new ImportProperty(datasource.getName(), datasource.getId(), null, null, null)).collect(Collectors.toList()));
}
// Update feed with re-mapped data sources
final boolean valid = componentOption.getProperties().stream().allMatch(property -> {
if (property.getPropertyValue() != null) {
ImportUtil.replaceDatasource(metadata, property.getProcessorId(), property.getPropertyValue());
return true;
} else {
return false;
}
});
if (valid) {
statusMessage.update("Validated data sources.", true);
} else {
statusMessage.update("Validation Error. Additional properties are needed before uploading the feed.", false);
importFeed.setValid(false);
}
uploadProgressService.completeSection(importFeed.getImportOptions(), ImportSection.Section.VALIDATE_USER_DATASOURCES);
return valid;
}
use of com.thinkbiganalytics.feedmgr.rest.model.UploadProgressMessage in project kylo by Teradata.
the class FeedImporter method init.
private void init() {
this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.IMPORT_FEEDS);
UploadProgressMessage feedImportStatusMessage = uploadProgressService.addUploadStatus(importFeedOptions.getUploadKey(), "Initialize feed import.");
try {
boolean isValid = isValidFileImport(fileName) && ZipFileUtil.validateZipEntriesWithRequiredEntries(file, getValidZipFileEntries(), Sets.newHashSet(ImportFeed.FEED_JSON_FILE));
if (!isValid) {
feedImportStatusMessage.update("Validation error. Feed import error. The zip file you uploaded is not valid feed export.", false);
throw new ImportFeedException("The zip file you uploaded is not valid feed export.");
}
// get the Feed Data
importFeed = readFeedJson(fileName, file);
// initially mark as valid.
importFeed.setValid(true);
// merge in the file components to the user options
Set<ImportComponentOption> componentOptions = ImportUtil.inspectZipComponents(file, ImportType.FEED);
importFeedOptions.addOptionsIfNotExists(componentOptions);
// importFeedOptions.findImportComponentOption(ImportComponent.TEMPLATE_CONNECTION_INFORMATION).addConnectionInfo(importFeed.getReusableTemplateConnections());
importFeed.setImportOptions(importFeedOptions);
feedImportStatusMessage.complete(true);
} catch (Exception e) {
throw new ImportException("Unable to import feed. ", e);
}
}
Aggregations