Skip to content

Commit

Permalink
Comments addressed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Aug 25, 2024
1 parent 1e35ef9 commit bc8c0ad
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ public enum ErrorMessages {
"Error while retrieving Action basic info from the system."),
ERROR_WHILE_DECRYPTING_ACTION_ENDPOINT_AUTH_PROPERTIES("65012",
"Error while decrypting Action Endpoint Authentication properties",
"Error while decrypting Action Endpoint Authentication properties in the system."),
ERROR_ACTION_TYPE_MISMATCH("65013", "Given action type does not match",
"The action type of the retrieved action does not match with the given action type.");
"Error while decrypting Action Endpoint Authentication properties in the system.");

private final String code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static class Query {
"PROPERTY_NAME, PROPERTY_VALUE, TENANT_ID) VALUES (:ACTION_UUID;, :PROPERTY_NAME;, :PROPERTY_VALUE;, " +
":TENANT_ID;)";
public static final String GET_ACTION_BASIC_INFO_BY_ID = "SELECT TYPE, NAME, DESCRIPTION, STATUS FROM " +
"IDN_ACTION WHERE UUID = :UUID; AND TENANT_ID = :TENANT_ID;";
"IDN_ACTION WHERE TYPE = :TYPE; UUID = :UUID; AND TENANT_ID = :TENANT_ID;";
public static final String GET_ACTION_ENDPOINT_INFO_BY_ID = "SELECT PROPERTY_NAME, PROPERTY_VALUE FROM " +
"IDN_ACTION_ENDPOINT WHERE ACTION_UUID = :ACTION_UUID; AND TENANT_ID = :TENANT_ID;";
public static final String GET_ACTIONS_BASIC_INFO_BY_ACTION_TYPE = "SELECT UUID, TYPE, NAME, DESCRIPTION," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,9 @@ public Map<String, Integer> getActionsCountPerType(Integer tenantId) throws Acti
public Action getActionByActionId(String actionType, String actionId, Integer tenantId) throws ActionMgtException {

try (Connection dbConnection = IdentityDatabaseUtil.getDBConnection(false)) {
Action action = getActionBasicInfoById(dbConnection, actionId, tenantId);
Action action = getActionBasicInfoById(dbConnection, actionType, actionId, tenantId);
if (action != null) {
action.setEndpoint(getActionEndpointConfigById(dbConnection, actionId, tenantId));
if (action.getType() != null && StringUtils.equals(action.getType().getActionType(), actionType)) {
throw ActionManagementUtil.handleServerException(
ActionMgtConstants.ErrorMessages.ERROR_ACTION_TYPE_MISMATCH, null);
}
}

return action;
Expand Down Expand Up @@ -400,13 +396,14 @@ private void addEndpointProperties(Connection dbConnection, String actionId,
* @return Action Basic Info.
* @throws ActionMgtException If an error occurs while retrieving action basic info from the database.
*/
private Action getActionBasicInfoById(Connection dbConnection, String actionId, Integer tenantId)
private Action getActionBasicInfoById(Connection dbConnection, String actionType, String actionId, Integer tenantId)
throws ActionMgtException {

Action action = null;
try (NamedPreparedStatement statement = new NamedPreparedStatement(dbConnection,
ActionMgtSQLConstants.Query.GET_ACTION_BASIC_INFO_BY_ID)) {

statement.setString(ActionMgtSQLConstants.Column.ACTION_TYPE, actionType);
statement.setString(ActionMgtSQLConstants.Column.ACTION_UUID, actionId);
statement.setInt(ActionMgtSQLConstants.Column.TENANT_ID, tenantId);

Expand Down Expand Up @@ -570,7 +567,7 @@ private Action changeActionStatus(String actionType, String actionId, String sta
statement.executeUpdate();
IdentityDatabaseUtil.commitTransaction(dbConnection);

return getActionBasicInfoById(dbConnection, actionId, tenantId);
return getActionBasicInfoById(dbConnection, actionType, actionId, tenantId);
} catch (SQLException e) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Error while updating the Action Status to %s of Action type: %s in " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ private void updateCache(Action action, ActionCacheEntry entry, ActionTypeCacheK
actionsFromCache.add(action);
actionCacheByType.clearCacheEntry(cacheKey, tenantId);
actionCacheByType.addToCache(cacheKey, new ActionCacheEntry(actionsFromCache), tenantId);
} else {
actionCacheByType.addToCache(cacheKey, new ActionCacheEntry(
new ArrayList<>(Collections.singletonList(action))), tenantId);
}
}
}

0 comments on commit bc8c0ad

Please sign in to comment.