Class ContributionIdentifier
- java.lang.Object
-
- org.silverpeas.core.contribution.model.ContributionIdentifier
-
- All Implemented Interfaces:
Serializable
,ComponentResourceIdentifier
,ResourceIdentifier
- Direct Known Subclasses:
CommentId
@Embeddable public class ContributionIdentifier extends Object implements ComponentResourceIdentifier, Serializable
A contribution identifier is an identifier that identifies uniquely a contribution in Silverpeas whatever its type and the application instance or tools to which it belongs. For doing, it is made up of two parts: one part that identify uniquely a contribution among all of the contributions of the same type, and a last part that identify the component instance the contribution belongs to. The contribution identifier is serializable and can it can be transmitted in JSON or in XML.- Author:
- mmoquillon
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
MISSING_PART
-
Constructor Summary
Constructors Modifier Constructor Description protected
ContributionIdentifier()
protected
ContributionIdentifier(String instanceId, String localId, String type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
asString()
Gets the absolute value of this identifier.static ContributionIdentifier
decode(String contributionId)
Decodes the contribution identifier from the given string.boolean
equals(Object o)
static ContributionIdentifier
from(String instanceId, String localId, String type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.static ContributionIdentifier
from(String instanceId, String localId, CoreContributionType type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.static ContributionIdentifier
from(ResourceIdentifier resourceId)
Constructs a new contribution identifier from the specified Silverpeas resource identifier.static ContributionIdentifier
from(ResourceReference key)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.static ContributionIdentifier
from(ResourceReference key, String type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.String
getComponentInstanceId()
Gets the unique identifier of the component instance to which the contribution belongs.String
getLocalId()
Gets the local identifier of the contribution.String
getType()
Gets the type of the contribution.int
hashCode()
static boolean
isValid(String id)
Is the specified identifier a valid contribution identifier?-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.ComponentResourceIdentifier
toReference
-
-
-
-
Field Detail
-
MISSING_PART
public static final String MISSING_PART
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ContributionIdentifier
protected ContributionIdentifier()
-
ContributionIdentifier
protected ContributionIdentifier(String instanceId, String localId, String type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.- Parameters:
instanceId
- the unique identifier of the instance.localId
- the local identifier of the contribution.type
- the type of the contribution.
-
-
Method Detail
-
decode
public static ContributionIdentifier decode(String contributionId)
Decodes the contribution identifier from the given string.
If the decoded contribution identifier is partially filled (component instance identifier is missing for example), then the
ContributionLocator
is used to attempt to locate the contribution behind the contribution identifier. If it is located, the component instance identifier found is taken into account.- Parameters:
contributionId
- a contribution identifier as string.- Returns:
- a
ContributionIdentifier
which represents the given id as string.
-
isValid
public static boolean isValid(String id)
Is the specified identifier a valid contribution identifier?- Parameters:
id
- the textual format of an identifier of a resource in Silverpeas.- Returns:
- true if the given parameter represents correctly the identifier of a contribution in Silverpeas, false otherwise.
-
from
public static ContributionIdentifier from(ResourceIdentifier resourceId)
Constructs a new contribution identifier from the specified Silverpeas resource identifier. If the resource identifier is actually aContributionIdentifier
instance, then returns it as such, otherwise decode it from itsString
representation (though itsResourceIdentifier.asString()
method- Parameters:
resourceId
- aResourceIdentifier
object.- Returns:
- an contribution identifier.
-
from
public static ContributionIdentifier from(String instanceId, String localId, CoreContributionType type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution. The type of the contribution is main one handled by the component.- Parameters:
instanceId
- the unique identifier of the instance.localId
- the local identifier of the contribution.type
- the type of the contribution.- Returns:
- an contribution identifier.
-
from
public static ContributionIdentifier from(ResourceReference key)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution. The type of the contribution is main one handled by the component.- Parameters:
key
- an old and deprecated representation of an identifier of Silverpeas.- Returns:
- an contribution identifier.
-
from
public static ContributionIdentifier from(String instanceId, String localId, String type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.- Parameters:
instanceId
- the unique identifier of the instance.localId
- the local identifier of the contribution.type
- the type of the contribution.- Returns:
- an contribution identifier.
-
from
public static ContributionIdentifier from(ResourceReference key, String type)
Constructs a new contribution identifier from the specified component instance identifier and from the local identifier of the contribution.- Parameters:
key
- an old and deprecated representation of an identifier of Silverpeas.type
- the type of the contribution.- Returns:
- an contribution identifier.
-
asString
public String asString()
Gets the absolute value of this identifier.Either it is an explicit absolute unique value or, in the case no absolute value is defined for this contribution, it is made up of both the component instance identifier and the contribution identifier. In latter, the component instance identifier defines the namespace in which the local identifier exists.
- Specified by:
asString
in interfaceResourceIdentifier
- Returns:
- the String representation of this identifier either as a value in itself or in the form of [component instance identifier]:[local contribution identifier]
-
getLocalId
public String getLocalId()
Gets the local identifier of the contribution. A local identifier is in fact unique only among all the contributions of the same type; it is why it's said local to the same contribution types.- Specified by:
getLocalId
in interfaceComponentResourceIdentifier
- Returns:
- the local contribution identifier.
-
getComponentInstanceId
public String getComponentInstanceId()
Gets the unique identifier of the component instance to which the contribution belongs. It acts as a namespace of the unique identifier.- Specified by:
getComponentInstanceId
in interfaceComponentResourceIdentifier
- Returns:
- the component instance identifier (either an application instance or a tool instance identifier).
-
getType
public String getType()
Gets the type of the contribution.- Returns:
- the type of the contribution as string.
-
-