/** Setup local state management. * <p> * This operation contacts the patch log server. */ public void attach(Id datasourceId, LocalStorageType storageType) { Objects.requireNonNull(datasourceId, "datasourceId"); DataSourceDescription dsd = dLink.getDataSourceDescription(datasourceId); if ( dsd == null ) throw new DeltaBadRequestException("Can't attach: no such link data source by id : "+datasourceId); setupState$(dsd, storageType); }
/** Setup local state management. * <p> * This operation contacts the patch log server. */ public void attach(String name, LocalStorageType storageType) { Objects.requireNonNull(name, "name"); DataSourceDescription dsd = dLink.getDataSourceDescriptionByName(name); if ( dsd == null ) throw new DeltaBadRequestException("Can't attach: no such link data source by name : "+name); setupState$(dsd, storageType); }
/** * Attach to an existing {@code DataSource} with a fresh * {@link DatasetGraph} as local state. The caller undertakes to only access * the {@code DatasetGraph} through a {@link DeltaConnection} obtained from * this {@code DeltaClient}. * <p> * The {@code DatasetGraph} is assumed to empty and is brought up-to-date. * The client must be registered with the {@link DeltaLink}. * <p> * This is a specialised operation - using a managed dataset (see * {@link #register(Id, LocalStorageType, SyncPolicy)}) is preferred. * <p> * {@link #connect(Id, SyncPolicy)} must be called later to use the dataset. */ public void attachExternal(Id datasourceId, DatasetGraph dsg) { Objects.requireNonNull(datasourceId); DataSourceDescription dsd = dLink.getDataSourceDescription(datasourceId); if ( dsd == null ) throw new DeltaBadRequestException("Can't attach: no such link data source : "+datasourceId); setupExternal(dsd, dsg); }
/** * Attach to an existing {@code DataSource} with a fresh * {@link DatasetGraph} as local state. The caller undertakes to only access * the {@code DatasetGraph} through a {@link DeltaConnection} obtained from * this {@code DeltaClient}. * <p> * This is a specialised operation - using a managed dataset (see * {@link #attach(String, LocalStorageType)}) is preferred. * <p> * The {@code DatasetGraph} is assumed to empty and is brought up-to-date. * The client must be registered with the {@code DeltaLink}. * <p> * {@link #connect(Id, SyncPolicy)} must be called later to use the dataset. */ public Id attachExternal(String name, DatasetGraph dsg) { DataSourceDescription dsd = dLink.getDataSourceDescriptionByName(name); if ( dsd == null ) throw new DeltaBadRequestException("Can't attach: no such link data source : "+name); setupExternal(dsd, dsg); return dsd.getId(); }
throw new DeltaBadRequestException("DataSource area already exists and is active at: "+sourcePath); throw new DeltaBadRequestException("DataSource area already exists at: "+sourcePath); if ( ! CfgFile.isEnabled(sourcePath) ) throw new DeltaBadRequestException("DataSource area disabled: "+sourcePath); throw new DeltaBadRequestException("Failed to create DataSource area: "+sourcePath);
/** Convert to original exception. */ public static DeltaHttpException extract(DeltaHttpException ex) { int statusCode = ex.getStatusCode(); String msg = ex.getMessage(); switch(statusCode) { case HttpSC.BAD_REQUEST_400: return new DeltaBadRequestException(msg); case HttpSC.NOT_FOUND_404: return new DeltaNotFoundException(msg); case HttpSC.UNAUTHORIZED_401: return new DeltaNotRegisteredException(msg); case HttpSC.FORBIDDEN_403: default: return ex; } }
} catch (HttpException ex) { if ( HttpSC.BAD_REQUEST_400 == ex.getResponseCode() ) { throw new DeltaBadRequestException(ex.getMessage());
/** * Create a new data source in the specified {@link PatchStore}. This can * not be one that has been removed (i.e. disabled) whose files must be * cleaned up manually. */ public Id createDataSource(PatchStore patchStore, String name, String baseURI/*, details*/) { checkActive(); int C = createCounter.incrementAndGet(); if ( syncedDataRegistry().containsName(name) ) throw new DeltaBadRequestException("DataSource with name '"+name+"' already exists"); // Proposed id, only becomes permanent if the create actually does a create and // does not find someone else has (with a different id); // XXX Delay id allocation until create-for-real. Create does not take a DSD. Id dsRef = Id.create(); FmtLog.info(LOG, "[%s](%d) createDataSource/start: %s", label, C, dsRef); DataSourceDescription dsd = new DataSourceDescription(dsRef, name, baseURI); DataSource dataSource = createDataSource$(C, patchStore, dsd); FmtLog.info(LOG, "[%s](%d) createDataSource/finish: %s %s", label, C, dsRef, dataSource.getDescription()); // dsRef is not invalid if it was not used. dsRef = null; return dataSource.getId(); }
String msg = String.format("Log name '%s' does not match regex '%s'", dsName, LogNameRegex); Log.warn(LOGZK, msg); throw new DeltaBadRequestException(msg);
previousId, this.latestId); throw new DeltaBadRequestException(msg);