use of org.entando.entando.aps.system.services.api.model.ApiMethod.HttpMethod in project entando-core by entando.
the class ApiCatalogDAO method loadApiStatus.
@Override
public void loadApiStatus(Map<String, ApiResource> resources) {
Connection conn = null;
PreparedStatement stat = null;
ResultSet res = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
stat = conn.prepareStatement(LOAD_API_STATUS);
// resourcecode, httpmethod, isactive, authenticationrequired, authorizationrequired
// "SELECT method, isactive FROM apicatalog_status";
res = stat.executeQuery();
while (res.next()) {
String resourceCode = res.getString("resourcecode");
String httpMethodString = res.getString("httpmethod");
ApiMethod.HttpMethod httpMethod = Enum.valueOf(ApiMethod.HttpMethod.class, httpMethodString.toUpperCase());
ApiMethod method = null;
ApiResource resource = resources.get(resourceCode);
if (null != resource) {
method = resource.getMethod(httpMethod);
}
if (null == method) {
this.resetApiStatus(resourceCode, httpMethod, conn);
continue;
}
boolean active = (res.getInt("isactive") == 1);
method.setStatus(active);
boolean authenticationRequired = (res.getInt("authenticationrequired") == 1);
method.setRequiredAuth(authenticationRequired);
String requiredPermission = res.getString("authorizationrequired");
if (null != requiredPermission && requiredPermission.trim().length() > 0) {
method.setRequiredPermission(requiredPermission);
} else {
method.setRequiredPermission(null);
}
boolean hidden = (res.getInt("ishidden") == 1);
method.setHidden(hidden);
}
conn.commit();
} catch (Throwable t) {
this.executeRollback(conn);
_logger.error("Error while loading api status", t);
throw new RuntimeException("Error while loading api status", t);
} finally {
closeDaoResources(res, stat, conn);
}
}
Aggregations