public DatasetTypeId datasetType(String type) { return new DatasetTypeId(namespace, type); }
@Override public String getEntityName() { return getType(); }
@VisibleForTesting @Override public boolean hasType(DatasetTypeId datasetTypeId) { return registries.containsKey(datasetTypeId.getParent()) && registries.get(datasetTypeId.getParent()).hasType(datasetTypeId.getEntityName()); }
@SuppressWarnings("unused") public static DatasetTypeId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new DatasetTypeId(next(iterator, "namespace"), nextAndEnd(iterator, "type")); }
private void writeTypeToModuleMapping(DatasetTypeId datasetTypeId, DatasetModuleId datasetModuleId) { write(getTypeKey(datasetTypeId.getNamespace(), datasetTypeId.getEntityName()), datasetModuleId); }
/** * Checks if a dataset type exists. * * @param type the dataset type to check * @return true if the dataset type exists * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public boolean exists(DatasetTypeId type) throws DatasetTypeNotFoundException, IOException, UnauthenticatedException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(type.getParent(), String.format("data/types/%s", type.getType())); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); return response.getResponseCode() != HttpURLConnection.HTTP_NOT_FOUND; } }
/** * Returns details of the specified {@link DatasetTypeId dataset type}. */ @Override public DatasetTypeMeta getType(DatasetTypeId datasetTypeId) throws Exception { ensureNamespaceExists(datasetTypeId.getParent()); DatasetTypeMeta typeMeta = typeManager.getTypeInfo(datasetTypeId); if (typeMeta == null) { throw new DatasetTypeNotFoundException(datasetTypeId); } return typeMeta; }
@Override public DatasetTypeMeta getType(DatasetTypeId datasetTypeId) throws Exception { // No authorization for system dataset types if (!NamespaceId.SYSTEM.equals(datasetTypeId.getNamespaceId())) { AuthorizationUtil.ensureOnePrivilege(datasetTypeId, EnumSet.allOf(Action.class), authorizationEnforcer, authenticationContext.getPrincipal()); } return delegate.getType(datasetTypeId); } }
public DatasetTypeId(String namespace, String type) { super(namespace, EntityType.DATASET_TYPE); if (type == null) { throw new NullPointerException("Type cannot be null."); } ensureValidDatasetId("dataset type", type); this.type = type; }
private void writeTypeToModuleMapping(DatasetTypeId datasetTypeId, DatasetModuleId datasetModuleId) { write(getTypeKey(datasetTypeId.getNamespace(), datasetTypeId.getEntityName()), datasetModuleId); }
@SuppressWarnings("unused") public static DatasetTypeId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new DatasetTypeId(next(iterator, "namespace"), nextAndEnd(iterator, "type")); }
/** * Gets information about a dataset type. * * @param type the dataset type * @return {@link DatasetTypeMeta} of the dataset type * @throws DatasetTypeNotFoundException if the dataset type could not be found * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public DatasetTypeMeta get(DatasetTypeId type) throws DatasetTypeNotFoundException, IOException, UnauthenticatedException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(type.getParent(), String.format("data/types/%s", type.getType())); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new DatasetTypeNotFoundException(type); } return ObjectResponse.fromJsonBody(response, DatasetTypeMeta.class).getResponseObject(); }
/** * Returns details of the specified {@link DatasetTypeId dataset type}. */ @Override public DatasetTypeMeta getType(DatasetTypeId datasetTypeId) throws Exception { ensureNamespaceExists(datasetTypeId.getParent()); DatasetTypeMeta typeMeta = typeManager.getTypeInfo(datasetTypeId); if (typeMeta == null) { throw new DatasetTypeNotFoundException(datasetTypeId); } return typeMeta; }
@Override public DatasetTypeMeta getType(DatasetTypeId datasetTypeId) throws Exception { // No authorization for system dataset types if (!NamespaceId.SYSTEM.equals(datasetTypeId.getNamespaceId())) { AuthorizationUtil.ensureOnePrivilege(datasetTypeId, EnumSet.allOf(Action.class), authorizationEnforcer, authenticationContext.getPrincipal()); } return delegate.getType(datasetTypeId); } }
public DatasetTypeId(String namespace, String type) { super(namespace, EntityType.DATASET_TYPE); if (type == null) { throw new NullPointerException("Type cannot be null."); } ensureValidDatasetId("dataset type", type); this.type = type; }
@VisibleForTesting @Override public boolean hasType(DatasetTypeId datasetTypeId) { return registries.containsKey(datasetTypeId.getParent()) && registries.get(datasetTypeId.getParent()).hasType(datasetTypeId.getEntityName()); }
@Nullable public DatasetModuleMeta getModuleByType(DatasetTypeId datasetTypeId) { DatasetModuleId datasetModuleId = get(getTypeKey(datasetTypeId.getNamespace(), datasetTypeId.getEntityName()), DatasetModuleId.class); if (datasetModuleId == null) { return null; } // TODO: Slightly strange. Maybe change signature to accept NamespaceId separately from typeName return getModule(datasetModuleId); }
public DatasetTypeId datasetType(String type) { return new DatasetTypeId(namespace, type); }
@Override public String getEntityName() { return getType(); }
datasetTypeMDS.writeModule(usedType.getParent(), usedModule);