public abstract class SandboxSupport
extends java.lang.Object
Constructor and Description |
---|
SandboxSupport() |
Modifier and Type | Method and Description |
---|---|
boolean |
addAdministrator(Sandbox sandbox,
java.lang.String userName)
Adds a user to the list of administrators of a sandbox.
|
abstract void |
addRepository(Sandbox sandbox,
SandboxedRepository repos)
Adds a repository in its latest certified state to a sandbox.
|
boolean |
canSynchronizedPublish(Sandbox sandbox)
Returns
true if all locks needed for
synchronizedPublish are available at the time of the
invocation. |
abstract void |
destroy(Sandbox sandbox)
Destroys a sandbox and deletes all information pertaining to the sandbox.
|
void |
destroy(Sandbox sandbox,
boolean retainInfo)
Destroys a sandbox and optionally retains the sandbox information such as
operation logs.
|
abstract boolean |
enableFeature(Sandbox sandbox,
java.lang.String featureId)
Enables a feature in the sandbox.
|
java.util.Map<java.lang.String,java.lang.Throwable> |
enableFeatures(Sandbox sandbox,
java.util.List<java.lang.String> featureIdList)
Enables a list of features.
|
abstract java.util.List<SandboxedFeature> |
getEnabledFeatures(Sandbox sandbox)
Returns the list of features enabled in a sandbox.
|
static SandboxSupport |
getInstance()
Returns the system default implementation of this class.
|
abstract java.util.List<SandboxedRepository> |
getRepositories(Sandbox sandbox)
Returns the list of repositories that have been branched for a sandbox.
|
RepositoryErrorLog |
getRepositoryErrorLog(Sandbox sandbox,
java.lang.String reposId)
Returns the error log from the last repository operation if any.
|
java.util.List<RepositoryErrorLog> |
getRepositoryErrorLogs(Sandbox sandbox)
Returns the list of non-null error logs from the repository branches of a
sandbox.
|
ChangeSet |
getRepositoryLastChanges(Sandbox sandbox,
java.lang.String reposId)
Returns the changes obtained last time from a repository branch.
|
abstract Sandbox |
getSandbox(java.lang.String id)
Returns the information of an existing sandbox.
|
abstract SandboxArchive |
getSandboxArchive(Sandbox sandbox)
Returns the
SandboxArchive object if the given sandbox is
from an archive. |
abstract SandboxLog |
getSandboxOperationLog(Sandbox sandbox)
Returns the log from the last sandbox operation.
|
abstract java.lang.Long |
getSandboxOperationLogId(java.lang.String sandboxId,
SandboxState.Condition condition)
Returns the ID of an open log for a sandbox.
|
int |
getSandboxOperationProgress(Sandbox sandbox)
Returns an integer from 0 (inclusive) to 100 (inclusive) to indicate the
progress of the current sandbox operation.
|
int |
getSandboxOperationProgress(Sandbox sandbox,
java.lang.String featureId)
Returns an integer from 0 (inclusive) to 100 (inclusive) to indicate the
progress of the current sandbox operation by feature.
|
boolean |
isCompatible(SandboxedFeature feature,
SandboxConstraints constraints)
Returns
true if the feature can be enabled in a sandbox with
the specified constraints. |
boolean |
isLockedBySandboxArchive()
Returns
true if the mainline of any repository is locked by
a sandbox archive at the time of invcation. |
java.util.List<java.lang.String> |
listAdministrators(Sandbox sandbox)
Returns the list of administrators of a sandbox.
|
java.util.List<java.lang.String> |
listOpenSandboxes()
Returns the IDs of the sandboxes that are open at the time of invocation,
not including the sandboxes created from archives.
|
abstract java.util.List<java.lang.String> |
listOpenSandboxes(boolean includeArchives)
Returns the IDs of the sandboxes that are open at the time of invocation.
|
Sandbox |
listSandbox(java.lang.String name)
Returns the most recently created sandbox whose name matches the specified
name exactly.
|
abstract java.util.List<java.lang.String> |
listSandboxes(java.lang.String name,
boolean exactMatch)
Returns the IDs of the sandboxes whose names contain or match the
specified name.
|
protected void |
logEvent(Sandbox sandbox,
RepositoryEvent e)
Logs a repository event.
|
abstract Sandbox |
newSandbox(SandboxArchive archive)
Creates a new sandbox from an archive as its initial contents.
|
abstract Sandbox |
newSandbox(java.lang.String name)
Creates a new sandbox.
|
abstract void |
notifyRefreshRequired(java.lang.String reposId)
Notifies sandboxes that contain a branch of a specific repository that
they must be refreshed before any further sandboxed changes are made.
|
abstract java.util.Map<SandboxedRepository,ChangeSet> |
publish(Sandbox sandbox)
Merges changes in a sandbox back into the repositories.
|
abstract java.util.Map<SandboxedRepository,ChangeSet> |
refresh(Sandbox sandbox)
Merges changes made in participating repositories into a sandbox.
|
boolean |
removeAdministrator(Sandbox sandbox,
java.lang.String userName)
Removes a user from the list of administrators of a sandbox.
|
boolean |
removeProcessLock(Sandbox sandbox,
int minElapsedHours)
Forcefully removes the synchronization lock placed by a Java process
performing a sandbox operation.
|
abstract void |
setDescription(Sandbox sandbox,
java.lang.String desc)
Updates the description of a sandbox.
|
abstract void |
setName(Sandbox sandbox,
java.lang.String name)
Updates the name of a sandbox.
|
abstract void |
setPrivate(Sandbox sandbox,
boolean p)
Marks a sandbox private or not.
|
abstract void |
setPublishable(Sandbox sandbox,
boolean p)
Marks a sandbox publishable or not.
|
void |
setSandboxConstraints(Sandbox sandbox,
SandboxConstraints constraints)
Sets constraints for a sandbox.
|
void |
setSandboxOperationChangeHint(Sandbox sandbox,
ChangeHint changeHint)
Gives a change hint to all repositories involved in the current operation.
|
java.util.Map<SandboxedRepository,ChangeSet> |
synchronizedPublish(Sandbox sandbox,
boolean refreshBefore)
Publishes a sandbox only when all mainline exclusive locks of the branched
repositories are available; in other words, a
ConcurrentSandboxOperationException is thrown when another
synchronizedPublish call is in progress, or when a mainline
exclusive lock of any branched repository has been acquired by an archive. |
boolean |
tryLock(SandboxArchive archive)
Tries to acquire the lock for processing a sandbox archive.
|
void |
unlock(SandboxArchive archive)
Releases the lock acquired for processing a sandbox archive.
|
void |
unpublish(Sandbox sandbox)
Unpublishes a sandbox if it's eligible.
|
IneligibleForUnpublishException |
unpublishCheck(Sandbox sandbox)
Checks if a sandbox is eligible for unpublish at this moment.
|
public static SandboxSupport getInstance()
public abstract Sandbox newSandbox(java.lang.String name) throws SandboxException
name
- the name of the sandboxjava.lang.IllegalArgumentException
- if the name already existsSandboxException
- if an error occurs while creating a sandboxpublic abstract Sandbox newSandbox(SandboxArchive archive) throws SandboxException
archive
- the archive that contains the initial contentsjava.lang.IllegalArgumentException
- if the name already existsSandboxException
- if an error occurs while creating a sandboxpublic abstract SandboxArchive getSandboxArchive(Sandbox sandbox)
SandboxArchive
object if the given sandbox is
from an archive.sandbox
- the sandbox the SandboxArchive
object is
associated withSandboxArchive
object if the given sandbox is
from an archive; null
otherwisepublic abstract void setName(Sandbox sandbox, java.lang.String name)
sandbox
- the sandbox to updatename
- the new namejava.lang.IllegalArgumentException
- if the given name is nullpublic abstract void setDescription(Sandbox sandbox, java.lang.String desc)
sandbox
- the sandboxdesc
- the descriptionpublic abstract void setPrivate(Sandbox sandbox, boolean p)
sandbox
- the sandbox to be set private or sharedp
- true
if the given sandbox is to be set to privatepublic abstract void setPublishable(Sandbox sandbox, boolean p)
sandbox
- the sandbox to be set publishable or notp
- true
if the given sandbox is to be set to
publishablepublic abstract java.util.List<java.lang.String> listSandboxes(java.lang.String name, boolean exactMatch)
name
- the name of the sandboxexactMatch
- true
if the names of the returned sandboxes
must match the specified name exactlyjava.lang.IllegalArgumentException
- if the given name is nullpublic abstract java.util.List<java.lang.String> listOpenSandboxes(boolean includeArchives)
destroy
to be performed on it. In other words, a sandbox that
is not open can only be destroyed.includeArchives
- true
if the returned list should include
the sandboxes that are created from archivespublic java.util.List<java.lang.String> listOpenSandboxes()
public Sandbox listSandbox(java.lang.String name)
name
- the name of the sandboxjava.lang.IllegalArgumentException
- if the given name is nullpublic abstract Sandbox getSandbox(java.lang.String id)
id
- the ID of the sandboxnull
if there is no such
sandboxpublic abstract SandboxLog getSandboxOperationLog(Sandbox sandbox)
sandbox
- the sandbox where the operation was performednull
if
not availablepublic abstract java.lang.Long getSandboxOperationLogId(java.lang.String sandboxId, SandboxState.Condition condition)
sandboxId
- the ID of the sandbox for which the log is createdcondition
- the condition when the log is availablenull
if no log is available for the given
sandbox in the given conditionpublic int getSandboxOperationProgress(Sandbox sandbox)
sandbox
- the sandbox on which the operation is in progresspublic int getSandboxOperationProgress(Sandbox sandbox, java.lang.String featureId)
sandbox
- the sandbox on which the operation is in progressfeatureId
- the ID of the enabled featurejava.lang.IllegalArgumentException
- if the given feature is not definedpublic void setSandboxConstraints(Sandbox sandbox, SandboxConstraints constraints)
sandbox
- the sandbox with which the constraints are to be associatedconstraints
- the constraints for the sandboxjava.lang.UnsupportedOperationException
- if this method is not supportedpublic void setSandboxOperationChangeHint(Sandbox sandbox, ChangeHint changeHint)
sandbox
- the sandbox on which the current operation is in progresschangeHint
- the change hint; null
if the default hint
should be givenjava.lang.UnsupportedOperationException
- if this method is not supportedSandboxTransaction
public boolean removeProcessLock(Sandbox sandbox, int minElapsedHours)
Normally a lock is placed on a sandbox before a process starts handling an operation and is removed after the process ends, so that a sandbox is handled by one process at a time. For example, when a process is refreshing a sandbox, a lock will prevent other processes from enabling new features in the same sandbox.
Occassionally a lock may not be removed due to unexpected situations such as the Java process that performs the operation is terminated prematurely. In such cases the lock must be removed explicitly. To avoid removing a lock while an operation is actually in progress, a minimum elapsed time may be specified, so that a lock is removed only if the duration between its placement and now is greater than the specified elapsed time.
sandbox
- the sandbox where the lock is placedminElapsedHours
- the minimum elapsed time in hourstrue
if the lock has been removed; false
a lock is in place but cannot be removed because the elapsed
time is shorter than or the same as the specified minimumjava.lang.IllegalArgumentException
- if the given elapsed time is invalid.
Implementation of this method may put a lower bound on
minElapsedHours
. Usually the minimum elapsed
time cannot be shorter than one hour.java.lang.UnsupportedOperationException
- If this method is not supportedpublic abstract boolean enableFeature(Sandbox sandbox, java.lang.String featureId) throws IncompatibleFeatureException, SandboxException
sandbox
- the sandboxfeatureId
- the ID of the sandboxed featurefalse
if the feature was already enabled prior to this
calljava.lang.IllegalArgumentException
- if the specified feature is unavailableIncompatibleFeatureException
- if the feature is incompatible with
the sandboxSandboxException
- if an error occurs while enabling the featurepublic java.util.Map<java.lang.String,java.lang.Throwable> enableFeatures(Sandbox sandbox, java.util.List<java.lang.String> featureIdList) throws IncompatibleFeatureException, SandboxException
sandbox
- the sandbox where the features are to be enabledfeatureIdList
- the IDs of the features to be enabledjava.lang.UnsupportedOperationException
- if enabling multiple features at
a time is not supportedIncompatibleFeatureException
SandboxException
public boolean isCompatible(SandboxedFeature feature, SandboxConstraints constraints)
true
if the feature can be enabled in a sandbox with
the specified constraints. This method may be invoked before a sandbox is
created, after the constraints are known.feature
- the sandbox feature to be enabledconstraints
- the conditions a sandbox must satisfy to enable the
feature; null
to indicate no constraintstrue
if the feature can be enabled in a sandbox with
the given constraintspublic abstract void addRepository(Sandbox sandbox, SandboxedRepository repos) throws SandboxException
sandbox
- the sandboxrepos
- the participating repositorySandboxException
- if an error occurs while adding the repositorypublic abstract java.util.List<SandboxedRepository> getRepositories(Sandbox sandbox)
sandbox
- the sandboxpublic abstract java.util.List<SandboxedFeature> getEnabledFeatures(Sandbox sandbox)
sandbox
- the sandboxpublic ChangeSet getRepositoryLastChanges(Sandbox sandbox, java.lang.String reposId)
sandbox
- the sandbox that contains the repository branchnull
if such information is unavailablepublic RepositoryErrorLog getRepositoryErrorLog(Sandbox sandbox, java.lang.String reposId)
sandbox
- the sandbox where the repository is branchedreposId
- the ID of the repositorynull
if there is no error, or the error log is not
availablepublic java.util.List<RepositoryErrorLog> getRepositoryErrorLogs(Sandbox sandbox)
sandbox
- the sandbox where the repositories are branchedprotected void logEvent(Sandbox sandbox, RepositoryEvent e)
sandbox
- the sandboxe
- the repository eventpublic abstract java.util.Map<SandboxedRepository,ChangeSet> refresh(Sandbox sandbox) throws SuspendedSandboxOperationException, RepositoryExceptions
SandboxState.INACTIVE
.sandbox
- the sandboxRepositoryExceptions
- if merge conflicts are detected or any error
occurs during the processSuspendedSandboxOperationException
public abstract void notifyRefreshRequired(java.lang.String reposId)
reposId
- the ID of the repositorySandbox.isRefreshRequired()
,
refresh(oracle.adf.share.sandbox.Sandbox)
public abstract java.util.Map<SandboxedRepository,ChangeSet> publish(Sandbox sandbox) throws RepositoryExceptions
SandboxState.INACTIVE
.sandbox
- the sandboxRepositoryExceptions
- if merge conflicts are detected or any error
occurs during the processpublic abstract void destroy(Sandbox sandbox) throws RepositoryExceptions
sandbox
- the sandbox to be destroyedRepositoryExceptions
- if there is any error coming from the repositoriespublic IneligibleForUnpublishException unpublishCheck(Sandbox sandbox)
unpublish
is called.sandbox
- the sandbox to be checkednull
if the given sandbox is eligible for unpublish;
otherwise an object is returned to indicate the reasonjava.lang.IllegalArgumentException
- if the given sandbox is nluljava.lang.UnsupportedOperationException
- if this operation is not supportedunpublish(oracle.adf.share.sandbox.Sandbox)
public void unpublish(Sandbox sandbox) throws IneligibleForUnpublishException
sandbox
- the sandbox to be unpublishedIneligibleForUnpublishException
- if the given sandbox is ineligible
for unpublishjava.lang.IllegalArgumentException
- if the given sandbox is nulljava.lang.UnsupportedOperationException
- if this operation is not supportedunpublishCheck(oracle.adf.share.sandbox.Sandbox)
public void destroy(Sandbox sandbox, boolean retainInfo) throws RepositoryExceptions
SandboxState.IRRECOVERABLE
.sandbox
- the sandbox to be destroyedretainInfo
- true
if the sandbox information should be
retainedjava.lang.UnsupportedOperationException
- if this method is not supportedRepositoryExceptions
destroy(Sandbox)
public boolean tryLock(SandboxArchive archive)
unlock(SandboxArchive)
. The behavior of
calling this method again with a different SandboxArchive
object before releasing the lock for the first call is undefined.archive
- the sandbox archive to be processedtrue
if the lock is acquired successfully;
false
if the involved repositories are currently
locked by other sandboxesjava.lang.IllegalArgumentException
- if the given sandbox archive is nulljava.lang.UnsupportedOperationException
- if this method is not supportedunlock(oracle.adf.share.sandbox.SandboxArchive)
public void unlock(SandboxArchive archive)
SandboxArchive
object.archive
- the sandbox archive that was just processed; or
null
if the information of the archive is no
longer availablejava.lang.UnsupportedOperationException
- if this method is not supportedtryLock(oracle.adf.share.sandbox.SandboxArchive)
public boolean isLockedBySandboxArchive()
true
if the mainline of any repository is locked by
a sandbox archive at the time of invcation. When the processing of a
sandbox archive is in progress,
ConcurrentSandboxOperationException
may be thrown by methods that require the same locks already acquired
by the archive, such as enableFeature
or
synchronizedPublish
. The client may simply skip all
operations and wait until this method returns false
again.true
if the mainline of any repository is locked by
a sandbox archive at the time of invocationtryLock(oracle.adf.share.sandbox.SandboxArchive)
,
unlock(oracle.adf.share.sandbox.SandboxArchive)
public java.util.Map<SandboxedRepository,ChangeSet> synchronizedPublish(Sandbox sandbox, boolean refreshBefore) throws RepositoryExceptions, ConcurrentSandboxOperationException
ConcurrentSandboxOperationException
is thrown when another
synchronizedPublish
call is in progress, or when a mainline
exclusive lock of any branched repository has been acquired by an archive.sandbox
- the sandbox to be publishedrefreshBefore
- true
if refresh
should be
called first after acquiring the necessary locks.
If a repository is pending resume after the first
pass, the process will be resumed once with change
hint ChangeHint.STOP_AT_CONFLICTS
.
If any repository is still pending resume after the
second pass, a SsuspendedSandboxOperation
is thrown.RepositoryExceptions
- if any error occurs during the publishConcurrentSandboxOperationException
- if refreshBefore
is true
and any repository is still pending
resume after the first resumepublic boolean canSynchronizedPublish(Sandbox sandbox)
true
if all locks needed for
synchronizedPublish
are available at the time of the
invocation. This information serves as a hint only. A
ConcurrentSandboxOperationException
may still be thrown
when synchronizedPublish
is invoked because the locks
may be acquired by another sandbox between the invocation of this method
and that of synchronizedPublish
. If a client must block
on synchronizedPublish
, skip this check and call
synchronizedPublish
periodically until
ConcurrentSandboxOperationException
is not thrown.sandbox
- the sandbox to be publishedtrue
if all locks needed for
synchronizedPublish
are available at the time of the
invocationpublic boolean addAdministrator(Sandbox sandbox, java.lang.String userName)
sandbox
- the sandbox administereduserName
- the user to be added as an administratortrue
if the user is not an administrator prior to
this call; false
if the user was not added to the
list because he is already an administrator of the sandboxjava.lang.IllegalArgumentException
- if the sandbox or user name is nullpublic boolean removeAdministrator(Sandbox sandbox, java.lang.String userName)
sandbox
- the sandbox administered by the useruserName
- the user to be removed from the list of administratorstrue
if the user is an administrator prior to this
call and is successfully removed from the list;
false
if the user is not on the list or cannot be
removed because he is the owner of the sandboxjava.lang.IllegalArgumentException
- if the sandbox or user name is nullpublic java.util.List<java.lang.String> listAdministrators(Sandbox sandbox)
sandbox
- the sandboxjava.lang.IllegalArgumentException
- if the sandbox is null