cancel
Showing results for 
Search instead for 
Did you mean: 

java program to manage the alfresco content

argaze20
Champ in-the-making
Champ in-the-making
good evening,

I want to make an integration of existing data (files doc or PDF) in alfresco from a java program, I managed to make a connection  with alfresco code,  but for the inclusion of files with their meta data, i do not find the code who can do that. if someone has already done it or he has informations or links that can help me I would be very grateful.
thank you and good navigation.
2 REPLIES 2

zaizi
Champ in-the-making
Champ in-the-making
We've done this for a client. They have lots of documents and the meta-data for the documents is in a separate database. We created different ways for users to upload the documents and Alfresco automatically looks up the meta-data from the separate database and adds it to the document's meta-data in Alfresco. This can then be searched from within Alfresco.

We did it in couple of different ways, because different types of users. E.g. power users want quick and efficient and occasional users want a step-by-step wizard.

The basics are this;
1. Upload the document.
2. Use an existing aspect such as dublin core or define your custom aspect to hold your own metadata. This is a good tutorial on content modeling and how to add custom aspect: http://ecmarchitect.com/archives/2007/06/09/756
3. Look up meta-data from the external application or database. This can be done through simple Spring JDBC: http://static.springframework.org/spring/docs/2.5.x/reference/jdbc.html.
4. Add the aspect with the meta-data you've looked up. The code below demonstrates this. This example is from the Alfresco SDK TaggingSample.

   
   /**
    * This action will take the comma separated list of tags and add them
    * separately to the tags property after applying the taggable aspect.
    *
    * If no tags are supplied the aspect is still applied.
    */
   @Override
   protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
   {
      if (this.nodeService.exists(actionedUponNodeRef) == true)
      {
         // add the aspect if it is not already present on the node
         QName tagAspect = QName.createQName("extension.tags", "taggable");
         if (this.nodeService.hasAspect(actionedUponNodeRef, tagAspect) == false)
         {
            this.nodeService.addAspect(actionedUponNodeRef, tagAspect, null);
         }
        
         // create the tags as a list
         String tags = (String)action.getParameterValue(PARAM_TAGS);
         List<String> tagsList = new ArrayList<String>();
         if (tags != null && tags.length() > 0)
         {
            StringTokenizer tokenizer = new StringTokenizer(tags, ",");
            while (tokenizer.hasMoreTokens())
            {
               tagsList.add(tokenizer.nextToken().trim());
            }
         }
        
         // set the tags property
         QName tagsProp = QName.createQName("extension.tags", "tags");
         this.nodeService.setProperty(actionedUponNodeRef, tagsProp, (Serializable)tagsList);
      }

mahdi
Champ in-the-making
Champ in-the-making
hi zaizi,
i 'm working on a similair project :
1- create a new content type (which is in fact, a table (named project) in my database) with new metadatas (the fileds of the table)
2- import a new document
3- assign the type content to the doc
4- import the values of metadata from the database  automaticlly.( the import is related to the number of project (numproj) which is the primary key of the table project)

i'm now trapped in the step 4

in fact i want to, when i tape the value of  numproj, the rest of metadata will automaticlly imported from the table)

i tried to update the add-content-Dialog.jsp but i didn't find how to manipulate the metadatas


can you please post your work or show me how to do?
i passed more than a week on this project, so please help?  Smiley Sad