cancel
Showing results for 
Search instead for 
Did you mean: 

Pass author name with file properties ...

kannank
Champ in-the-making
Champ in-the-making
Hi,

Please refer my post http://forums.alfresco.com/viewtopic.php?t=1838 - I need to get transfer the author name when uploading file in .NET 2003 / .NET 2005. All other properties like filename,description etc are getting transferred with the file except field "author".

I have tested the mysql database and understood that author name data is available in the node_properties table and still it is not displayed in the webclient.I need to solve this very urgently.

Any earlier reply must be appreciated.

Looking for some one to help,

Thanks,

K.Kannan.
5 REPLIES 5

rivetlogic
Champ on-the-rise
Champ on-the-rise
The content item must have the aspect cm:author applied to it first.

By default, content added doesn't have the cm:author aspect applied, and therefore you must apply that before you try to set the author field.

Hope that helps.

–Sumer

kannank
Champ in-the-making
Champ in-the-making
Hi,

Thanks for your immediate response.I need some more help from you.

I am not sure what you are referring to "cm:author" - How to apply that before set author field?

Please give me some suggestion or sample code for applying cm:author - Looking for your immediate help in this regard.

Thanks,

K.Kannan.

rivetlogic
Champ on-the-rise
Champ on-the-rise
There is a Web Service call that allows you to add an aspect to a content item. The aspect you want to add is:
{http://www.alfresco.org/model/content/1.0}author

This aspect is defined in the default Content Model as:
      <aspect name="cm:author">
         <title>Author</title>
         <properties>
            <property name="cm:author">
               <title>Author</title>
               <type>d:text</type>
            </property>
         </properties>
      </aspect>
After using WebServices to create the content item, try adding the author aspect before you set the properties (meta-data) and you should be okay.

To see what aspects are added to a content item, use the doc_info.ftl template to preview the item in the Web Client UI.

Best of luck.

–Sumer

kannank
Champ in-the-making
Champ in-the-making
Hi,

Thanks again for your very quick response - Still some information is not clearer to me, how to add aspect before setting the properties - My code is in C# dotnet language and I have attached the full working code below - Everything works fine in this code except that the author name is not transferred with the uploaded file or image,

The working code in .NET 2003 is,

Alfresco.RepositoryWebService.Reference reference   = new Alfresco.RepositoryWebService.Reference();
reference.store                                     = this.spacesStore;
reference.uuid                                      = node.id;

// Create the reference for the node selected.
Alfresco.ContentWebService.Store spacesStore2       = new Alfresco.ContentWebService.Store();
spacesStore2.scheme                                 = Alfresco.ContentWebService.StoreEnum.workspace;
spacesStore2.address                                = "SpacesStore";

// Parent references.
this.parentReferences.Add(this.currentReference);

// Write the contents into the node.
ContentFormat formatval = new ContentFormat();
formatval.mimetype      = "application/octet-stream";                   

// Get the text value from file.
FileStream fsfile = null;
fsfile = File.Open("D:\\test.cpy", FileMode.Open);
byte[] toSend = new byte[fsfile.Length];
fsfile.Read(toSend, 0, System.Convert.ToInt32(fsfile.Length));
fsfile.Close();

NamedValue[] properties = new NamedValue[] { new NamedValue(), new NamedValue(), new NamedValue(), new NamedValue(), new NamedValue() };
properties[0].name = "{http://www.alfresco.org/model/content/1.0}name";
properties[0].value  = "test.cpy";

properties[1].name = "{http://www.alfresco.org/model/content/1.0}title";
properties[1].value = "Title";

properties[2].name = "{http://www.alfresco.org/model/content/1.0}creator";
properties[2].value = "Creator";

properties[3].name = "{http://www.alfresco.org/model/content/1.0}description";
properties[3].value = "Test Description";

properties[4].name = "{http://www.alfresco.org/model/content/1.0}author";
properties[4].value = "Author12";                
                     
                                                                                 
Alfresco.RepositoryWebService.ParentReference parent    = new Alfresco.RepositoryWebService.ParentReference();
parent.store                                            = reference.store;
parent.uuid                                             = reference.uuid;
parent.associationType                                  = "{http://www.alfresco.org/model/content/1.0}contains";
parent.childName                                        = "{http://www.alfresco.org/model/content/1.0}" + "siradev.pdf";
                         
CMLCreate create  = new CMLCreate();
create.id            = "1";
create.parent     = parent;
create.property  = properties;
create.type        = "{http://www.alfresco.org/model/content/1.0}content";
                          
CML cml          = new CML();
cml.create       = new CMLCreate[1] {(create)};

UpdateResult[] result = repoService.update(cml);
Alfresco.RepositoryWebService.Reference newcontentnode  = result[0].destination;
                          
Alfresco.ContentWebService.Reference reference2 = new Alfresco.ContentWebService.Reference();
reference2.store= spacesStore2;
reference2.uuid = newcontentnode.uuid;                    

populateListBox(reference);

this.contentService.write(reference2, "{http://www.alfresco.org/model/content/1.0}content", toSend, formatval);

This is the working code - Please tell me some suggestion how to "Add aspect cm:author" in this .NET code in order to get the author name along with the uploaded file or image.

Thanks and Looking for your earlier message,

K.Kannan.

janaka1984
Star Contributor
Star Contributor
Hi,

i need to know when pass query into search.queryResultSet() include facets in "search.lib.js" , it return number of document under particular facets name

eg. {http://www.alfresco.org/model/content/1.0}author

result is

@{http://www.alfresco.org/model/content/1.0}author[2]

author
jana (1)
wee (1)

i named document autor as "jana wee", but it return as jana and wee seperatly from search.queryResultSet(). how can i avoid this issue?

Regards
Janaka