-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial hook up of systems to the rest of the models
- Loading branch information
Showing
9 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
service/src/main/java/org/kiwiproject/champagne/model/DeployableSystemThreadLocal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.kiwiproject.champagne.model; | ||
|
||
import java.util.Optional; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class DeployableSystemThreadLocal { | ||
|
||
private static final ThreadLocal<Long> THREAD_LOCAL = new ThreadLocal<>(); | ||
|
||
public static Optional<Long> getCurrentDeployableSystem() { | ||
return Optional.ofNullable(THREAD_LOCAL.get()); | ||
} | ||
|
||
public static void setCurrentDeployableSystem(Long id) { | ||
THREAD_LOCAL.set(id); | ||
} | ||
|
||
public static void clearCurrentDeployableSystem() { | ||
THREAD_LOCAL.remove(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...rc/main/java/org/kiwiproject/champagne/resource/filter/DeployableSystemRequestFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.kiwiproject.champagne.resource.filter; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerRequestFilter; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.kiwiproject.champagne.model.DeployableSystemThreadLocal; | ||
|
||
public class DeployableSystemRequestFilter implements ContainerRequestFilter { | ||
|
||
private static final String DEPLOYABLE_SYSTEM_HEADER_NAME = "DeployableSystem"; | ||
|
||
@Override | ||
public void filter(ContainerRequestContext requestContext) throws IOException { | ||
var system = requestContext.getHeaderString(DEPLOYABLE_SYSTEM_HEADER_NAME); | ||
|
||
// TODO: Need to validate that user is in system | ||
|
||
if (StringUtils.isNotBlank(system)) { | ||
DeployableSystemThreadLocal.setCurrentDeployableSystem(Long.valueOf(system)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters