cancel
Showing results for 
Search instead for 
Did you mean: 

PHP SDK - getting (custom) file properties

wielo
Champ in-the-making
Champ in-the-making
I'm currently implementing something with alfresco for a client. The client has an enterprise alfresco, and I'm using CMIS (i guess?) to download some of there files in certain folders, so it can be shown on their website.

I'm using the php-sdk to communicate with alfresco.
I succeeded in looping over the folders/subfolders/files.

When I view the file in alfresco, I can see some properties (screenshot: <a href="http://cl.ly/image/2l252x0n2Z39">http://cl.ly/image/2l252x0n2Z39</a> (I blurred some text for privacy reasons)).
How can I get these properties from the API? (properties that I need are size, publication level, products and record types).

(note that I have no experience with alfresco at all and it's literally the first time I do something with it).

Thanks in advance!
Lowie
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
Which PHP SDK are you using? If you are using the one on Google Code, you are not using CMIS, you are using Web Services. The PHP SDK on Google Code has pretty good documentation. One of the things it includes is a tutorial about properties, see: https://code.google.com/p/alfresco-php-sdk/wiki/PHPTutorialThree.

If, on the other hand, you are using the PHP CMIS API, available from Apache Chemistry, you are using CMIS. The documentation for getProperties lives here: http://chemistry.apache.org/php/docs/atom/classes/CMISService.html#getProperties

If you are using this PHP CMIS API, I recommend downloading and running the Apache Chemistry OpenCMIS Workbench. That will let you inspect the objects and properties as CMIS sees them, including figuring out what a property's ID is.

In general, accessing custom properties is no different than accessing the out-of-the-box properties. You just need to know the property's name.

Jeff

wielo
Champ in-the-making
Champ in-the-making
I'm using the PHP SDK from google code. So I'm actually using the Web Services.
I tried doing the same as in the tutorial about properties and now I can see the custom property names, but some of them are NULL, while they actually have values if I view the file in alfresco itself.

The property I need is {http://www.domain.eu/alfresco/namespace}products (I removed their domain). But the value is NULL.
On my screenshot in the previous post, you can see the properties do have values.
I have the same problem for other properties such as publicationLevel, materialNumber, … All of these properties are custom properties (they are prepended with the namespace  {http://www.domain.eu/alfresco/namespace}).

Thanks for your help!

jpotts
World-Class Innovator
World-Class Innovator
Make sure your code has the same node you are looking at in the user interface. One way to do this is to dump the node reference and ensure that it is the same. The only other thing I can think of that would cause the values to be null is if you are using the wrong namespace. Check your content model XML to make sure that the namespace for those specific properties is what you think it is.

Jeff

wielo
Champ in-the-making
Champ in-the-making
I'm sure the node reference is the same.
The property namespace is {http://www.domain.eu/alfresco/namespace} and the property name is products.
Where can I find the content model XML?

jpotts
World-Class Innovator
World-Class Innovator
The location of the content model is up to the person who deployed it. If they deployed it as an amp it will be under $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco/module/[some_module_name]/[possibly_some_other_sub-dir]/somename.xml.

If it was not deployed as an AMP it may be under $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco/extension or some directory under that.

Hopefully it was not deployed somewhere else, but the only technical requirement is that it is found somewhere on the classpath.

It could also have been deployed using a "hot deploy" to the repository itself under /Data Dictionary/Models.

Jeff