Class ResourceChange
java.lang.Object
org.apache.sling.api.resource.observation.ResourceChange
- Direct Known Subclasses:
JcrResourceChange
A resource change event is immutable.
A change event can either be local or external. Local changes happened
on the same instance, while external changes happened on a different
instance.
Resource listeners only receive external changes if they mark themselves
as a
ExternalResourceChangeListener
.
For all events (local and external), the path and the type of change is
set.
Resource provider events are always local events and only provide the path.
Local events for resources provide the names of the properties that
have been added, removed or changed. This information might be missing
for external events.- Since:
- 1.0.0 (Sling API Bundle 2.11.0)
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionResourceChange
(@NotNull ResourceChange.ChangeType changeType, @NotNull String path, boolean isExternal) Create a new change objectResourceChange
(@NotNull ResourceChange.ChangeType changeType, @NotNull String path, boolean isExternal, Set<String> addedPropertyNames, Set<String> changedPropertyNames, Set<String> removedPropertyNames) Deprecated.The sets of property names are not supported anymore. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.As there is no guarantee that this information is contained in the change event, this should not be used anymore.Deprecated.As there is no guarantee that this information is contained in the change event, this should not be used anymore.@NotNull String
getPath()
Get the resource path.Deprecated.As there is no guarantee that this information is contained in the change event, this should not be used anymore.@NotNull ResourceChange.ChangeType
getType()
Get the type of change@Nullable String
Get the user id of the user initiating the changeboolean
Is this an external event?toString()
-
Constructor Details
-
ResourceChange
public ResourceChange(@NotNull @NotNull ResourceChange.ChangeType changeType, @NotNull @NotNull String path, boolean isExternal) Create a new change object- Parameters:
changeType
- The change typepath
- The resource pathisExternal
- {code true} if the change happened on another node- Since:
- 1.2.0 (Sling API Bundle 2.15.0)
-
ResourceChange
@Deprecated public ResourceChange(@NotNull @NotNull ResourceChange.ChangeType changeType, @NotNull @NotNull String path, boolean isExternal, Set<String> addedPropertyNames, Set<String> changedPropertyNames, Set<String> removedPropertyNames) Deprecated.The sets of property names are not supported anymore.Create a new change object- Parameters:
changeType
- The change typepath
- The resource pathisExternal
- {code true} if the change happened on another nodeaddedPropertyNames
- set of added property names, if provided must be immutablechangedPropertyNames
- set of added property names, if provided must be immutableremovedPropertyNames
- set of added property names, if provided must be immutable
-
-
Method Details
-
getPath
Get the resource path.- Returns:
- The path to the resource.
-
getUserId
Get the user id of the user initiating the change- Returns:
- The user id or
null
if it's not available.
-
isExternal
public boolean isExternal()Is this an external event?- Returns:
true
if the event is external.
-
getType
Get the type of change- Returns:
- The type of change
-
getChangedPropertyNames
Deprecated.As there is no guarantee that this information is contained in the change event, this should not be used anymore.Optional information about changed properties. The application code can not rely on getting the correct set of changed properties. A resource provider implementation is free to not support this. Therefore if this method returnsnull
it does not mean that there are no changed properties. However if an empty set is returned, it can safely be assumed that there are none. Therefore returning {code null} is the equivalent of "don't know".- Returns:
- The set of changed property names. For external events or
resource provider events
null
is returned.
-
getAddedPropertyNames
Deprecated.As there is no guarantee that this information is contained in the change event, this should not be used anymore.Optional information about added properties. The application code can not rely on getting the correct set of added properties. A resource provider implementation is free to not support this. Therefore if this method returnsnull
it does not mean that there are no added properties. However if an empty set is returned, it can safely be assumed that there are none. Therefore returning {code null} is the equivalent of "don't know".- Returns:
- The set of changed property names. For external events or
resource provider events
null
is returned.
-
getRemovedPropertyNames
Deprecated.As there is no guarantee that this information is contained in the change event, this should not be used anymore.Optional information about removed properties. The application code can not rely on getting the correct set of removed properties. A resource provider implementation is free to not support this. Therefore if this method returnsnull
it does not mean that there are no removed properties. However if an empty set is returned, it can safely be assumed that there are none. Therefore returning {code null} is the equivalent of "don't know".- Returns:
- The set of changed property names. For external events or
resource provider events
null
is returned.
-
toString
-