use of org.hisp.dhis.datastore.DatastoreEntry in project dhis2-core by dhis2.
the class DefaultOrgUnitProfileService method saveOrgUnitProfile.
@Override
@Transactional
public void saveOrgUnitProfile(OrgUnitProfile profile) {
DatastoreEntry entry = new DatastoreEntry(ORG_UNIT_PROFILE_KEY, ORG_UNIT_PROFILE_NAMESPACE);
try {
entry.setValue(jsonMapper.writeValueAsString(profile));
dataStore.saveOrUpdateEntry(entry);
} catch (JsonProcessingException e) {
log.error(DebugUtils.getStackTrace(e));
throw new IllegalArgumentException(String.format("Can't serialize OrgUnitProfile: %s", profile));
}
}
use of org.hisp.dhis.datastore.DatastoreEntry in project dhis2-core by dhis2.
the class DatastoreControllerTest method testAddKeyJsonValue_Encrypt.
@Test
void testAddKeyJsonValue_Encrypt() {
assertStatus(HttpStatus.CREATED, POST("/dataStore/pets/cat?encrypt=true", "{}"));
// there is no way to see in the exposed metadata that a value is
// encrypted, user service
DatastoreEntry entry = service.getEntry("pets", "cat");
assertTrue(entry.getEncrypted());
assertNull(entry.getJbPlainValue());
assertNotNull(entry.getEncryptedValue());
}
use of org.hisp.dhis.datastore.DatastoreEntry in project dhis2-core by dhis2.
the class DatastoreController method deleteKeyJsonValue.
/**
* Delete a key from the given namespace.
*/
@ResponseBody
@DeleteMapping(value = "/{namespace}/{key}", produces = APPLICATION_JSON_VALUE)
public WebMessage deleteKeyJsonValue(@PathVariable String namespace, @PathVariable String key) throws Exception {
DatastoreEntry entry = getExistingEntry(namespace, key);
service.deleteEntry(entry);
return ok(String.format("Key '%s' deleted from namespace '%s'", key, namespace));
}
use of org.hisp.dhis.datastore.DatastoreEntry in project dhis2-core by dhis2.
the class DatastoreController method updateKeyJsonValue.
/**
* Update a key in the given namespace.
*/
@ResponseBody
@PutMapping(value = "/{namespace}/{key}", produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public WebMessage updateKeyJsonValue(@PathVariable String namespace, @PathVariable String key, @RequestBody String value) throws Exception {
DatastoreEntry entry = getExistingEntry(namespace, key);
entry.setValue(value);
service.updateEntry(entry);
return ok(String.format("Key updated: '%s'", key));
}
Aggregations