|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ContentType.java | 50% | 66.7% | 75% | 66.7% |
|
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | package org.apache.xindice.webadmin.webdav.components.props; | |
19 | ||
20 | import org.apache.xindice.core.Collection; | |
21 | import org.apache.xindice.core.data.Entry; | |
22 | import org.apache.xindice.webadmin.PartialResponse; | |
23 | import org.apache.xindice.webadmin.util.MimeTable; | |
24 | ||
25 | /** | |
26 | * ContentType creates a response node that identifies content type of | |
27 | * the collection entry. It is not applicable for collections and always | |
28 | * contains "text/xml" for documents. For binary entries ContentType | |
29 | * attemps to guess content type, if unsuccessful, it will assume default | |
30 | * binary type of "application/octet-stream". | |
31 | * <br/><br/> | |
32 | * Example: | |
33 | * <pre> | |
34 | * <getcontenttype> | |
35 | * text/xml | |
36 | * </getcontenttype> | |
37 | * </pre> | |
38 | * | |
39 | * @version $Revision: 541515 $, $Date: 2007-05-24 19:45:06 -0700 (Thu, 24 May 2007) $ | |
40 | */ | |
41 | public class ContentType implements DAVProperty { | |
42 | private static final String CONTENT_TYPE = "getcontenttype"; | |
43 | ||
44 | 2 | public String getName() { |
45 | 2 | return CONTENT_TYPE; |
46 | } | |
47 | ||
48 | 0 | public PartialResponse.Content getRootProperty() { |
49 | 0 | return null; |
50 | } | |
51 | ||
52 | 7 | public PartialResponse.Content getProperty(Collection col) { |
53 | 7 | return null; |
54 | } | |
55 | ||
56 | 5 | public PartialResponse.Content getProperty(Entry entry) { |
57 | 5 | if (entry.getEntryType() == Entry.DOCUMENT) { |
58 | 5 | return new PartialResponse.Content(CONTENT_TYPE, MimeTable.XML_MIME_TYPE); |
59 | } else { | |
60 | 0 | return new PartialResponse.Content(CONTENT_TYPE, MimeTable.getMimeType(entry.getKey().toString())); |
61 | } | |
62 | } | |
63 | ||
64 | } |
|