6

I'm trying to access the publication data (PUBLICATION_PATH) by its publicationId in a java class with the deployer API, but I'm not able to find any class or method to map the Publication object.

With odata seems too complicated to such a little need, and I'm not sure I can access de odata webservice.

" ... new Publication(pubId); " creates an empty publication.

Is there a way to access de persistence model of the database? My solution is in the following class/method:

JPAPublicationDAO.findById(int publicationId)

In the public API the only class of JPA is "JPAQueryDAO". So I don't know if it's possible to access JPAPublicationDAO.

Does anyone knows how can I do it?

7

The proper way to get a publication already stored in the Broker storage is to use the PublicationDAO. Here is an example of how this could be done (for a publication if Id=3):

final int publicationId = 3;
final PublicationDAO publicationDAO = (PublicationDAO) StorageManagerFactory.getDAO(publicationId, StorageTypeMapping.PUBLICATION);
final Publication publication = publicationDAO.findById(publicationId);
if (publication != null) {
    System.out.println(publication.getPublicationPath());
}

Hope this helps.

| improve this answer | |
  • Great! That was exactly what I was looking for! I think is a general way to access DAO objects. – Raúl Escudero Apr 15 '13 at 11:41
  • 1
    Correct Raul. This is a generic mechanism to access the Broker storage. You can replace "publication" with the type you're interested and it will probably work. The DAO interfaces are defined in the "com.tridion.storage.dao" package. – Daniel Neagu Apr 15 '13 at 12:26
2

In a deployer extension you should probably use the com.tridion.transport.transportpackage.Publication class, but can't really find a good example right now.

It seems like you'd have to load this from the current ProcessingInstructions rather than trying to initialize a new one (as it could be the first time you're publishing something from a given publication and therefore the Storage layer wouldn't know about this publication yet).

| improve this answer | |

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.