Package org.silverpeas.components.kmelia.model

## Class KmeliaPublication

- java.lang.Object
- - org.silverpeas.components.kmelia.model.KmeliaPublication

- All Implemented Interfaces:
    `Serializable`, `org.silverpeas.core.contribution.model.Contribution`, `org.silverpeas.core.contribution.model.I18nContribution`, `org.silverpeas.core.contribution.model.SilverpeasContent`, `org.silverpeas.core.contribution.model.WithPermanentLink`, `org.silverpeas.core.contribution.model.WithThumbnail`, `org.silverpeas.core.i18n.LocalizedResource`, `org.silverpeas.core.i18n.Translatable`, `org.silverpeas.core.Identifiable`, `org.silverpeas.core.Instance<org.silverpeas.core.contribution.model.Contribution>`, `org.silverpeas.core.Nameable`, `org.silverpeas.core.security.Securable`, `org.silverpeas.core.SilverpeasResource`

      public class KmeliaPublication
      extends Object
      implements org.silverpeas.core.contribution.model.I18nContribution, org.silverpeas.core.contribution.model.SilverpeasContent, org.silverpeas.core.contribution.model.WithPermanentLink, org.silverpeas.core.contribution.model.WithThumbnail

  A publication as defined in a Kmelia component. A publication in Kmelia is a publication that is always in a given topic (the father of the publication), and that can be positioned in the PDC, can have attachments, and can be commented.

  In Kmelia, a publication can be in one or more topics. In such a case, a Kmelia publication that is in a topic other that the original one is said to be an alias of the publication in the original topic: any changes are done in the true publication.

  See Also:
    Serialized Form

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static KmeliaPublication` | `aKmeliaPublicationFromCompleteDetail​(org.silverpeas.core.contribution.publication.model.CompletePublication detail)` | Gets the Kmelia publication from the specified complete publication detail.
    `boolean` | `canBeAccessedBy​(org.silverpeas.core.admin.user.model.User user)` | Is the specified user can access this publication?
    `boolean` | `equals​(Object obj)` |
    `static KmeliaPublication` | `fromDetail​(org.silverpeas.core.contribution.publication.model.PublicationDetail detail)` | Gets the Kmelia publication from the specified publication detail.
    `static KmeliaPublication` | `fromDetail​(org.silverpeas.core.contribution.publication.model.PublicationDetail detail, org.silverpeas.core.node.model.NodePK fatherPK)` | Gets the Kmelia publication in the given topic from the specified publication detail.
    `static KmeliaPublication` | `fromDetail​(org.silverpeas.core.contribution.publication.model.PublicationDetail detail, org.silverpeas.core.node.model.NodePK fatherPK, Map<String,​List<org.silverpeas.core.contribution.publication.model.Location>> locationCache)` | Gets the Kmelia publication in the given topic from the specified publication detail.
    `List<org.silverpeas.core.comment.model.Comment>` | `getComments()` | Gets the comments on this publication.
    `org.silverpeas.core.contribution.publication.model.CompletePublication` | `getCompleteDetail()` | Gets the complete detail about this publication.
    `String` | `getComponentInstanceId()` |
    `String` | `getContributionType()` |
    `Date` | `getCreationDate()` |
    `org.silverpeas.core.admin.user.model.User` | `getCreator()` | Gets the creator of this publication (the initial author).
    `String` | `getDescription()` |
    `org.silverpeas.core.contribution.publication.model.PublicationDetail` | `getDetail()` | Gets the details about this publication.
    `String` | `getId()` | Gets the unique identifier of this publication.
    `org.silverpeas.core.contribution.model.ContributionIdentifier` | `getIdentifier()` |
    `Date` | `getLastUpdateDate()` |
    `org.silverpeas.core.admin.user.model.User` | `getLastUpdater()` | Gets the user that has lastly modified this publication.
    `org.silverpeas.core.contribution.publication.model.Location` | `getLocation()` |
    `org.silverpeas.core.contribution.model.ContributionModel` | `getModel()` |
    `int` | `getNbAccess()` |
    `int` | `getNumberOfComments()` | Get the number of comments on this publication
    `Optional<org.silverpeas.core.contribution.publication.model.Location>` | `getOriginalLocation​(String userId)` | Gets the original location of this alias according to the access right the of the specified user.
    `List<org.silverpeas.core.pdc.pdc.model.ClassifyPosition>` | `getPDCPositions()` | Gets the positions in the PDC of this publication.
    `String` | `getPermalink()` |
    `org.silverpeas.core.contribution.publication.model.PublicationPK` | `getPk()` | Gets the primary key of this publication.
    `Optional<org.silverpeas.core.contribution.publication.model.PublicationPath>` | `getResourcePath()` |
    `String` | `getSilverpeasContentId()` |
    `org.silverpeas.core.contribution.model.Thumbnail` | `getThumbnail()` |
    `String` | `getTitle()` |
    `org.silverpeas.core.i18n.ResourceTranslation` | `getTranslation​(String language)` |
    `String` | `getURL()` | Gets the complete URL at which this publication is located.
    `ValidatorsList` | `getValidators()` |
    `int` | `hashCode()` |
    `boolean` | `isAlias()` | Is this publication an alias of an existing Kmelia publication?
    `boolean` | `isRead()` |
    `boolean` | `isVisible()` | Is this publication visible?
    `void` | `setAsRead()` |
    `static KmeliaPublication` | `withPK​(org.silverpeas.core.contribution.publication.model.PublicationPK pk)` | Gets the Kmelia publication with the specified primary key identifying it uniquely.
    `static KmeliaPublication` | `withPK​(org.silverpeas.core.contribution.publication.model.PublicationPK pk, org.silverpeas.core.node.model.NodePK fatherPk)` | Gets the Kmelia publication with the specified primary key and that is in the topic specified by its primary key.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.silverpeas.core.contribution.model.Contribution

      `getName, isIndexable`

    - ### Methods inherited from interface org.silverpeas.core.contribution.model.I18nContribution

      `getLocalizationIn`

    - ### Methods inherited from interface org.silverpeas.core.Instance

      `getParent`

    - ### Methods inherited from interface org.silverpeas.core.security.Securable

      `canBeDeletedBy, canBeFiledInBy, canBeModifiedBy`

- - ### Method Detail

    - #### withPK

          public static KmeliaPublication withPK​(org.silverpeas.core.contribution.publication.model.PublicationPK pk)

      Gets the Kmelia publication with the specified primary key identifying it uniquely. If no such publication exists with the specified key, then the runtime exception `KmeliaRuntimeException` is thrown. The publication is by default the original one and hence not an alias.
      Parameters:
        `pk` - the primary key of the publication to get.
      Returns:
        the Kmelia publication matching the primary key.

    - #### withPK

          public static KmeliaPublication withPK​(org.silverpeas.core.contribution.publication.model.PublicationPK pk,
                                                 org.silverpeas.core.node.model.NodePK fatherPk)

      Gets the Kmelia publication with the specified primary key and that is in the topic specified by its primary key. If no such publication exists with the specified key or if the publication has no such father, then the runtime exception `KmeliaRuntimeException` is thrown.
      Parameters:
        `pk` - the primary key of the publication to get.
        `fatherPk` - the primary key of the topic that is the father of the publication.
      Returns:
        the Kmelia publication matching the primary key.

    - #### getLocation

          public org.silverpeas.core.contribution.publication.model.Location getLocation()

    - #### fromDetail

          public static KmeliaPublication fromDetail​(org.silverpeas.core.contribution.publication.model.PublicationDetail detail)

      Gets the Kmelia publication from the specified publication detail. The publication is by default the original one and not an alias.
      Parameters:
        `detail` - the detail about the publication to get.
      Returns:
        the Kmelia publication matching the specified publication detail.

    - #### fromDetail

          public static KmeliaPublication fromDetail​(org.silverpeas.core.contribution.publication.model.PublicationDetail detail,
                                                     org.silverpeas.core.node.model.NodePK fatherPK)

      Gets the Kmelia publication in the given topic from the specified publication detail.
      Parameters:
        `detail` - the detail about the publication to get.
        `fatherPK` - the primary key of the topic that is father of the publication to get.
      Returns:
        the Kmelia publication matching the specified publication detail.

    - #### fromDetail

          public static KmeliaPublication fromDetail​(org.silverpeas.core.contribution.publication.model.PublicationDetail detail,
                                                     org.silverpeas.core.node.model.NodePK fatherPK,
                                                     Map<String,​List<org.silverpeas.core.contribution.publication.model.Location>> locationCache)

      Gets the Kmelia publication in the given topic from the specified publication detail.
      Parameters:
        `detail` - the detail about the publication to get.
        `fatherPK` - the primary key of the topic that is father of the publication to get.
        `locationCache` - cache of locations already loaded.
      Returns:
        the Kmelia publication matching the specified publication detail.

    - #### aKmeliaPublicationFromCompleteDetail

          public static KmeliaPublication aKmeliaPublicationFromCompleteDetail​(org.silverpeas.core.contribution.publication.model.CompletePublication detail)

      Gets the Kmelia publication from the specified complete publication detail. The publication is by default the original one and not an alias.
      Parameters:
        `detail` - the complete detail about the publication to get.
      Returns:
        the Kmelia publication matching the specified complete publication detail.

    - #### isRead

          public boolean isRead()

    - #### setAsRead

          public void setAsRead()

    - #### isAlias

          public boolean isAlias()

      Is this publication an alias of an existing Kmelia publication?
      Returns:
        true if this publication is an alias, false otherwise.

    - #### isVisible

          public boolean isVisible()

      Is this publication visible?
      Returns:
        true if this publication is visible, false otherwise.

    - #### getPk

          public org.silverpeas.core.contribution.publication.model.PublicationPK getPk()

      Gets the primary key of this publication.
      Returns:
        the publication primary key.

    - #### getId

          public String getId()

      Gets the unique identifier of this publication.
      Specified by:
        `getId` in interface `org.silverpeas.core.Identifiable`
      Specified by:
        `getId` in interface `org.silverpeas.core.contribution.model.SilverpeasContent`
      Returns:
        the unique identifier of this publication.

    - #### getURL

          public String getURL()

      Gets the complete URL at which this publication is located.
      Returns:
        the publication URL.

    - #### getDetail

          public org.silverpeas.core.contribution.publication.model.PublicationDetail getDetail()

      Gets the details about this publication.
      Returns:
        the publication details.

    - #### getCompleteDetail

          public org.silverpeas.core.contribution.publication.model.CompletePublication getCompleteDetail()

      Gets the complete detail about this publication.
      Returns:
        the publication complete details.

    - #### getCreator

          public org.silverpeas.core.admin.user.model.User getCreator()

      Gets the creator of this publication (the initial author).
      Specified by:
        `getCreator` in interface `org.silverpeas.core.SilverpeasResource`
      Returns:
        the detail about the creator of this publication.

    - #### getLastUpdater

          public org.silverpeas.core.admin.user.model.User getLastUpdater()

      Gets the user that has lastly modified this publication. He's the last one that has worked on this publication. If this publication was not modified since its creation, the creator is returned as he's the last user that has worked on this publication.
      Specified by:
        `getLastUpdater` in interface `org.silverpeas.core.SilverpeasResource`
      Returns:
        the detail about the last modifier of this publication.

    - #### getComments

          public List<org.silverpeas.core.comment.model.Comment> getComments()

      Gets the comments on this publication.
      Returns:
        an unmodifiable list with the comments on this publication.

    - #### getPDCPositions

          public List<org.silverpeas.core.pdc.pdc.model.ClassifyPosition> getPDCPositions()

      Gets the positions in the PDC of this publication.
      Returns:
        an unmodifiable list with the PDC positions of this publication.

    - #### getNbAccess

          public int getNbAccess()

    - #### equals

          public boolean equals​(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getComponentInstanceId

          public String getComponentInstanceId()

      Specified by:
        `getComponentInstanceId` in interface `org.silverpeas.core.contribution.model.SilverpeasContent`

    - #### getSilverpeasContentId

          public String getSilverpeasContentId()

      Specified by:
        `getSilverpeasContentId` in interface `org.silverpeas.core.contribution.model.SilverpeasContent`

    - #### getCreationDate

          public Date getCreationDate()

      Specified by:
        `getCreationDate` in interface `org.silverpeas.core.SilverpeasResource`

    - #### getLastUpdateDate

          public Date getLastUpdateDate()

      Specified by:
        `getLastUpdateDate` in interface `org.silverpeas.core.SilverpeasResource`

    - #### getTitle

          public String getTitle()

      Specified by:
        `getTitle` in interface `org.silverpeas.core.contribution.model.Contribution`

    - #### getDescription

          public String getDescription()

      Specified by:
        `getDescription` in interface `org.silverpeas.core.contribution.model.Contribution`
      Specified by:
        `getDescription` in interface `org.silverpeas.core.Nameable`

    - #### getContributionType

          public String getContributionType()

      Specified by:
        `getContributionType` in interface `org.silverpeas.core.contribution.model.Contribution`

    - #### getResourcePath

          public Optional<org.silverpeas.core.contribution.publication.model.PublicationPath> getResourcePath()

      Specified by:
        `getResourcePath` in interface `org.silverpeas.core.contribution.model.Contribution`

    - #### canBeAccessedBy

          public boolean canBeAccessedBy​(org.silverpeas.core.admin.user.model.User user)

      Is the specified user can access this publication?

      A user can access a publication if he has enough rights to access both the Kmelia instance in which is managed this publication and the topics to which this publication belongs to.
      Specified by:
        `canBeAccessedBy` in interface `org.silverpeas.core.contribution.model.Contribution`
      Specified by:
        `canBeAccessedBy` in interface `org.silverpeas.core.security.Securable`
      Parameters:
        `user` - a user in Silverpeas.
      Returns:
        true if the user can access this publication, false otherwise.

    - #### getNumberOfComments

          public int getNumberOfComments()

      Get the number of comments on this publication
      Returns:
        the number.

    - #### getOriginalLocation

          public Optional<org.silverpeas.core.contribution.publication.model.Location> getOriginalLocation​(String userId)

      Gets the original location of this alias according to the access right the of the specified user. If this location isn't an alias, then returns itself. If the user has no access right to the original location, then returns nothing. If no original location can be found, whatever the access right of the user, a `KmeliaRuntimeException` is thrown.
      Parameters:
        `userId` - the unique identifier of the user for which the access right on the original location has to be checked.
      Returns:
        either the original location (itself if this location is already the original one) or nothing whether the given user has no access right on it.

    - #### getValidators

          public ValidatorsList getValidators()

    - #### getPermalink

          public String getPermalink()

      Specified by:
        `getPermalink` in interface `org.silverpeas.core.contribution.model.WithPermanentLink`

    - #### getThumbnail

          public org.silverpeas.core.contribution.model.Thumbnail getThumbnail()

      Specified by:
        `getThumbnail` in interface `org.silverpeas.core.contribution.model.WithThumbnail`

    - #### getIdentifier

          public org.silverpeas.core.contribution.model.ContributionIdentifier getIdentifier()

      Specified by:
        `getIdentifier` in interface `org.silverpeas.core.contribution.model.Contribution`
      Specified by:
        `getIdentifier` in interface `org.silverpeas.core.contribution.model.I18nContribution`
      Specified by:
        `getIdentifier` in interface `org.silverpeas.core.contribution.model.SilverpeasContent`
      Specified by:
        `getIdentifier` in interface `org.silverpeas.core.SilverpeasResource`

    - #### getTranslation

          public org.silverpeas.core.i18n.ResourceTranslation getTranslation​(String language)

      Specified by:
        `getTranslation` in interface `org.silverpeas.core.i18n.LocalizedResource`
      Specified by:
        `getTranslation` in interface `org.silverpeas.core.i18n.Translatable`

    - #### getModel

          public org.silverpeas.core.contribution.model.ContributionModel getModel()

      Specified by:
        `getModel` in interface `org.silverpeas.core.contribution.model.Contribution`