cancel
Showing results for 
Search instead for 
Did you mean: 

Getting file name

carolanna
Champ in-the-making
Champ in-the-making
Hi..
using this code am able to get the node value.
      if (rows != null)
        {
            for (int x = 0; x < rows.length; x++)
            {
               ResultSetRow row1 = rows[x];
               
                NamedValue[] columns = row1.getColumns();
                for (int y = 0; y < columns.length; y++)
                {
                  System.out.println("row " + x + ": "
                            + row1.getColumns(y).getName() + " = "
                            + row1.getColumns(y).getValue());
               }
}


the value am getting output is
/{http://www.alfresco.org/model/application/1.0}company_home/{}cm_x003a_newq30000012d130833e90132.sub

i need output file name
that is newq30000012d130833e90132.sub. can anyone help me :cry:
3 REPLIES 3

mrogers
Star Contributor
Star Contributor
That looks like a path in a string format rather than the name.     The last part is often the same as the name property but can be different, either by choice or design (e.g multiple assocs to the same file).

And it's curious since it seems to have a spurious "cm:" and a blank namespace.   I suspect that the code that created it was not correct w.r.t the qname used.

If you want to go from a path in string format and are not interested in the the namespaces then simply use a regex to match the name part only i.e. ignore the text between { and} Split on the dir separator char '/' and then ISO9075 decode the last element.      ]

However If you are using the Java API then should you not be simply getting the Name property of the node?   Or if you are working with a Path then do you have a Path object that will hold QNames already so you don't need to convert to string format and back again?

carolanna
Champ in-the-making
Champ in-the-making
thanks. but in alfresco web client the file looks as newq30000012d130833e90132.sub. Is it using some method/function to get file name or by using regexp.

mrogers
Star Contributor
Star Contributor
I suspect its just displaying the Name property.