if(validationStatus.isError()) {
runStatus = validationStatus;
} else {
final SodaDdl updater = SodaDdl.newDdl(connectionInfo.getUrl(), connectionInfo.getUser(),
connectionInfo.getPassword(), connectionInfo.getToken());
final SodaWorkflow workflower = SodaWorkflow.newWorkflow(connectionInfo.getUrl(), connectionInfo.getUser(),
connectionInfo.getPassword(), connectionInfo.getToken());
boolean noExceptions = false;
try {
DatasetInfo datasetInfo = updater.loadDatasetInfo(datasetID);
if (datasetInfo == null) {
runErrorMessage = "Dataset with that ID does not exist or you do not have permission to publish to it";
runStatus = JobStatus.PUBLISH_ERROR;
}
else {
if (datasetInfo.PUBLISHED.equals(datasetInfo.getPublicationStage())) {
DatasetInfo workingCopyDatasetInfo = workflower.createWorkingCopy(datasetInfo.getId());
datasetInfo = updater.loadDatasetInfo(workingCopyDatasetInfo.getId());
workingCopyDatasetId = datasetInfo.getId();
}
datasetInfo.setName(title);
datasetInfo.setDescription(description);
datasetInfo.setCategory(category);
if (keywords != null && !keywords.isEmpty()) {
datasetInfo.setTags(keywords);
}
else {
datasetInfo.setTags(new ArrayList<String>());
}
if (licenseType != null) {
//TODO: Once issue with setting no license via api is resolved, update below to handle
if (licenseType == LicenseType.no_license) {
datasetInfo.setLicenseId(""); //null, "", "''", "\"\"", Tried all of these, no luck, validation errors on all, so
}
else {
datasetInfo.setLicenseId(licenseType.getValue());
}
}
datasetInfo.setAttribution(dataProvidedBy);
datasetInfo.setAttributionLink(sourceLink);
Map<String, Object> privateMetadata = datasetInfo.getPrivateMetadata();
if (privateMetadata == null) {
privateMetadata = new HashMap<String, Object>();
}
privateMetadata.put("contactEmail", contactInfo);
updater.updateDatasetInfo(datasetInfo);
if (!StringUtils.isBlank(workingCopyDatasetId)) {
workflower.publish(datasetInfo.getId());
workingCopyDatasetId = null;
}