Merge branch 'master' into publisher-fix

billing-new-api
Pahansith Gunathilake 2 years ago
commit d5b2d8ac3b

@ -31,6 +31,7 @@ import io.entgra.application.mgt.core.util.DAOUtil;
import io.entgra.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.application.mgt.core.dao.impl.AbstractDAOImpl;
import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException;
import io.entgra.application.mgt.core.exception.UnexpectedServerErrorException; import io.entgra.application.mgt.core.exception.UnexpectedServerErrorException;
import io.entgra.application.mgt.core.util.Constants;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -149,7 +150,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
sql += "WHERE AP_APP.TENANT_ID = ? "; sql += "WHERE AP_APP.TENANT_ID = ? ";
if (StringUtils.isNotEmpty(filter.getAppType())) { if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) {
sql += "AND AP_APP.TYPE = ? "; sql += "AND AP_APP.TYPE = ? ";
} }
if (StringUtils.isNotEmpty(filter.getAppName())) { if (StringUtils.isNotEmpty(filter.getAppName())) {
@ -204,7 +205,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIndex = 1; int paramIndex = 1;
stmt.setInt(paramIndex++, tenantId); stmt.setInt(paramIndex++, tenantId);
if (StringUtils.isNotEmpty(filter.getAppType())) { if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) {
stmt.setString(paramIndex++, filter.getAppType()); stmt.setString(paramIndex++, filter.getAppType());
} }
if (StringUtils.isNotEmpty(filter.getAppName())) { if (StringUtils.isNotEmpty(filter.getAppName())) {

@ -26,6 +26,7 @@ import io.entgra.application.mgt.common.dto.ApplicationDTO;
import io.entgra.application.mgt.common.exception.DBConnectionException; import io.entgra.application.mgt.common.exception.DBConnectionException;
import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException;
import io.entgra.application.mgt.core.util.DAOUtil; import io.entgra.application.mgt.core.util.DAOUtil;
import io.entgra.application.mgt.core.util.Constants;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -94,7 +95,7 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|| StringUtils.isNotEmpty(filter.getAppReleaseType())) { || StringUtils.isNotEmpty(filter.getAppReleaseType())) {
sql += "LEFT JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "; sql += "LEFT JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID ";
} }
if (StringUtils.isNotEmpty(filter.getAppType())) { if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) {
sql += "AND AP_APP.TYPE = ? "; sql += "AND AP_APP.TYPE = ? ";
} }
if (StringUtils.isNotEmpty(filter.getAppName())) { if (StringUtils.isNotEmpty(filter.getAppName())) {
@ -145,7 +146,7 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIndex = 1; int paramIndex = 1;
if (StringUtils.isNotEmpty(filter.getAppType())) { if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) {
stmt.setString(paramIndex++, filter.getAppType()); stmt.setString(paramIndex++, filter.getAppType());
} }
if (StringUtils.isNotEmpty(filter.getAppName())) { if (StringUtils.isNotEmpty(filter.getAppName())) {

@ -25,6 +25,7 @@ import io.entgra.application.mgt.common.dto.ApplicationDTO;
import io.entgra.application.mgt.common.exception.DBConnectionException; import io.entgra.application.mgt.common.exception.DBConnectionException;
import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException;
import io.entgra.application.mgt.core.util.DAOUtil; import io.entgra.application.mgt.core.util.DAOUtil;
import io.entgra.application.mgt.core.util.Constants;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -93,7 +94,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
|| StringUtils.isNotEmpty(filter.getAppReleaseType())) { || StringUtils.isNotEmpty(filter.getAppReleaseType())) {
sql += "LEFT JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "; sql += "LEFT JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID ";
} }
if (StringUtils.isNotEmpty(filter.getAppType())) { if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) {
sql += "AND AP_APP.TYPE = ? "; sql += "AND AP_APP.TYPE = ? ";
} }
if (StringUtils.isNotEmpty(filter.getAppName())) { if (StringUtils.isNotEmpty(filter.getAppName())) {
@ -144,7 +145,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIndex = 1; int paramIndex = 1;
if (StringUtils.isNotEmpty(filter.getAppType())) { if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) {
stmt.setString(paramIndex++, filter.getAppType()); stmt.setString(paramIndex++, filter.getAppType());
} }
if (StringUtils.isNotEmpty(filter.getAppName())) { if (StringUtils.isNotEmpty(filter.getAppName())) {

@ -2932,7 +2932,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (!StringUtils.isEmpty(appType)) { if (!StringUtils.isEmpty(appType)) {
boolean isValidAppType = false; boolean isValidAppType = false;
for (ApplicationType applicationType : ApplicationType.values()) { for (ApplicationType applicationType : ApplicationType.values()) {
if (applicationType.toString().equalsIgnoreCase(appType)) { if (applicationType.toString().equalsIgnoreCase(appType) || Constants.ALL.equalsIgnoreCase(appType)) {
isValidAppType = true; isValidAppType = true;
break; break;
} }

@ -322,7 +322,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished); @QueryParam("is-published") boolean isPublished);
@POST @POST
@Path("/web-app") @Path("/web-app")
@ -366,7 +366,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished @QueryParam("is-published") boolean isPublished
); );
@POST @POST
@ -411,7 +411,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished @QueryParam("is-published") boolean isPublished
); );
@POST @POST
@ -457,7 +457,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished @QueryParam("is-published") boolean isPublished
); );
@POST @POST
@ -512,7 +512,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished @QueryParam("is-published") boolean isPublished
); );
@POST @POST
@ -567,7 +567,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished @QueryParam("is-published") boolean isPublished
); );
@POST @POST
@ -617,7 +617,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished @QueryParam("is-published") boolean isPublished
); );
@POST @POST
@ -672,7 +672,7 @@ public interface ApplicationManagementPublisherAPI {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished @QueryParam("is-published") boolean isPublished
); );
@PUT @PUT

@ -318,7 +318,7 @@ public interface SPApplicationService {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished); @QueryParam("is-published") boolean isPublished);
/** /**
* This method is used to register an APIM application for tenant domain. * This method is used to register an APIM application for tenant domain.
@ -345,7 +345,7 @@ public interface SPApplicationService {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished); @QueryParam("is-published") boolean isPublished);
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app") @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app")
@POST @POST
@ -369,7 +369,7 @@ public interface SPApplicationService {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished); @QueryParam("is-published") boolean isPublished);
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app") @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app")
@POST @POST
@ -392,5 +392,5 @@ public interface SPApplicationService {
name = "isPublished", name = "isPublished",
value = "Published state of the application" value = "Published state of the application"
) )
@QueryParam("isPublished") boolean isPublished); @QueryParam("is-published") boolean isPublished);
} }

@ -157,12 +157,12 @@ public interface ApplicationManagementPublisherAdminAPI {
@PathParam("appId") int applicatioId); @PathParam("appId") int applicatioId);
@DELETE @DELETE
@Path("/tags/{tagName}") @Path("/tags")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "DELETE",
value = "Delete application tag", value = "Delete application tag",
notes = "This will delete application tag", notes = "This will delete application tag",
tags = "Application Management", tags = "Application Management",
@ -185,10 +185,10 @@ public interface ApplicationManagementPublisherAdminAPI {
}) })
Response deleteTag( Response deleteTag(
@ApiParam( @ApiParam(
name = "tagName", name = "tag-name",
value = "Tag Name", value = "Tag Name",
required = true) required = true)
@PathParam("tagName") String tagName @QueryParam("tag-name") String tagName
); );
@POST @POST
@ -273,7 +273,7 @@ public interface ApplicationManagementPublisherAdminAPI {
); );
@DELETE @DELETE
@Path("/categories/{categoryName}") @Path("/categories")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
@ -301,10 +301,10 @@ public interface ApplicationManagementPublisherAdminAPI {
}) })
Response deleteCategory( Response deleteCategory(
@ApiParam( @ApiParam(
name = "categoryName", name = "category-name",
value = "Category Name", value = "Category Name",
required = true) required = true)
@PathParam("categoryName") String categoryName @QueryParam("category-name") String categoryName
); );
@PUT @PUT

@ -260,7 +260,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@PathParam("deviceType") String deviceTypeName, @PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId, @PathParam("appId") int appId,
EntAppReleaseWrapper entAppReleaseWrapper, EntAppReleaseWrapper entAppReleaseWrapper,
@QueryParam("isPublished") boolean isPublished) { @QueryParam("is-published") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validateEntAppReleaseCreatingRequest(entAppReleaseWrapper, deviceTypeName); applicationManager.validateEntAppReleaseCreatingRequest(entAppReleaseWrapper, deviceTypeName);
@ -284,7 +284,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createPubAppRelease( public Response createPubAppRelease(
@PathParam("deviceType") String deviceTypeName, @PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId, @PathParam("appId") int appId,
PublicAppReleaseWrapper publicAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) { PublicAppReleaseWrapper publicAppReleaseWrapper, @QueryParam("is-published") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
@ -312,7 +312,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Override @Override
public Response createWebAppRelease( public Response createWebAppRelease(
@PathParam("appId") int appId, @PathParam("appId") int appId,
WebAppReleaseWrapper webAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) { WebAppReleaseWrapper webAppReleaseWrapper, @QueryParam("is-published") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper); applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper);
@ -340,7 +340,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createCustomAppRelease( public Response createCustomAppRelease(
@PathParam("deviceType") String deviceTypeName, @PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId, @PathParam("appId") int appId,
CustomAppReleaseWrapper customAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) { CustomAppReleaseWrapper customAppReleaseWrapper, @QueryParam("is-published") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName); applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName);

@ -295,7 +295,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
@Override @Override
public Response createEntApp(@PathParam("identity-server-id") int identityServerId, public Response createEntApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app, @PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app,
@QueryParam("isPublished") boolean isPublished) { @QueryParam("is-published") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished); return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }
@ -304,7 +304,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
@Override @Override
public Response createPubApp(@PathParam("identity-server-id") int identityServerId, public Response createPubApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app, @PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app,
@QueryParam("isPublished") boolean isPublished) { @QueryParam("is-published") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished); return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }
@ -313,7 +313,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
@Override @Override
public Response createWebApp(@PathParam("identity-server-id") int identityServerId, public Response createWebApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app, @PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app,
@QueryParam("isPublished") boolean isPublished) { @QueryParam("is-published") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished); return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }
@ -322,7 +322,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
@Override @Override
public Response createCustomApp(@PathParam("identity-server-id") int identityServerId, public Response createCustomApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app, @PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app,
@QueryParam("isPublished") boolean isPublished) { @QueryParam("is-published") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished); return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }

@ -104,9 +104,9 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
@DELETE @DELETE
@Override @Override
@Consumes(MediaType.WILDCARD) @Consumes(MediaType.WILDCARD)
@Path("/tags/{tagName}") @Path("/tags")
public Response deleteTag( public Response deleteTag(
@PathParam("tagName") String tagName) { @QueryParam("tag-name") String tagName) {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
try { try {
applicationManager.deleteTag(tagName); applicationManager.deleteTag(tagName);
@ -169,9 +169,9 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
@DELETE @DELETE
@Override @Override
@Consumes(MediaType.WILDCARD) @Consumes(MediaType.WILDCARD)
@Path("/categories/{categoryName}") @Path("/categories")
public Response deleteCategory( public Response deleteCategory(
@PathParam("categoryName") String categoryName) { @QueryParam("category-name") String categoryName) {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
try { try {
applicationManager.deleteCategory(categoryName); applicationManager.deleteCategory(categoryName);

@ -50,11 +50,22 @@ public class RequestValidationUtil {
case "REMOVED": case "REMOVED":
case "BLOCKED": case "BLOCKED":
case "CREATED": case "CREATED":
case "CONFIGURED":
case "READY_TO_CONNECT":
case "RETURN_PENDING":
case "RETURNED":
case "DEFECTIVE":
case "WARRANTY_PENDING":
case "WARRANTY_SENT":
case "WARRANTY_REPLACED":
case "ASSIGNED":
break; break;
default: default:
String msg = "Invalid enrollment status type: " + status + ". \nValid status types " + String msg = "Invalid enrollment status type: " + status + ". \nValid status types " +
"are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + "are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " +
"DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED | CONFIGURED | READY_TO_CONNECT | " +
"RETURN_PENDING | RETURNED | DEFECTIVE | WARRANTY_PENDING | WARRANTY_SENT | " +
"WARRANTY_REPLACED | ASSIGNED |";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }

@ -51,7 +51,7 @@
<Bundle-Description>Entgra Logger Bundle</Bundle-Description> <Bundle-Description>Entgra Logger Bundle</Bundle-Description>
<Import-Package> <Import-Package>
io.entgra.device.mgt.extensions.logger, io.entgra.device.mgt.extensions.logger,
org.apache.commons.logging;version="[1.2,2) org.apache.commons.logging
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
io.entgra.device.mgt.extensions.logger.* io.entgra.device.mgt.extensions.logger.*

@ -24,57 +24,29 @@ import org.apache.commons.logging.Log;
public interface EntgraLogger extends Log { public interface EntgraLogger extends Log {
void info(String message); void info(Object object, LogContext logContext);
void info(String message, Throwable t); void info(Object object, Throwable t, LogContext logContext);
void info(String message, LogContext logContext); void debug(Object object, LogContext logContext);
void debug(String message); void debug(Object object, Throwable t, LogContext logContext);
void debug(String message, Throwable t); void error(Object object, LogContext logContext);
void debug(String message, LogContext logContext); void error(Object object, Throwable t, LogContext logContext);
void error(String message); void fatal(Object object, LogContext logContext);
void error(String message, Throwable t); void fatal(Object object, Throwable t, LogContext logContext);
void error(String message, LogContext logContext); void trace(Object object, LogContext logContext);
void error(String message, Throwable t, LogContext logContext); void trace(Object object, Throwable t, LogContext logContext);
void warn(String message); void warn(Object object, LogContext logContext);
void warn(String message, Throwable t); void warn(Object object, Throwable t, LogContext logContext);
void warn(String message, LogContext logContext);
void warn(String message, Throwable t, LogContext logContext);
void trace(String message);
void trace(String message, Throwable t);
void trace(String message, LogContext logContext);
void fatal(String message);
void fatal(String message, Throwable t);
void fatal(String message, LogContext logContext);
boolean isDebugEnabled();
boolean isErrorEnabled();
boolean isFatalEnabled();
boolean isInfoEnabled();
boolean isTraceEnabled();
boolean isWarnEnabled();
void clearLogContext(); void clearLogContext();

@ -54,6 +54,7 @@ import org.wso2.carbon.registry.core.session.UserRegistry;
import org.wso2.carbon.registry.resource.services.utils.ChangeRolePermissionsUtil; import org.wso2.carbon.registry.resource.services.utils.ChangeRolePermissionsUtil;
import org.wso2.carbon.user.api.*; import org.wso2.carbon.user.api.*;
import org.wso2.carbon.user.core.common.AbstractUserStoreManager; import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
import org.wso2.carbon.user.core.constants.UserCoreErrorConstants.ErrorMessages;
import org.wso2.carbon.user.mgt.UserRealmProxy; import org.wso2.carbon.user.mgt.UserRealmProxy;
import org.wso2.carbon.user.mgt.common.UIPermissionNode; import org.wso2.carbon.user.mgt.common.UIPermissionNode;
import org.wso2.carbon.user.mgt.common.UserAdminException; import org.wso2.carbon.user.mgt.common.UserAdminException;
@ -316,21 +317,31 @@ public class RoleManagementServiceImpl implements RoleManagementService {
entity("Role '" + roleInfo.getRoleName() + "' has " + "successfully been" entity("Role '" + roleInfo.getRoleName() + "' has " + "successfully been"
+ " added").build(); + " added").build();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String errorCode = "";
String errorMessage = e.getMessage();
if (errorMessage != null && !errorMessage.isEmpty() &&
errorMessage.contains(ErrorMessages.ERROR_CODE_ROLE_ALREADY_EXISTS.getCode())) {
errorCode = e.getMessage().split("-")[0].trim();
}
if (ErrorMessages.ERROR_CODE_ROLE_ALREADY_EXISTS.getCode().equals(errorCode)) {
String roleName = roleInfo.getRoleName().split("/")[1];
String msg = "Role already exists with name " + roleName + ".";
log.warn(msg);
return Response.status(Response.Status.CONFLICT).entity(msg).build();
} else {
String msg = "Error occurred while adding role '" + roleInfo.getRoleName() + "'"; String msg = "Error occurred while adding role '" + roleInfo.getRoleName() + "'";
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); }
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
String msg = "Error occurred while composing the URI at which the information of the newly created role " + String msg = "Error occurred while composing the URI at which the information of the newly created role " +
"can be retrieved"; "can be retrieved";
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
String msg = "Error occurred while encoding role name"; String msg = "Error occurred while encoding role name";
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }

@ -153,11 +153,21 @@ public class RequestValidationUtil {
case "REMOVED": case "REMOVED":
case "BLOCKED": case "BLOCKED":
case "CREATED": case "CREATED":
case "CONFIGURED":
case "READY_TO_CONNECT":
case "RETURN_PENDING":
case "RETURNED":
case "DEFECTIVE":
case "WARRANTY_PENDING":
case "WARRANTY_SENT":
case "WARRANTY_REPLACED":
case "ASSIGNED":
break; break;
default: default:
String msg = "Invalid enrollment status type: " + status + ". \nValid status types are " + String msg = "Invalid enrollment status type: " + status + ". \nValid status types are " +
"ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " +
"DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED | CONFIGURED | READY_TO_CONNECT | " +
"RETURN_PENDING | RETURNED | DEFECTIVE | WARRANTY_PENDING | WARRANTY_SENT | WARRANTY_REPLACED | ASSIGNED ";
log.error(msg); log.error(msg);
throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder() throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatus.SC_BAD_REQUEST) .setCode(HttpStatus.SC_BAD_REQUEST)
@ -175,12 +185,18 @@ public class RequestValidationUtil {
switch (ownership) { switch (ownership) {
case "BYOD": case "BYOD":
case "COPE": case "COPE":
case "WORK_PROFILE":
case "GOOGLE_ENTERPRISE":
case "COSU":
case "FULLY_MANAGED":
case "DEDICATED_DEVICE":
return; return;
default: default:
throw new InputValidationException( throw new InputValidationException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage( new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(
"Invalid ownership type received. " + "Invalid ownership type received. " +
"Valid ownership types are BYOD | COPE").build()); "Valid ownership types are BYOD | COPE " +
"WORK_PROFILE | GOOGLE_ENTERPRISE | COSU | FULLY_MANAGED | DEDICATED_DEVICE").build());
} }
} }

@ -34,7 +34,7 @@ public interface OTPManagementService {
* @throws OTPManagementException if error occurs while creating OTP token and storing tenant details. * @throws OTPManagementException if error occurs while creating OTP token and storing tenant details.
* @throws BadRequestException if found and incompatible payload to create OTP token. * @throws BadRequestException if found and incompatible payload to create OTP token.
*/ */
void sendUserVerifyingMail(OTPWrapper otpWrapper) throws OTPManagementException, DeviceManagementException; String sendUserVerifyingMail(OTPWrapper otpWrapper) throws OTPManagementException, DeviceManagementException;
/** /**
* Check the validity of the OTP * Check the validity of the OTP

@ -26,6 +26,7 @@ import java.util.Date;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.el.lang.ELSupport;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceBilling; import org.wso2.carbon.device.mgt.common.DeviceBilling;
@ -211,6 +212,24 @@ public final class DeviceManagementDAOUtil {
return enrolmentInfos.get(EnrolmentInfo.Status.SUSPENDED); return enrolmentInfos.get(EnrolmentInfo.Status.SUSPENDED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.BLOCKED)) { } else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.BLOCKED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.BLOCKED); return enrolmentInfos.get(EnrolmentInfo.Status.BLOCKED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.CONFIGURED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.CONFIGURED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.READY_TO_CONNECT)) {
return enrolmentInfos.get(EnrolmentInfo.Status.READY_TO_CONNECT);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.RETURN_PENDING)) {
return enrolmentInfos.get(EnrolmentInfo.Status.RETURN_PENDING);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.RETURNED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.RETURNED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.DEFECTIVE)) {
return enrolmentInfos.get(EnrolmentInfo.Status.DEFECTIVE);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.WARRANTY_PENDING)) {
return enrolmentInfos.get(EnrolmentInfo.Status.WARRANTY_PENDING);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.WARRANTY_SENT)) {
return enrolmentInfos.get(EnrolmentInfo.Status.WARRANTY_SENT);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.WARRANTY_REPLACED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.WARRANTY_REPLACED);
} else if (enrolmentInfos.containsKey(EnrolmentInfo.Status.ASSIGNED)) {
return enrolmentInfos.get(EnrolmentInfo.Status.ASSIGNED);
} }
return enrolmentInfo; return enrolmentInfo;
} }

@ -78,18 +78,19 @@ public class OTPManagementServiceImpl implements OTPManagementService {
} }
@Override @Override
public void sendUserVerifyingMail(OTPWrapper otpWrapper) throws OTPManagementException, DeviceManagementException { public String sendUserVerifyingMail(OTPWrapper otpWrapper) throws OTPManagementException, DeviceManagementException {
Tenant tenant = validateTenantCreatingDetails(otpWrapper); Tenant tenant = validateTenantCreatingDetails(otpWrapper);
OneTimePinDTO oneTimePinDTO = createOneTimePin(otpWrapper.getEmail(), otpWrapper.getEmailType(), OneTimePinDTO oneTimePinDTO = createOneTimePin(otpWrapper.getEmail(), otpWrapper.getEmailType(),
otpWrapper.getUsername(), tenant, -1234); otpWrapper.getUsername(), tenant, -1234);
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
this.otpManagementDAO.addOTPData(Collections.singletonList(oneTimePinDTO)); this.otpManagementDAO.addOTPData(Collections.singletonList(oneTimePinDTO));
Properties props = new Properties(); // Properties props = new Properties();
props.setProperty("first-name", tenant.getAdminFirstName()); // props.setProperty("first-name", tenant.getAdminFirstName());
props.setProperty("otp-token", oneTimePinDTO.getOtpToken()); // props.setProperty("otp-token", oneTimePinDTO.getOtpToken());
sendMail(props, tenant.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); // sendMail(props, tenant.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
return oneTimePinDTO.getOtpToken();
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
String msg = "Error occurred while disabling AutoCommit."; String msg = "Error occurred while disabling AutoCommit.";
log.error(msg, e); log.error(msg, e);

@ -47,6 +47,7 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException;
import org.wso2.carbon.device.mgt.common.GroupPaginationRequest; import org.wso2.carbon.device.mgt.common.GroupPaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.exceptions.TrackerAlreadyExistException;
import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
@ -140,13 +141,16 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
if (HttpReportingUtil.isTrackerEnabled()){ if (HttpReportingUtil.isTrackerEnabled()){
existingGroup = this.groupDAO.getGroup(deviceGroup.getName(), tenantId); existingGroup = this.groupDAO.getGroup(deviceGroup.getName(), tenantId);
int groupId = existingGroup.getGroupId(); int groupId = existingGroup.getGroupId();
try {
DeviceManagementDataHolder.getInstance().getDeviceAPIClientService() DeviceManagementDataHolder.getInstance().getDeviceAPIClientService()
.addGroup(deviceGroup, groupId, tenantId); .addGroup(deviceGroup, groupId, tenantId);
} catch (TrackerAlreadyExistException e) {
throw new GroupAlreadyExistException("Group exist with name " + deviceGroup.getName());
} }
// add a group if not exist in traccar starts } else {
throw new GroupAlreadyExistException("Group exist with name " + deviceGroup.getName()); throw new GroupAlreadyExistException("Group exist with name " + deviceGroup.getName());
} }
}
} catch (GroupManagementDAOException e) { } catch (GroupManagementDAOException e) {
GroupManagementDAOFactory.rollbackTransaction(); GroupManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while adding deviceGroup '" + deviceGroup.getName() + "' to database."; String msg = "Error occurred while adding deviceGroup '" + deviceGroup.getName() + "' to database.";

@ -648,7 +648,7 @@ public class TraccarClientFactory {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
trackerGroupInfo = trackerDAO.getTrackerGroup(groupId, tenantId); trackerGroupInfo = trackerDAO.getTrackerGroup(groupId, tenantId);
if (trackerGroupInfo != null) { if (trackerGroupInfo != null) {
String msg = "The group already exit"; String msg = "The group already exists in Traccar.";
log.error(msg); log.error(msg);
throw new TrackerAlreadyExistException(msg); throw new TrackerAlreadyExistException(msg);
} }

@ -555,7 +555,7 @@ public class TraccarClientImpl implements TraccarClient {
TrackerManagementDAOFactory.openConnection(); TrackerManagementDAOFactory.openConnection();
trackerGroupInfo = trackerDAO.getTrackerGroup(groupId, tenantId); trackerGroupInfo = trackerDAO.getTrackerGroup(groupId, tenantId);
if (trackerGroupInfo != null) { if (trackerGroupInfo != null) {
String msg = "The group already exit"; String msg = "The group already exists in Traccar.";
log.error(msg); log.error(msg);
throw new TrackerAlreadyExistException(msg); throw new TrackerAlreadyExistException(msg);
} }

@ -166,7 +166,7 @@ public class OTPInvokerHandler extends HttpServlet {
throws IOException { throws IOException {
String schema = req.getScheme(); String schema = req.getScheme();
apiEndpoint = schema + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) apiEndpoint = schema + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(schema); + HandlerConstants.COLON + HandlerUtil.getCorePort(schema);
if (StringUtils.isBlank(req.getHeader(HandlerConstants.OTP_HEADER))) { if (StringUtils.isBlank(req.getHeader(HandlerConstants.OTP_HEADER))) {
log.error("Unauthorized, Please provide OTP token."); log.error("Unauthorized, Please provide OTP token.");

@ -57,8 +57,8 @@ CREATE TABLE IF NOT EXISTS AP_APP_REVIEW(
COMMENT TEXT NOT NULL, COMMENT TEXT NOT NULL,
ROOT_PARENT_ID INTEGER NOT NULL, ROOT_PARENT_ID INTEGER NOT NULL,
IMMEDIATE_PARENT_ID INTEGER NOT NULL, IMMEDIATE_PARENT_ID INTEGER NOT NULL,
CREATED_AT TIMESTAMP NOT NULL, CREATED_AT BIGINT NOT NULL,
MODIFIED_AT TIMESTAMP NOT NULL, MODIFIED_AT BIGINT NOT NULL,
RATING INTEGER NULL, RATING INTEGER NULL,
USERNAME VARCHAR(45) NOT NULL, USERNAME VARCHAR(45) NOT NULL,
ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE, ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE,

@ -58,8 +58,8 @@ CREATE TABLE AP_APP_REVIEW(
COMMENT VARCHAR(max) NOT NULL, COMMENT VARCHAR(max) NOT NULL,
ROOT_PARENT_ID INTEGER NOT NULL, ROOT_PARENT_ID INTEGER NOT NULL,
IMMEDIATE_PARENT_ID INTEGER NOT NULL, IMMEDIATE_PARENT_ID INTEGER NOT NULL,
CREATED_AT DATETIME2(0) NOT NULL, CREATED_AT BIGINT NOT NULL,
MODIFIED_AT DATETIME2(0) NOT NULL, MODIFIED_AT BIGINT NOT NULL,
RATING INTEGER NULL, RATING INTEGER NULL,
USERNAME VARCHAR(45) NOT NULL, USERNAME VARCHAR(45) NOT NULL,
ACTIVE_REVIEW BIT NOT NULL DEFAULT 1, ACTIVE_REVIEW BIT NOT NULL DEFAULT 1,

@ -63,8 +63,8 @@ CREATE TABLE IF NOT EXISTS AP_APP_REVIEW(
COMMENT TEXT NOT NULL, COMMENT TEXT NOT NULL,
ROOT_PARENT_ID INTEGER NOT NULL, ROOT_PARENT_ID INTEGER NOT NULL,
IMMEDIATE_PARENT_ID INTEGER NOT NULL, IMMEDIATE_PARENT_ID INTEGER NOT NULL,
CREATED_AT TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL, CREATED_AT BIGINT NOT NULL,
MODIFIED_AT TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL, MODIFIED_AT BIGINT NOT NULL,
RATING INTEGER NULL, RATING INTEGER NULL,
USERNAME VARCHAR(45) NOT NULL, USERNAME VARCHAR(45) NOT NULL,
ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE, ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE,

Loading…
Cancel
Save