src/share/jaxws_classes/com/sun/xml/internal/ws/message/jaxb/AttachmentMarshallerImpl.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
23 * questions. 23 * questions.
24 */ 24 */
25 25
26 package com.sun.xml.internal.ws.message.jaxb; 26 package com.sun.xml.internal.ws.message.jaxb;
27 27
28 import com.sun.istack.internal.logging.Logger;
28 import com.sun.xml.internal.ws.api.message.Attachment; 29 import com.sun.xml.internal.ws.api.message.Attachment;
29 import com.sun.xml.internal.ws.api.message.AttachmentSet; 30 import com.sun.xml.internal.ws.api.message.AttachmentSet;
30 import com.sun.xml.internal.ws.message.AttachmentSetImpl;
31 import com.sun.xml.internal.ws.message.DataHandlerAttachment; 31 import com.sun.xml.internal.ws.message.DataHandlerAttachment;
32 32
33 import javax.activation.DataHandler; 33 import javax.activation.DataHandler;
34 import javax.xml.bind.attachment.AttachmentMarshaller; 34 import javax.xml.bind.attachment.AttachmentMarshaller;
35 import javax.xml.ws.WebServiceException; 35 import javax.xml.ws.WebServiceException;
37 import java.net.MalformedURLException; 37 import java.net.MalformedURLException;
38 import java.net.URI; 38 import java.net.URI;
39 import java.net.URISyntaxException; 39 import java.net.URISyntaxException;
40 import java.net.URLEncoder; 40 import java.net.URLEncoder;
41 import java.util.UUID; 41 import java.util.UUID;
42 import java.util.logging.Level;
42 43
43 /** 44 /**
44 * Implementation of {@link AttachmentMarshaller}, its used from JAXBMessage to marshall swaref type 45 * Implementation of {@link AttachmentMarshaller}, its used from JAXBMessage to marshall swaref type
45 * 46 *
46 * @author Vivek Pandey 47 * @author Vivek Pandey
47 * @see JAXBMessage 48 * @see JAXBMessage
48 */ 49 */
49 final class AttachmentMarshallerImpl extends AttachmentMarshaller { 50 final class AttachmentMarshallerImpl extends AttachmentMarshaller {
51
52 private static final Logger LOGGER = Logger.getLogger(AttachmentMarshallerImpl.class);
53
50 private AttachmentSet attachments; 54 private AttachmentSet attachments;
51 55
52 public AttachmentMarshallerImpl(AttachmentSet attachemnts) { 56 public AttachmentMarshallerImpl(AttachmentSet attachemnts) {
53 this.attachments = attachemnts; 57 this.attachments = attachemnts;
54 } 58 }
58 */ 62 */
59 void cleanup() { 63 void cleanup() {
60 attachments = null; 64 attachments = null;
61 } 65 }
62 66
67 @Override
63 public String addMtomAttachment(DataHandler data, String elementNamespace, String elementLocalName) { 68 public String addMtomAttachment(DataHandler data, String elementNamespace, String elementLocalName) {
64 // We don't use JAXB for handling XOP 69 // We don't use JAXB for handling XOP
65 throw new IllegalStateException(); 70 throw new IllegalStateException();
66 } 71 }
67 72
73 @Override
68 public String addMtomAttachment(byte[] data, int offset, int length, String mimeType, String elementNamespace, String elementLocalName) { 74 public String addMtomAttachment(byte[] data, int offset, int length, String mimeType, String elementNamespace, String elementLocalName) {
69 // We don't use JAXB for handling XOP 75 // We don't use JAXB for handling XOP
70 throw new IllegalStateException(); 76 throw new IllegalStateException();
71 } 77 }
72 78
79 @Override
73 public String addSwaRefAttachment(DataHandler data) { 80 public String addSwaRefAttachment(DataHandler data) {
74 String cid = encodeCid(null); 81 String cid = encodeCid(null);
75 Attachment att = new DataHandlerAttachment(cid, data); 82 Attachment att = new DataHandlerAttachment(cid, data);
76 attachments.add(att); 83 attachments.add(att);
77 cid = "cid:" + cid; 84 cid = "cid:" + cid;
84 if (ns != null && (ns.length() > 0)) { 91 if (ns != null && (ns.length() > 0)) {
85 try { 92 try {
86 URI uri = new URI(ns); 93 URI uri = new URI(ns);
87 cid = uri.toURL().getHost(); 94 cid = uri.toURL().getHost();
88 } catch (URISyntaxException e) { 95 } catch (URISyntaxException e) {
89 e.printStackTrace(); 96 if (LOGGER.isLoggable(Level.INFO)) {
97 LOGGER.log(Level.INFO, null, e);
98 }
90 return null; 99 return null;
91 } catch (MalformedURLException e) { 100 } catch (MalformedURLException e) {
92 try { 101 try {
93 cid = URLEncoder.encode(ns, "UTF-8"); 102 cid = URLEncoder.encode(ns, "UTF-8");
94 } catch (UnsupportedEncodingException e1) { 103 } catch (UnsupportedEncodingException e1) {

mercurial