01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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: */package org.apache.cxf.interceptor;
19:
20: import java.io.IOException;
21: import java.util.logging.Logger;
22:
23: import org.apache.cxf.attachment.AttachmentDeserializer;
24: import org.apache.cxf.message.Message;
25: import org.apache.cxf.phase.AbstractPhaseInterceptor;
26: import org.apache.cxf.phase.Phase;
27:
28: public class AttachmentInInterceptor extends
29: AbstractPhaseInterceptor<Message> {
30:
31: public static final String ATTACHMENT_DIRECTORY = "attachment-directory";
32: public static final String ATTACHMENT_MEMORY_THRESHOLD = "attachment-memory-threshold";
33: public static final int THRESHHOLD = 1024 * 100;
34: private static final Logger LOG = Logger
35: .getLogger(AttachmentInInterceptor.class.getName());
36:
37: /**
38: * contruct the soap message with attachments from mime input stream
39: *
40: * @param messageParam
41: */
42:
43: public AttachmentInInterceptor() {
44: super (Phase.RECEIVE);
45: }
46:
47: public void handleMessage(Message message) {
48: if (isGET(message)) {
49: LOG
50: .info("AttachmentInInterceptor skipped in HTTP GET method");
51: return;
52: }
53:
54: String contentType = (String) message.get(Message.CONTENT_TYPE);
55: if (contentType != null
56: && contentType.toLowerCase().indexOf(
57: "multipart/related") != -1) {
58: AttachmentDeserializer ad = new AttachmentDeserializer(
59: message);
60: try {
61: ad.initializeAttachments();
62: } catch (IOException e) {
63: throw new Fault(e);
64: }
65: }
66: }
67:
68: public void handleFault(Message messageParam) {
69: }
70:
71: }
|