public DatasetSpecification configure(String instanceName, DatasetProperties properties) { DatasetSpecification spec = delegate.configure(instanceName, properties); spec = spec.setOriginalProperties(properties); if (properties.getDescription() != null) { spec = spec.setDescription(properties.getDescription()); } return spec; }
public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { DatasetSpecification spec = AbstractDatasetDefinition .reconfigure(delegate, instanceName, newProperties, currentSpec) .setOriginalProperties(newProperties); if (newProperties.getDescription() != null) { spec = spec.setDescription(newProperties.getDescription()); } return spec; }
public DatasetSpecification configure(String instanceName, DatasetProperties properties) { DatasetSpecification spec = delegate.configure(instanceName, properties); spec = spec.setOriginalProperties(properties); if (properties.getDescription() != null) { spec = spec.setDescription(properties.getDescription()); } return spec; }
public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { DatasetSpecification spec = AbstractDatasetDefinition .reconfigure(delegate, instanceName, newProperties, currentSpec) .setOriginalProperties(newProperties); if (newProperties.getDescription() != null) { spec = spec.setDescription(newProperties.getDescription()); } return spec; }
@Override public void addInstance(String datasetType, DatasetId datasetInstanceId, DatasetProperties props, @Nullable KerberosPrincipalId ownerPrincipal) throws DatasetManagementException, IOException { if (ownerPrincipal != null) { throw new UnsupportedOperationException("Creating dataset with owner is not supported"); } writeLock.lock(); try { if (instances.contains(datasetInstanceId.getParent(), datasetInstanceId)) { throw new InstanceConflictException(String.format("Dataset instance '%s' already exists.", datasetInstanceId)); } DatasetDefinition def = getDefinitionForType(datasetInstanceId.getParent(), datasetType); if (def == null) { throw new DatasetManagementException( String.format("Dataset type '%s' is neither registered in the '%s' namespace nor in the system namespace", datasetType, datasetInstanceId.getParent())); } DatasetSpecification spec = def.configure(datasetInstanceId.getEntityName(), props); spec = spec.setOriginalProperties(props); if (props.getDescription() != null) { spec = spec.setDescription(props.getDescription()); } def.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec, null).create(); instances.put(datasetInstanceId.getParent(), datasetInstanceId, spec); publishAudit(datasetInstanceId, AuditType.CREATE); LOG.info("Created dataset {} of type {}", datasetInstanceId, datasetType); } finally { writeLock.unlock(); } }
@Override public void addInstance(String datasetType, DatasetId datasetInstanceId, DatasetProperties props, @Nullable KerberosPrincipalId ownerPrincipal) throws DatasetManagementException, IOException { if (ownerPrincipal != null) { throw new UnsupportedOperationException("Creating dataset with owner is not supported"); } writeLock.lock(); try { if (instances.contains(datasetInstanceId.getParent(), datasetInstanceId)) { throw new InstanceConflictException(String.format("Dataset instance '%s' already exists.", datasetInstanceId)); } DatasetDefinition def = getDefinitionForType(datasetInstanceId.getParent(), datasetType); if (def == null) { throw new DatasetManagementException( String.format("Dataset type '%s' is neither registered in the '%s' namespace nor in the system namespace", datasetType, datasetInstanceId.getParent())); } DatasetSpecification spec = def.configure(datasetInstanceId.getEntityName(), props); spec = spec.setOriginalProperties(props); if (props.getDescription() != null) { spec = spec.setDescription(props.getDescription()); } def.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec, null).create(); instances.put(datasetInstanceId.getParent(), datasetInstanceId, spec); publishAudit(datasetInstanceId, AuditType.CREATE); LOG.info("Created dataset {} of type {}", datasetInstanceId, datasetType); } finally { writeLock.unlock(); } }
private static DatasetSpecification createType2Spec(String instanceName, String typeName, String description, DatasetProperties properties) { return new TestModule2().createDefinition(typeName).configure(instanceName, properties) .setOriginalProperties(properties).setDescription(description); }
.setOriginalProperties(props); if (props.getDescription() != null) { spec = spec.setDescription(props.getDescription());
.setOriginalProperties(props); if (props.getDescription() != null) { spec = spec.setDescription(props.getDescription());
@Override public DatasetCreationResponse update(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetProperties props, DatasetSpecification existing) throws Exception { DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider()); if (type == null) { throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta); } try { DatasetSpecification spec = type.reconfigure(datasetInstanceId.getEntityName(), props, existing); DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec); if (admin instanceof Updatable) { ((Updatable) admin).update(existing); } else { admin.create(); } if (spec.getDescription() == null && existing.getDescription() != null) { spec.setDescription(existing.getDescription()); } return new DatasetCreationResponse(spec, null); } catch (IncompatibleUpdateException e) { throw new ConflictException(e.getMessage()); } }
@Override public DatasetCreationResponse update(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetProperties props, DatasetSpecification existing) throws Exception { DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider()); if (type == null) { throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta); } try { DatasetSpecification spec = type.reconfigure(datasetInstanceId.getEntityName(), props, existing); DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec); if (admin instanceof Updatable) { ((Updatable) admin).update(existing); } else { admin.create(); } if (spec.getDescription() == null && existing.getDescription() != null) { spec.setDescription(existing.getDescription()); } return new DatasetCreationResponse(spec, null); } catch (IncompatibleUpdateException e) { throw new ConflictException(e.getMessage()); } }