Interface ProjectManagerBase
- All Known Subinterfaces:
ProjectManager
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProjectListener
(ProjectListener listener) Add aProjectListener
.default String
copyProject
(String projectName, String newProjectName) Create a copy of theRuntimeProject
namedprojectName
, usingnewProjectName
as the new project name, if possible.void
createOrReplaceProject
(String projectName, ProjectManifest manifest, List<ProjectResource> resources) Create a newRuntimeProject
with the provided manifests and resources, or replace an existing project byprojectName
if it already exists.void
createProject
(String projectName, ProjectManifest manifest, List<ProjectResource> resources) Create a newRuntimeProject
with the provided manifest and resources.default String
createProjectSafe
(String projectName, ProjectManifest manifest, List<ProjectResource> resources) Create a newRuntimeProject
with the provided manifests and resources.default String
createProjectSafe
(String projectName, ProjectManifest manifest, List<ProjectResource> resources, String namePattern) Create a newRuntimeProject
with the provided manifests and resources.void
deleteProject
(String projectName) Delete the project namedprojectName
, if it exists.void
exportProject
(String projectName, OutputStream destination) default Optional<RuntimeProject>
getProject
(String projectName) Get a theRuntimeProject
for the given name with all project resources in all scopes, if it exists.default Optional<RuntimeProject>
getProject
(String projectName, int applicationScope) Returns aRuntimeProject
for the given name loaded with all project resources that meet the given application scope, if it exists.getProject
(String projectName, ResourceFilter resourceFilter) Get aRuntimeProject
by the givenprojectName
containing only resources that pass the providedResourceFilter
, if it exists.Get aMap
ofProjectManifest
s for all current Projects.Get aList
of all current project names.pull
(List<ProjectSnapshot> snapshots) Pull any changes for the givensnapshots
.pull
(List<ProjectSnapshot> snapshots, ResourceFilter filter) Pull any changes for the givensnapshots
, but only changes for resources that match thefilter
.void
push
(List<ChangeOperation> changeOperations) Attempt to push a list ofChangeOperation
s.void
removeProjectListener
(ProjectListener listener) Remove a previously-registeredProjectListener
.Requests that a scan for Project Resources on the filesystem be performed immediately.
-
Field Details
-
DEFAULT_NAME_PATTERN
- See Also:
-
-
Method Details
-
addProjectListener
Add aProjectListener
.- Parameters:
listener
- theProjectListener
.
-
removeProjectListener
Remove a previously-registeredProjectListener
.- Parameters:
listener
- theProjectListener
.
-
createProject
void createProject(String projectName, ProjectManifest manifest, List<ProjectResource> resources) throws IllegalArgumentException, IOException, NameInUseException Create a newRuntimeProject
with the provided manifest and resources.- Parameters:
projectName
- the name of the project to create.manifest
- theProjectManifest
.resources
- the resources, if any, to assign to the project.- Throws:
IllegalArgumentException
- if any of the resources indicate they belong to a project other thanprojectName
.IOException
- if the project files could not be created.NameInUseException
- if a project byprojectName
already exists.
-
createProjectSafe
default String createProjectSafe(String projectName, ProjectManifest manifest, List<ProjectResource> resources) throws IllegalArgumentException, IOException Create a newRuntimeProject
with the provided manifests and resources.If a project by
projectName
already exists, the suffix "_N", where N increases monotonically from 1, is appended toprojectName
until a name that isn't already used is found.- Parameters:
projectName
- the name of the project to create.manifest
- theProjectManifest
.resources
- the resources, if any, to assign to the project.- Returns:
- the name of the new project.
- Throws:
IllegalArgumentException
- if any of the resources indicate they belong to a project other thanprojectName
.IOException
- if the project files could not be created.
-
createProjectSafe
default String createProjectSafe(String projectName, ProjectManifest manifest, List<ProjectResource> resources, String namePattern) throws IllegalArgumentException, IOException Create a newRuntimeProject
with the provided manifests and resources.If a project by
projectName
already exists thenamePattern
is applied to the name viaString.format(String, Object...)
, with a monotonically increasing integer value supplied, until a suitable name is found.- Parameters:
projectName
- the name of the project to create.manifest
- theProjectManifest
.resources
- the resources, if any, to assign to the project.namePattern
- the name pattern to apply ifprojectName
already exists.- Returns:
- the name of the new project.
- Throws:
IllegalArgumentException
- if any of the resources indicate they belong to a project other thanprojectName
.IOException
- if the project files could not be created.
-
createOrReplaceProject
void createOrReplaceProject(String projectName, ProjectManifest manifest, List<ProjectResource> resources) throws IllegalArgumentException, IOException Create a newRuntimeProject
with the provided manifests and resources, or replace an existing project byprojectName
if it already exists.Replacing an existing project is modeled as a push of create, modify, and delete
ChangeOperation
s, as opposed to deleting the existing project and creating a new one.- Parameters:
projectName
- the name of the project to create or replace.manifest
- theProjectManifest
.resources
- the resources, if any, to assign to the project.- Throws:
IllegalArgumentException
- if any of the resources indicate they belong to a project other thanprojectName
.IOException
- if the project files could not be created.
-
copyProject
default String copyProject(String projectName, String newProjectName) throws IOException, ProjectNotFoundException, ProjectInvalidException Create a copy of theRuntimeProject
namedprojectName
, usingnewProjectName
as the new project name, if possible.If
newProjectName
already exists a suitable name will be chosen automatically viacreateProjectSafe(String, ProjectManifest, List)
.- Parameters:
projectName
- the name of the existing project to copy.newProjectName
- the name for the new project.- Returns:
- the actual name used for the new project.
- Throws:
IOException
- if the project files could not be created.ProjectNotFoundException
- if a project byprojectName
does not exist.ProjectInvalidException
- if the project byprojectName
exists but its configuration is not valid.
-
deleteProject
Delete the project namedprojectName
, if it exists.- Parameters:
projectName
- the name of the project to delete- Throws:
IOException
- if the project files could not be deleted.ProjectNotFoundException
- if a project byprojectName
does not exist.
-
getProject
Get a theRuntimeProject
for the given name with all project resources in all scopes, if it exists.The project returned will not have been validated. See
RuntimeProject.validateOrThrow()
.- Parameters:
projectName
- the name of the project to get.- Returns:
- the
RuntimeProject
for the given name with all project resources in all scopes.
-
getProject
Returns aRuntimeProject
for the given name loaded with all project resources that meet the given application scope, if it exists.The project returned will not have been validated. See
RuntimeProject.validateOrThrow()
.- Parameters:
projectName
- the name of the project to get.applicationScope
- theApplicationScope
resources must belong to.- Returns:
- a
RuntimeProject
for the given name loaded with all project resources that meet the given application scope.
-
getProject
Get aRuntimeProject
by the givenprojectName
containing only resources that pass the providedResourceFilter
, if it exists.The project returned will not have been validated. See
RuntimeProject.validateOrThrow()
.- Parameters:
projectName
- the name of the project to get.resourceFilter
- theResourceFilter
.- Returns:
- a
RuntimeProject
by the givenprojectName
containing only resources that pass the providedResourceFilter
.
-
exportProject
void exportProject(String projectName, OutputStream destination) throws IOException, ProjectNotFoundException Export a copy of projectprojectName
by writing the contents to thedestination
OutputStream
.The bytes written are composed of a zip formatted project folder that could be uncompressed and placed directly in the projects directory resulting in a functional project.
- Parameters:
projectName
- the name of the project to export.destination
- anOutputStream
to write the export to.- Throws:
IOException
ProjectNotFoundException
-
getProjectManifests
Map<String,ProjectManifest> getProjectManifests()Get aMap
ofProjectManifest
s for all current Projects.- Returns:
- a
Map
ofProjectManifest
s, keyed by project name.
-
getProjectNames
Get aList
of all current project names.- Returns:
- a
List
of all current project names.
-
push
Attempt to push a list ofChangeOperation
s.If any changes conflict with the current state a
ProjectPushException
will be thrown.It is expected that consumers of this API will then pull and resolve any conflicts before attempting to push again.
- Parameters:
changeOperations
- a list ofChangeOperation
s to apply.- Throws:
ProjectPushException
- if any changes conflict with the current state.
-
pull
Pull any changes for the givensnapshots
.- Parameters:
snapshots
- theProjectSnapshot
s to pull changes for.- Returns:
ProjectDiff
s for eachProjectSnapshot
containing any resource diffs.- Throws:
ProjectPullException
-
pull
List<ProjectDiff.AbsoluteDiff> pull(List<ProjectSnapshot> snapshots, ResourceFilter filter) throws ProjectPullException Pull any changes for the givensnapshots
, but only changes for resources that match thefilter
.- Parameters:
snapshots
- theProjectSnapshot
s to pull changes for.filter
- theResourceFilter
.- Returns:
ProjectDiff.AbsoluteDiff
s for eachProjectSnapshot
containing any resource diffs.- Throws:
ProjectPullException
-
requestScan
CompletableFuture<Void> requestScan()Requests that a scan for Project Resources on the filesystem be performed immediately. If this method is called while a scan is already in progress, a new scan will not be initiated and will complete when the current scan is done.- Returns:
- a
CompletableFuture
that completes when a new scan or currently running scan has completed.
-