1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.chemistry.opencmis.client.parser;
20
21 import java.io.File;
22 import java.util.Map;
23
24 import org.apache.chemistry.opencmis.client.mapper.MapperException;
25 import org.apache.chemistry.opencmis.client.mapper.PropertyMapper;
26 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
27
28 /**
29 * This interface is used to extract metadata from content. An instance is
30 * responsible to parse the content and extract the metadata. The metadata
31 * must be stored in a CMIS property bag. Implementations of this class are
32 * created by the Configurator depending on the Content-Type to parse and
33 * the corresponding parser configuration
34 *
35 * @author Jens
36 *
37 */
38 public interface MetadataParser {
39
40 /**
41 * Initialize a parser with a given property mapper and a content type
42 * @param mapper
43 * PropertyMapper used to map tags to properties and convert values
44 * @param contentType
45 * content type of file to extract
46 */
47 void initialize(PropertyMapper mapper, String contentType);
48
49 /**
50 * get ready for parsing a new file
51 */
52 void reset();
53
54 /**
55 * Parse a file and extract all metadata and store them in a CMIS property bag
56 * @param f
57 * file to parse
58 * @throws MapperException
59 */
60 void extractMetadata(File f, TypeDefinition td) throws MapperException;
61
62 /**
63 * Return all found metadata, called after parsing is completed.
64 * @return
65 * extracted CMIS properties
66 */
67 Map<String, Object> getCmisProperties();
68
69 /**
70 * get all content types handled by this parser
71 * @return
72 * array with content types
73 */
74 String[] getContentTypes();
75
76 /**
77 * get the CMIS type id used by this type
78 * @return
79 * CMIS type id
80 */
81 String getMappedTypeId();
82
83 /**
84 * get the associated property mapper for this CMIS type
85 *
86 * @return
87 * property mapper
88 */
89 PropertyMapper getMapper();
90 }