@Override public DatasetConfig renameDataset(NamespaceKey oldDatasetPath, NamespaceKey newDatasetPath) throws NamespaceException { return doRenameDataset(oldDatasetPath, newDatasetPath, getEntitiesOnPath(oldDatasetPath.getParent()), getEntitiesOnPath(newDatasetPath.getParent())); }
@VisibleForTesting NameSpaceContainer deleteEntity(final NamespaceKey path, final Type type, String version, boolean deleteRoot) throws NamespaceException { final List<NameSpaceContainer> entitiesOnPath = getEntitiesOnPath(path); final NameSpaceContainer container = lastElement(entitiesOnPath); if (container == null) { throw new NamespaceNotFoundException(path, String.format("Entity %s not found", path)); } return doDeleteEntity(path, type, version, entitiesOnPath, deleteRoot); }
/** * Helper method which creates a new entity or update the existing entity with given entity * * @param entity * @throws NamespaceException */ private void createOrUpdateEntity(final NamespaceEntity entity, NamespaceAttribute... attributes) throws NamespaceException { final NamespaceKey entityPath = entity.getPathKey().getPath(); final List<NameSpaceContainer> entitiesOnPath = getEntitiesOnPath(entityPath); doCreateOrUpdateEntity(entity, entitiesOnPath, attributes); }
/** * Helper method which retrieves the entity with given key. No authorization check done. * * @param key * @return * @throws NamespaceException */ private NameSpaceContainer getEntity(final NamespaceKey key, Type type) throws NamespaceException { final List<NameSpaceContainer> entitiesOnPath = getEntitiesOnPath(key); NameSpaceContainer container = lastElement(entitiesOnPath); if (container == null || container.getType() != type) { throw new NamespaceNotFoundException(key, "not found"); } return doGetEntity(key, type, entitiesOnPath); }
@Override public List<NameSpaceContainer> list(NamespaceKey root) throws NamespaceException { final List<NameSpaceContainer> entitiesOnPath = getEntitiesOnPath(root); final NameSpaceContainer rootContainer = lastElement(entitiesOnPath); if (rootContainer == null) { throw new NamespaceNotFoundException(root, "not found"); } if (!isListable(rootContainer.getType())) { throw new NamespaceNotFoundException(root, "no listable entity found"); } return doList(root, entitiesOnPath); }