use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_REPLACE_SECRET in project carbon-identity-framework by wso2.
the class SecretDAOImpl method replaceSecret.
@Override
public void replaceSecret(Secret secret) throws SecretManagementException {
Timestamp currentTime = new java.sql.Timestamp(new Date().getTime());
SecretType secretType = getSecretTypeByName(secret.getSecretType());
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
try {
Timestamp createdTime = jdbcTemplate.withTransaction(template -> {
updateSecretMetadata(template, secret, secretType, currentTime);
return getCreatedTimeInResponse(secret, secretType.getId());
});
secret.setLastModified(currentTime.toInstant().toString());
if (createdTime != null) {
secret.setCreatedTime(createdTime.toInstant().toString());
}
secret.setSecretType(secretType.getName());
} catch (TransactionException e) {
if (e.getCause() instanceof SecretManagementException) {
throw (SecretManagementException) e.getCause();
}
throw handleServerException(ERROR_CODE_REPLACE_SECRET, secret.getSecretName(), e);
}
}
Aggregations