use of org.restlet.resource.Put in project pinot by linkedin.
the class PinotTenantRestletResource method put.
/*
* For tenant update
*/
@Override
@Put("json")
public Representation put(Representation entity) {
StringRepresentation presentation;
try {
final Tenant tenant = _objectMapper.readValue(ByteStreams.toByteArray(entity.getStream()), Tenant.class);
presentation = updateTenant(tenant);
} catch (final Exception e) {
presentation = exceptionToStringRepresentation(e);
LOGGER.error("Caught exception while updating tenant ", e);
ControllerRestApplication.getControllerMetrics().addMeteredGlobalValue(ControllerMeter.CONTROLLER_TABLE_TENANT_UPDATE_ERROR, 1L);
setStatus(Status.SERVER_ERROR_INTERNAL);
}
return presentation;
}
use of org.restlet.resource.Put in project OpenAM by OpenRock.
the class ResourceSetRegistrationEndpoint method updateResourceSet.
@Put
public Representation updateResourceSet(JsonRepresentation entity) throws NotFoundException, ServerException, BadRequestException {
if (!isConditionalRequest()) {
throw new ResourceException(512, "precondition_failed", "Require If-Match header to update Resource Set", null);
}
final Map<String, Object> resourceSetDescriptionAttributes = validator.validate(toMap(entity));
final String resourceSetId = getResourceSetId();
ResourceSetStore store = providerSettingsFactory.get(requestFactory.create(getRequest())).getResourceSetStore();
ResourceSetDescription resourceSetDescription = store.read(resourceSetId, getResourceOwnerId()).update(resourceSetDescriptionAttributes);
JsonValue labels = resourceSetDescription.getDescription().get(OAuth2Constants.ResourceSets.LABELS);
resourceSetDescription.getDescription().remove(OAuth2Constants.ResourceSets.LABELS);
store.update(resourceSetDescription);
if (labels.isNotNull()) {
resourceSetDescription.getDescription().add(OAuth2Constants.ResourceSets.LABELS, labels.asSet());
} else {
resourceSetDescription.getDescription().add(OAuth2Constants.ResourceSets.LABELS, new HashSet<String>());
}
labelRegistration.updateLabelsForExistingResourceSet(resourceSetDescription);
return createJsonResponse(resourceSetDescription, false, true);
}
Aggregations