Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sandbox example of User Tenant Service #41

Merged
merged 8 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public final class CommonConstants {
"com.sourcefuse.jarc.core.models";
public static final String CORE_SOFT_DELETE_PACKAGE =
"com.sourcefuse.jarc.services.usertenantservice.repository";
public static final String NO_RECORD =
"No records is present against the given value";
public static final String VIEW = "view";
public static final String UPDATE = "update";
public static final String DELETE = "delete";

private CommonConstants() {
throw new IllegalStateException("Utility class");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.sourcefuse.jarc.core.constants;

public final class PermissionKeyConstants {

public static final String CREATE_USER_GROUP = "CREATE_USER_GROUP";
public static final String VIEW_USER_GROUP_LIST = "VIEW_USER_GROUP_LIST";
public static final String UPDATE_USER_GROUP = "UPDATE_USER_GROUP";
public static final String DELETE_USER_GROUP = "DELETE_USER_GROUP";
public static final String DELETE_SUBSCRIPTIONS = "DELETE_SUBSCRIPTIONS";
public static final String VIEW_ROLES = "VIEW_ROLES";
public static final String NOT_ALLOWED = "NOT_ALLOWED";
public static final String CREATE_ROLES = "CREATE_ROLES";
public static final String UPDATE_ROLES = "UPDATE_ROLES";
public static final String DELETE_ROLES = "DELETE_ROLES";
public static final String VIEW_ANY_USER = "VIEW_ANY_USER";
public static final String VIEW_TENANT_USER = "VIEW_TENANT_USER";
public static final String VIEW_TENANT_USER_RESTRICTED =
"VIEW_TENANT_USER_RESTRICTED";
public static final String VIEW_ALL_USER = "VIEW_ALL_USER";
public static final String VIEW_OWN_USER = "VIEW_OWN_USER";
public static final String CREATE_ANY_USER = "CREATE_ANY_USER";
public static final String CREATE_TENANT_USER = "CREATE_TENANT_USER";
public static final String CREATE_TENANT_USER_RESTRICTED =
"CREATE_TENANT_USER_RESTRICTED";
public static final String UPDATE_ANY_USER = "UPDATE_ANY_USER";
public static final String UPDATE_OWN_USER = "UPDATE_OWN_USER";
public static final String UPDATE_TENANT_USER = "UPDATE_TENANT_USER";
public static final String UPDATE_TENANT_USER_RESTRICTED =
"UPDATE_TENANT_USER_RESTRICTED";
public static final String DELETE_ANY_USER = "DELETE_ANY_USER";
public static final String DELETE_TENANT_USER = "DELETE_TENANT_USER";
public static final String DELETE_TENANT_USER_RESTRICTED =
"DELETE_TENANT_USER_RESTRICTED";
public static final String CREATE_TENANT = "CREATE_TENANT";
public static final String VIEW_TENANT = "VIEW_TENANT";
public static final String UPDATE_TENANT = "UPDATE_TENANT";
public static final String VIEW_OWN_TENANT = "VIEW_OWN_TENANT";
public static final String UPDATE_OWN_TENANT = "UPDATE_OWN_TENANT";
public static final String DELETE_TENANT = "DELETE_TENANT";
public static final String ADD_MEMBER_TO_USER_GROUP =
"ADD_MEMBER_TO_USER_GROUP";
public static final String UPDATE_MEMBER_IN_USER_GROUP =
"UPDATE_MEMBER_IN_USER_GROUP";
public static final String REMOVE_MEMBER_FROM_USER_GROUP =
"REMOVE_MEMBER_FROM_USER_GROUP";
public static final String LEAVE_USER_GROUP = "LEAVE_USER_GROUP";
public static final String UPDATE_USER_TENANT_PREFERENCE =
"UPDATE_USER_TENANT_PREFERENCE";
public static final String VIEW_USER_TENANT_PREFERENCE =
"VIEW_USER_TENANT_PREFERENCE";

private PermissionKeyConstants() {}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.sourcefuse.jarc.core.exception;

import com.sourcefuse.jarc.core.constants.CommonConstants;
import com.sourcefuse.jarc.core.dtos.ErrorDetails;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
Expand Down Expand Up @@ -105,4 +107,17 @@ private static final ResponseEntity<ErrorDetails> handleHttpError(
);
return new ResponseEntity<>(errorDetails, exception.getStatusCode());
}

@ExceptionHandler(EmptyResultDataAccessException.class)
private static final ResponseEntity<ErrorDetails> handleEmptyResultDataAccessException(
EmptyResultDataAccessException exception,
WebRequest webRequest
) {
ErrorDetails errorDetails = new ErrorDetails(
LocalDateTime.now(),
CommonConstants.NO_RECORD,
webRequest.getDescription(false)
);
return new ResponseEntity<>(errorDetails, HttpStatus.NOT_FOUND);
}
}
16 changes: 16 additions & 0 deletions libs/jarc-auth-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@
<artifactId>jarc-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<module>sandbox/notification-pubnub-example</module>
<module>sandbox/notification-twilio-example</module>
<module>sandbox/audit-service-example</module>
<module>sandbox/user-tenant-service-example</module>
</modules>

<build>
Expand Down
33 changes: 33 additions & 0 deletions sandbox/user-tenant-service-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Loading