-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate workspace scope on DSL submission.
- Loading branch information
1 parent
66bedbe
commit 504d851
Showing
3 changed files
with
30 additions
and
19 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
21 changes: 21 additions & 0 deletions
21
...zr-onpremises/src/main/java/com/structurizr/onpremises/util/WorkspaceValidationUtils.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,21 @@ | ||
package com.structurizr.onpremises.util; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.validation.WorkspaceScopeValidationException; | ||
import com.structurizr.validation.WorkspaceScopeValidatorFactory; | ||
|
||
public class WorkspaceValidationUtils { | ||
|
||
public static void validateWorkspaceScope(Workspace workspace) throws WorkspaceScopeValidationException { | ||
// if workspace scope validation is enabled, reject workspaces without a defined scope | ||
if (Configuration.getInstance().isFeatureEnabled(Features.WORKSPACE_SCOPE_VALIDATION)) { | ||
if (workspace.getConfiguration().getScope() == null) { | ||
throw new WorkspaceScopeValidationException("Strict workspace scope validation has been enabled on this on-premises installation, but this workspace has no defined scope - see https://docs.structurizr.com/workspaces for more information."); | ||
} | ||
} | ||
|
||
// validate workspace scope | ||
WorkspaceScopeValidatorFactory.getValidator(workspace).validate(workspace); | ||
} | ||
|
||
} |
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