Class 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
    • 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​(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 interface ResourceIdentifier
        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 interface ComponentResourceIdentifier
        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 interface ComponentResourceIdentifier
        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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object