Advertisement
Guest User

shmoula

a guest
Mar 26th, 2008
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. package cz.shmoula;
  2.  
  3. import java.io.Serializable;
  4. import java.util.Arrays;
  5. import java.util.HashSet;
  6. import java.util.Map;
  7. import java.io.File;
  8.  
  9. import org.alfresco.repo.content.MimetypeMap;
  10. import org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter;
  11. import org.alfresco.service.cmr.repository.ContentReader;
  12. import org.alfresco.util.TempFileProvider;
  13.  
  14.  
  15. public class ASDMetadataExtracter extends AbstractMappingMetadataExtracter{
  16.     private static final String KEY_DESCRIPTION = "description";
  17.     private static final String KEY_POKUS = "pokus";
  18.    
  19.     public static String[] SUPPORTED_MIMETYPES = new String[] {
  20.             MimetypeMap.MIMETYPE_TEXT_PLAIN
  21.     };
  22.  
  23.     public ASDMetadataExtracter(){
  24.         super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)));
  25.     }
  26.  
  27.     @Override
  28.     public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable{
  29.         Map<String, Serializable> rawProperties = newRawMap();
  30.        
  31.  
  32.         File tempFile = TempFileProvider.createTempFile("ASDMetadataExtracter_", ".tmp");
  33.         try{
  34.             reader.getContent(tempFile);
  35.             long size = reader.getSize();
  36.            
  37.             putRawValue(KEY_DESCRIPTION, "Tadyk je nejakej popisek", rawProperties);
  38.             putRawValue(KEY_POKUS, Long.toString(size), rawProperties);
  39.         }
  40.         finally{
  41.             tempFile.delete();
  42.         }
  43.         return rawProperties;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement