From 12d46550e67fb1d1f9875e76711b35e82ea3f0ed Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Wed, 17 Apr 2019 15:40:22 +0530 Subject: [PATCH] Fix requested changes in the review --- .../service/api/UserManagementService.java | 2 +- .../impl/UserManagementServiceImpl.java | 6 ++--- .../device/mgt/jaxrs/util/Constants.java | 1 + .../mgt/common/UserNotFoundException.java | 25 +++++++++---------- .../service/api/UserManagementService.java | 2 +- .../impl/UserManagementServiceImpl.java | 6 ++--- .../device/mgt/jaxrs/util/Constants.java | 1 + 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java index bfe829b610a..6000845829f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java @@ -933,7 +933,7 @@ public interface UserManagementService { Response validateUser(Credential credential); @GET - @Path("/activities") + @Path("/device/activities") @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index 7bfd934bb19..329c5599032 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -807,7 +807,7 @@ public class UserManagementServiceImpl implements UserManagementService { @GET @Override - @Path("/activities") + @Path("/device/activities") public Response getActivities( @QueryParam("since") String since, @QueryParam("offset") int offset, @@ -825,7 +825,7 @@ public class UserManagementServiceImpl implements UserManagementService { RequestValidationUtil.validatePaginationParameters(offset, limit); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { Date ifSinceDate; - SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); + SimpleDateFormat format = new SimpleDateFormat(Constants.DEFAULT_SIMPLE_DATE_FORMAT); try { ifSinceDate = format.parse(ifModifiedSince); } catch (ParseException e) { @@ -837,7 +837,7 @@ public class UserManagementServiceImpl implements UserManagementService { timestamp = ifModifiedSinceTimestamp / 1000; } else if (since != null && !since.isEmpty()) { Date sinceDate; - SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); + SimpleDateFormat format = new SimpleDateFormat(Constants.DEFAULT_SIMPLE_DATE_FORMAT); try { sinceDate = format.parse(since); } catch (ParseException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java index 728c461c7bd..4525cdd38dd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java @@ -30,6 +30,7 @@ public class Constants { public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; + public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static final int DEFAULT_PAGE_LIMIT = 50; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/UserNotFoundException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/UserNotFoundException.java index a428db7fbac..640e28b7527 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/UserNotFoundException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/UserNotFoundException.java @@ -1,21 +1,20 @@ package org.wso2.carbon.device.mgt.common; /* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ public class UserNotFoundException extends Exception { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java index df2bfa7128d..3167ff572f8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java @@ -807,7 +807,7 @@ public interface UserManagementService { @Valid EnrollmentInvitation enrollmentInvitation); @GET - @Path("/activities") + @Path("/device/activities") @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index 9da9f9289e6..7d2a02fc31d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -644,7 +644,7 @@ public class UserManagementServiceImpl implements UserManagementService { @GET @Override - @Path("/activities") + @Path("/device/activities") public Response getActivities( @QueryParam("since") String since, @QueryParam("offset") int offset, @@ -662,7 +662,7 @@ public class UserManagementServiceImpl implements UserManagementService { RequestValidationUtil.validatePaginationParameters(offset, limit); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { Date ifSinceDate; - SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); + SimpleDateFormat format = new SimpleDateFormat(Constants.DEFAULT_SIMPLE_DATE_FORMAT); try { ifSinceDate = format.parse(ifModifiedSince); } catch (ParseException e) { @@ -674,7 +674,7 @@ public class UserManagementServiceImpl implements UserManagementService { timestamp = ifModifiedSinceTimestamp / 1000; } else if (since != null && !since.isEmpty()) { Date sinceDate; - SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); + SimpleDateFormat format = new SimpleDateFormat(Constants.DEFAULT_SIMPLE_DATE_FORMAT); try { sinceDate = format.parse(since); } catch (ParseException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java index 31a83cf03d2..dd942c2aae0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java @@ -30,6 +30,7 @@ public class Constants { public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; + public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static final int DEFAULT_PAGE_LIMIT = 50;