use of io.apiman.manager.api.beans.gateways.UpdateGatewayBean in project apiman by apiman.
the class GatewayResourceImpl method update.
/**
* @see IGatewayResource#update(java.lang.String, io.apiman.manager.api.beans.gateways.UpdateGatewayBean)
*/
@Override
public void update(String gatewayId, UpdateGatewayBean gatewayToUpdate) throws GatewayNotFoundException, NotAuthorizedException {
securityContext.checkAdminPermissions();
try {
Date now = new Date();
GatewayBean gateway = storage.getGateway(gatewayId);
if (gateway == null) {
throw ExceptionFactory.gatewayNotFoundException(gatewayId);
}
gateway.setModifiedBy(securityContext.getCurrentUser());
gateway.setModifiedOn(now);
if (gatewayToUpdate.getDescription() != null)
gateway.setDescription(gatewayToUpdate.getDescription());
if (gatewayToUpdate.getType() != null)
gateway.setType(gatewayToUpdate.getType());
if (gatewayToUpdate.getConfiguration() != null)
gateway.setConfiguration(gatewayToUpdate.getConfiguration());
encryptPasswords(gateway);
storage.updateGateway(gateway);
// $NON-NLS-1$
LOGGER.debug(String.format("Successfully updated gateway %s: %s", gateway.getName(), gateway));
} catch (AbstractRestException e) {
throw e;
} catch (Exception e) {
throw new SystemErrorException(e);
}
}
Aggregations