@Override public long addMetadataEntity(Entity entity) throws JasDBStorageException { return writer.writeRecord(SimpleEntity.toJson(entity), null); }
updatedRecordPointer = writeRecord(recordContents, null); } else { LOG.debug("Record update for: {} not possible, reinstering at new position", recordPointer); updatedRecordPointer = writeRecord(recordContents, null);
private Instance addInstance(String instanceId, String path) throws JasDBStorageException { if(!instanceMetaMap.containsKey(instanceId)) { InstanceMeta instance = new InstanceMeta(instanceId, path); SimpleEntity entity = InstanceMeta.toEntity(instance); String jsonData = SimpleEntity.toJson(entity); long recordPointer = writer.writeRecord(jsonData, null); instanceMetaMap.put(instanceId, new MetaWrapper<>(instance, recordPointer)); return instance; } else { throw new JasDBStorageException("Unable to create instance, already exists"); } }
@Override public void updateInstance(Instance instance) throws JasDBStorageException { if(instanceMetaMap.containsKey(instance.getInstanceId())) { SimpleEntity entity = InstanceMeta.toEntity(instance); String jsonData = SimpleEntity.toJson(entity); removeInstance(instance.getInstanceId()); long recordPointer = writer.writeRecord(jsonData, null); instanceMetaMap.put(instance.getInstanceId(), new MetaWrapper<>(instance, recordPointer)); } else { throw new JasDBStorageException("Unable to update instance, does not exists"); } }
@Override public void addBag(Bag bag) throws JasDBStorageException { if(instanceMetaMap.containsKey(bag.getInstanceId())) { String bagId = getBagKey(bag.getInstanceId(), bag.getName()); if(!bagMetaMap.containsKey(bagId)) { SimpleEntity entity = BagMeta.toEntity(bag); String bagData = SimpleEntity.toJson(entity); long recordPointer = writer.writeRecord(bagData, null); bagMetaMap.put(bagId, new MetaWrapper<>(bag, recordPointer)); } else { throw new JasDBStorageException("Unable to add bag: " + bag.getName() + ", already exists"); } } else { throw new JasDBStorageException("Unable to create bag, instance: " + bag.getInstanceId() + " does not exist"); } }