4

I was wondering that we have two properties in TcmUri class - ContextRepositoryId and PublicationId both of these supposedly gives us the Publication ID from a TCM URI passed in the constructor and in most of the scenario gives same result.

If I google, then everywhere it is recommended to use the TcmUri.PublicationId if we would like to retrieve the Publication ID from a TCM URI whereas the TcmUri.ContextRepositoryID is more precise as compared to the TcmUri.PublicationId

My questions:

  • Any rational behind having these two properties
  • Is it OK to use TcmUri.ContextRepositoryID in all scenario as TcmUri.PublicationId would fail if TCM URI of a publication is passed to it.
5

The concept of a Repository was introduced with the .NET implementation of Tridion (so 5.3 I should think). .NET allowed for a class hierarchy, as opposed to the strictly interface-based approach of COM. Until then, and indeed, until now, the only kind of Repository in Tridion is a Publication.

The Context Repository of an item is a BluePrinting concept. It's the repository in which you have accessed the item. So if I open an item called tcm:5-1234, its context repository will be 5. If it's not really there, and only a shared item that lives in a different place in the blueprint, it's Owning Repository could be different. So if my component is shared from publication 3, its Owning repository would be 3.

So as things stand now, the Context Repository of an item will always be its Publication. If there were ever to be another kind of repository, then presumably items in it wouldn't have a Publication, while the Context Repository would be expected to be available. (An item has to live somewhere, right? Obviously, System items live in their own special place.)

So if you're writing code that deals with publications specifically, you might use Publication.Id. In general, though, most often when you need to know what the repository/publication is, you are doing something with BluePrinting. Although we often talk of Publications when dealing with BluePrinting, it's actually Repositories that do BluePrinting; Publications just inherit this behaviour, so for BluePrinting work, use the Repository.

| improve this answer | |
  • perfect answer Dom; this clarifies the thing – Pankaj Gaur Sep 15 '14 at 1:23
2

The main difference I can see - value of this properties for SystemWideObjects:

 publication.Id = tcm:0-4-1
 publication.Id.PublicationId = -1
 publication.Id.ContextRepositoryId = 4
 approvalStatus.Id = tcm:0-2-131073
 approvalStatus.Id.PublicationId = -1
 approvalStatus.Id.ContextRepositoryId = 0

So: For RepositoryLocalObjects there is no difference. For SystemWideObjects properties have different behavior: publicationId is always -1, ContextRepositoryId returns exact the publication value of the item.

| improve this answer | |
  • So that is my question - what is the significance of publicationId property when ContextRepositoryId can be used in all scenarios – Pankaj Gaur Sep 13 '14 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.