use of com.netflix.metacat.common.dto.BaseDto in project metacat by Netflix.
the class MetadataService method deleteDefinitionMetadata.
/**
* Deletes definition metadata for the given <code>name</code>.
*
* @param name qualified name
* @param force If true, deletes the metadata without checking if database/table/partition exists
* @param metacatRequestContext request context
* @return true if deleted
*/
public boolean deleteDefinitionMetadata(final QualifiedName name, final boolean force, final MetacatRequestContext metacatRequestContext) {
try {
final MetacatService service = this.helper.getService(name);
BaseDto dto = null;
if (!force) {
try {
dto = service.get(name);
} catch (final NotFoundException ignored) {
}
}
if ((force || dto == null) && !"rds".equalsIgnoreCase(name.getCatalogName())) {
if (dto != null) {
this.helper.postPreUpdateEvent(name, metacatRequestContext, dto);
} else {
this.helper.postPreDeleteEvent(name, metacatRequestContext);
}
this.userMetadataService.deleteDefinitionMetadata(Lists.newArrayList(name));
this.tagService.delete(name, false);
log.info("Deleted definition metadata for {}", name);
if (dto != null) {
final BaseDto newDto = service.get(name);
this.helper.postPostUpdateEvent(name, metacatRequestContext, dto, newDto);
} else {
this.helper.postPostDeleteEvent(name, metacatRequestContext);
}
return true;
}
} catch (Exception e) {
log.warn("Failed deleting definition metadata for name {}.", name, e);
throw e;
}
return false;
}
use of com.netflix.metacat.common.dto.BaseDto in project metacat by Netflix.
the class MetadataV1Resource method deleteDefinitionMetadata.
/**
* {@inheritDoc}
*/
@Override
public void deleteDefinitionMetadata(final QualifiedName name, final Boolean force) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
requestWrapper.processRequest("deleteDefinitionMetadata", () -> {
final MetacatService service = helper.getService(name);
BaseDto dto = null;
try {
dto = service.get(name);
} catch (NotFoundException ignored) {
}
if ((force || dto == null) && !"rds".equalsIgnoreCase(name.getCatalogName())) {
helper.postPreUpdateEvent(name, metacatRequestContext, dto);
userMetadataService.deleteDefinitionMetadatas(Lists.newArrayList(name));
if (dto instanceof HasDefinitionMetadata) {
((HasDefinitionMetadata) dto).setDefinitionMetadata(null);
}
final BaseDto newDto = service.get(name);
helper.postPostUpdateEvent(name, metacatRequestContext, dto, newDto);
}
return null;
});
}
Aggregations