cancel
Showing results for 
Search instead for 
Did you mean: 

Associating an existing metadata extractor to new extension

sergio
Champ in-the-making
Champ in-the-making
Hi all.

I would like to know how it is possible to associate an already existing metadata extractor to a file with a proprietary extension (for which it has sense to extract specific metadata).

For example, suppose I have a file whith extension .prop for which I am sure that some existing metadata could be extracted.

Many thanks to everyone.

Sergio
14 REPLIES 14

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

You should create a custom metadata extracter as an extension and associate it with your new mime-type (eg. text/prop). Then copy the code from the Alfresco extracter that you think will work with this mime-type.

Cheers,

–Aladdin

amarendrakt
Champ on-the-rise
Champ on-the-rise
Hi All,

   I developed Custom metadata extractor which will work for my custom contents but the problem is how to updat the custom property using this extractor.
Title,Author etc are coming by default from files only but I want my custom property also should be recovered by Alfresco from these files (PDF Form Files). I have used PDFBox to read PDF Forms which will read all textfields like Status,Customer Name etc. and then I want to use this information to display automatically while uploading the content in Alfresco i.e. Alfresco should extract this information.I done the necessary changes and it is able to read these properties however it is nt able to display it in Content Properties Dialog which comes just after uploading the document.

Can you please guide me on this? Its very Urgent

kevinr
Star Contributor
Star Contributor
Have you looked at this page?
http://wiki.alfresco.com/wiki/Displaying_Custom_Metadata#Viewing_Aspect_Properties_in_the_Web_Client...

You also need to add a rule that applies the aspect containing the custom property definition to your content - the properties screen you have configured will then show the attributes that have been extracted by your code.

Thanks,

Kevin

amarendrakt
Champ on-the-rise
Champ on-the-rise
Thanks for your reply.

   I'm able to configure custom properties screen but I'm not able to show the data extracted from PDF in this screen.What are the changes need to be done in Alfresco files or is it required to develope new class for this.
I have developed new AddContentDialog class in which I'm adding these custom property along with the the default properties like title and author.It is reading those properties but not able to show it up on the screen.

What could be the problem?

I hope you got my question.

Thanks in Advance

amarendrakt
Champ on-the-rise
Champ on-the-rise
Thanks for your reply,

   I want to associate my custom property with the fields that I am reading form PDF form files. I am able to read these properties but not able to associate it with my custom content properties.

Plz guide me on this.

Thanks in Advance.

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

You shouldn't need to create a custom dialog for this. The things you need to do are:

- Create a custom content type that either:
    a) Has the custom properties you need, or
    b) Is associated with an aspect that carries those custom properties

- Create a custom metadata extracter that:
    a) Is associated with the mimetype you are extracting from (if it's PDF then keep in mind that Alfresco comes with a PDF metadata extracter so you should make sure you carry the current functionality as well)
    b) Extracts the custom metadata from the node being added and sets the properties in the node  (you must set the properties for them to be assigned correctly)

- Configure the web client to display those custom properties.

- Make sure that when your custom content type is used the aspect is applied. You can verify this using the Node Browser.

- Try running the action "Extract common metadata…" on a node with the custom content type to test. The custom properties should be displayed in the details page.

Hope this helps,

–Aladdin

amarendrakt
Champ on-the-rise
Champ on-the-rise
Thanks For yor help.
I'm really thankful for your help but code worked very well but now it is showing Integrity Failure Error when the document is uploaded.

Previously it was working really great.
Can you guide me why may be this error occur?

Plz help me.Its really very urgent.
Thanks in Advance.

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

Can you post more details about the exception you're getting?

Cheers,

–Aladdin

stebans
Champ in-the-making
Champ in-the-making
Hi all,

I've posted on another thread about Metadata Extracter already,  but unfortunately, I haven't had any answer yet and I really need to be able to update custom metadata fields with extracted metadata.
As an example, I would start on updating the "my:authorisedBy" field from the exampleModel with some string value.

I have created what I think is the simplest way to set a value to this metadata. Maybe it's the wrong way, but still, I don't understand why it doesn't work.
package my.test;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;

import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.metadata.AbstractMetadataExtracter;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.namespace.QName;

public class MyMetadataUpdater extends AbstractMetadataExtracter {
   public static String[] SUPPORTED_MIMETYPES = new String[] {
         MimetypeMap.MIMETYPE_WORD
        };

   static final QName PROP_AUTHOR = QName.createQName(
         "http://www.alfresco.org/model/content/1.0", "author");

   static final QName PROP_AUTHORISEDBY = QName.createQName("my.new.model",
         "authorisedBy");

   public MyMetadataUpdater() {
      super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)), 1.0,
            1000);
   }

   public void extractInternal(ContentReader reader,
         final Map<QName, Serializable> destination) throws Throwable {

      trimPut(PROP_AUTHOR, "Someone", destination);
      trimPut(PROP_AUTHORISEDBY, "Myself", destination);
   }
}
which is exported as a jar in lib dir, and registered by replacing the OfficeMetadataExtracter (It might be a wrong idea of course, but it's for the purpose of the test) in content-services-context.xml file:
   <!– <bean id="extracter.Office" class="org.alfresco.repo.content.metadata.OfficeMetadataExtracter" parent="baseMetadataExtracter" /> –>
   <bean id="extracter.Office" class="my.test.MyMetadataUpdater" parent="baseMetadataExtracter" />

Result:
    author = "Someone"
    authorisedBy remains empty!

I really hope someone can help.
Best regards
Stéphane

I use for this example: alfresco-nightly-build of 2007, June 11th.