Skip to content

Commit

Permalink
Fix Pagination (#113)
Browse files Browse the repository at this point in the history
* basic auth fix

* sparql query check

* refactor fix

* changes next release

* en translation

* updated version

* removed quartz env property and fixed orion test bearer

* Updated Log4j2 to 2.15.0

* change log

* docker-compose updates

* Cookie secured and NGSI Connector subscription url management

* updated docker-compose

* updated docker-compose

* updated version

* fix catalogue pagination
  • Loading branch information
robcalla committed Feb 11, 2022
1 parent a108433 commit c76e51d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 20 deletions.
18 changes: 9 additions & 9 deletions Idra/src/main/java/it/eng/idra/api/AdministrationApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1349,11 +1349,11 @@ public Response loginGet(@DefaultValue("") @QueryParam("code") String code,
if (token != null && ((String) token).trim().length() > 0) {
return Response.seeOther(URI.create(
PropertyManager.getProperty(IdraProperty.IDRA_CATALOGUE_BASEPATH)))
.cookie(new NewCookie("loggedin", (String) token, "/", "", "comment", 100, false))
.cookie(new NewCookie("loggedin", (String) token, "/", "", "comment", 100, true))
.cookie(new NewCookie("refresh_token", refreshToken,
"/", "", "comment", 100, false))
"/", "", "comment", 100, true))
.cookie(new NewCookie("username", info.getDisplayName(),
"/", "", "comment", 100, false)).build();
"/", "", "comment", 100, true)).build();
} else {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
Expand All @@ -1374,11 +1374,11 @@ public Response loginGet(@DefaultValue("") @QueryParam("code") String code,
if (token != null && ((String) token).trim().length() > 0) {
return Response.seeOther(URI.create(
PropertyManager.getProperty(IdraProperty.IDRA_CATALOGUE_BASEPATH)))
.cookie(new NewCookie("loggedin", (String) token, "/", "", "comment", 100, false))
.cookie(new NewCookie("loggedin", (String) token, "/", "", "comment", 100, true))
.cookie(new NewCookie("refresh_token", refreshToken,
"/", "", "comment", 100, false))
"/", "", "comment", 100, true))
.cookie(new NewCookie("username", keycloakUser.getPreferredUsername(),
"/", "", "comment", 100, false)).build();
"/", "", "comment", 100, true)).build();
} else {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
Expand Down Expand Up @@ -1464,10 +1464,10 @@ public Response loginPost(@Context HttpServletRequest httpRequest) {
if (token != null && ((String) token).trim().length() > 0) {
return Response.seeOther(URI.create(
PropertyManager.getProperty(IdraProperty.IDRA_CATALOGUE_BASEPATH)))
.cookie(new NewCookie("loggedin", (String) token, "/", "", "comment", 100, false))
.cookie(new NewCookie("refresh_token", refreshToken, "/", "", "comment", 100, false))
.cookie(new NewCookie("loggedin", (String) token, "/", "", "comment", 100, true))
.cookie(new NewCookie("refresh_token", refreshToken, "/", "", "comment", 100, true))
.cookie(new NewCookie("username", keycloakUser.getPreferredUsername(),
"/", "", "comment", 100, false)).build();
"/", "", "comment", 100, true)).build();
} else {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
Expand Down
9 changes: 5 additions & 4 deletions Idra/src/main/java/it/eng/idra/api/ClientApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,10 @@ public Response getOdmsCatalogues(
}

// TODO: enable pagination

int count = nodes.size();
JSONObject result = new JSONObject();
result.put("count", count);

int row = CommonUtil.ROWSDEFAULT;
int off = CommonUtil.OFFSETDEFAULT;

Expand All @@ -1308,10 +1311,8 @@ public Response getOdmsCatalogues(
}
nodes = nodes.subList(off, row);
}
int count = nodes.size();

JSONArray array = new JSONArray(GsonUtil.obj2JsonWithExclude(nodes, GsonUtil.nodeListType));
JSONObject result = new JSONObject();
result.put("count", count);
result.put("catalogues", array);
System.gc();
return Response.status(Response.Status.OK).entity(result.toString()).build();
Expand Down
4 changes: 3 additions & 1 deletion Idra/src/main/java/it/eng/idra/beans/IdraProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ public enum IdraProperty {
/** The preview timeout. */
PREVIEW_TIMEOUT("idra.preview.timeout"),
/** The preview max size. */
PREVIEW_MAX_SIZE("idra.preview.fileSize");
PREVIEW_MAX_SIZE("idra.preview.fileSize"),
/** The server base url. */
IDRA_SERVER_BASEURL("idra.server.baseurl");

/** The text. */
private final String text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;

import it.eng.idra.beans.IdraProperty;
import it.eng.idra.beans.dcat.DcatDataset;
import it.eng.idra.beans.dcat.DcatDistribution;
import it.eng.idra.beans.dcat.DctLicenseDocument;
Expand All @@ -34,6 +36,7 @@
import it.eng.idra.beans.odms.OdmsSynchronizationResult;
import it.eng.idra.utils.CommonUtil;
import it.eng.idra.utils.GsonUtil;
import it.eng.idra.utils.PropertyManager;
import it.eng.idra.utils.restclient.RestClient;
import it.eng.idra.utils.restclient.RestClientImpl;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -62,6 +65,10 @@
*/
public class NgsiLdCbDcatConnector implements IodmsConnector {

/** The subscription base callback url. */
private static String subscriptionBaseUrl =
PropertyManager.getProperty(IdraProperty.IDRA_SERVER_BASEURL);

/** The node id. */
private String nodeId;

Expand Down Expand Up @@ -589,7 +596,10 @@ public void subscribeToTheContextBroker() throws Exception {
if (status != 200) {
logger.info("Subscription NOT present, creation");

String endpoint = "http://host.docker.internal:8080/Idra/api/v1/client" + "/notification/" + node.getId() + "/" + node.getApiKey() + "/push";
String endpoint = (subscriptionBaseUrl.endsWith("/")
? subscriptionBaseUrl : subscriptionBaseUrl + "/")
+ "Idra/api/v1/client" + "/notification/" + node.getId()
+ "/" + node.getApiKey() + "/push";

String req = "{"
+ "\"description\": \"Notify me on the creation or modification of a Dataset\","
Expand Down
7 changes: 5 additions & 2 deletions Idra/src/main/resources/configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# along with this program. If not, see http://www.gnu.org/licenses/.
#-------------------------------------------------------------------------------
################# PLATFORM API ###################################
idra.version=2.3.3
idra.release.timestamp=2021-11-13T17:00:00Z
idra.version=3.0.0
idra.release.timestamp=2022-02-08T16:00:00Z

################# PERSISTENCE MANAGER CONFIGURATION ##############
#&rewriteBatchedStatements\=true
Expand Down Expand Up @@ -126,3 +126,6 @@ idm.admin.role.name=Admin
#The name of the deployed application to be redirected after login
#Leave blank if the application is deployed as ROOT e.g. in tomcat
idra.catalogue.basepath=/IdraPortal

#Used to create subscription for the Orion NGSI-LD Connector
idra.server.baseurl=http://localhost:8080
6 changes: 3 additions & 3 deletions IdraPortal/src/main/webapp/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
loginType=config["idra.authentication.method"];

if (loginType === "FIWARE" || loginType === "KEYCLOAK"){
$cookies.put('destinationUrl', $window.location.hash,{"path":"/"});
$cookies.put('destinationUrl', $window.location.hash,{"path":"/","secure":true});
$('#loginform').submit();
}else{
$window.location.assign('#/login');
Expand Down Expand Up @@ -563,8 +563,8 @@
$rootScope.stopSpin();
$rootScope.token=value.data;
$rootScope.loggedUsername = $scope.username;
$cookies.put('loggedin', value.data,{"path":"/"});
$cookies.put('username', $scope.username,{"path":"/"});
$cookies.put('loggedin', value.data,{"path":"/","secure":true});
$cookies.put('username', $scope.username,{"path":"/","secure":true});

$window.location.assign('#/metadata');
}, function(value){
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ services :
- idm.redirecturi=http://IDRA_HOST/Idra/api/v1/administration/login
- idm.logout.callback=http://IDRA_HOST/IdraPortal
- idm.admin.role.name=Admin
- idra.server.baseurl=<IDRA_PROTOCOL>://<IDRA_HOST>
- JAVA_OPTS=-Xms1024m -Xmx3g -XX:PermSize=1024m -XX:MaxPermSize=2048m
secrets:
- my_secret_data
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ services :
- idm.client.secret=
- idm.redirecturi=http://IDRA_HOST/Idra/api/v1/administration/login
- idm.logout.callback=http://IDRA_HOST/IdraPortal
- idra.server.baseurl=<IDRA_PROTOCOL>://<IDRA_HOST>
- idm.admin.role.name=Admin
- DATALET_ENABLED=true
- DATALET_URL=http://localhost:80/deep/deep-components/demo.html
Expand Down

0 comments on commit c76e51d

Please sign in to comment.