Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.shmoula;
- import java.io.Serializable;
- import java.util.Arrays;
- import java.util.HashSet;
- import java.util.Map;
- import java.io.File;
- import org.alfresco.repo.content.MimetypeMap;
- import org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter;
- import org.alfresco.service.cmr.repository.ContentReader;
- import org.alfresco.util.TempFileProvider;
- public class ASDMetadataExtracter extends AbstractMappingMetadataExtracter{
- private static final String KEY_DESCRIPTION = "description";
- private static final String KEY_POKUS = "pokus";
- public static String[] SUPPORTED_MIMETYPES = new String[] {
- MimetypeMap.MIMETYPE_TEXT_PLAIN
- };
- public ASDMetadataExtracter(){
- super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)));
- }
- @Override
- public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable{
- Map<String, Serializable> rawProperties = newRawMap();
- File tempFile = TempFileProvider.createTempFile("ASDMetadataExtracter_", ".tmp");
- try{
- reader.getContent(tempFile);
- long size = reader.getSize();
- putRawValue(KEY_DESCRIPTION, "Tadyk je nejakej popisek", rawProperties);
- putRawValue(KEY_POKUS, Long.toString(size), rawProperties);
- }
- finally{
- tempFile.delete();
- }
- return rawProperties;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement