001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package javax.jbi.messaging;
018    
019    import java.util.Set;
020    
021    import javax.activation.DataHandler;
022    import javax.security.auth.Subject;
023    import javax.xml.transform.Source;
024    
025    /**
026     * Represents a JBI Normalized Message.
027     *
028     * @author JSR208 Expert Group
029     */
030    public interface NormalizedMessage {
031    
032        /**
033         * Add an attachment to the message.
034         *
035         * @param id unique identifier for the attachment
036         * @param content attachment content
037         * @throws MessagingException failed to add attachment
038         */
039        void addAttachment(String id, DataHandler content) throws MessagingException;
040    
041        /**
042         * Retrieve the content of the message.
043         *
044         * @return message content
045         */
046        Source getContent();
047    
048        /**
049         * Retrieve attachment with the specified identifier.
050         *
051         * @param id unique identifier for attachment
052         * @return DataHandler representing attachment content, or null if an attachment
053         *         with the specified identifier is not found
054         */
055        DataHandler getAttachment(String id);
056    
057        /**
058         * Returns a list of identifiers for each attachment to the message.
059         *
060         * @return iterator over String attachment identifiers
061         */
062        Set getAttachmentNames();
063    
064        /**
065         * Removes attachment with the specified unique identifier.
066         *
067         * @param id attachment identifier
068         * @throws MessagingException failed to remove attachment
069         */
070        void removeAttachment(String id) throws MessagingException;
071    
072        /**
073         * Set the content of the message.
074         *
075         * @param content message content
076         * @throws MessagingException failed to set content
077         */
078        void setContent(Source content) throws MessagingException;
079    
080        /**
081         * Set a property on the message.
082         *
083         * @param name property name
084         * @param value property value
085         */
086        void setProperty(String name, Object value);
087    
088        /**
089         * Set the security Subject for the message.
090         *
091         * @param subject Subject to associated with message.
092         */
093        void setSecuritySubject(Subject subject);
094    
095        /**
096         * Retrieve a list of property names for the message.
097         *
098         * @return list of property names
099         */
100        Set getPropertyNames();
101    
102        /**
103         * Retrieve a property from the message.
104         *
105         * @param name property name
106         * @return property value, or null if the property does not exist
107         */
108        Object getProperty(String name);
109    
110        /**
111         * Retrieve the security Subject from the message.
112         *
113         * @return security Subject associated with message, or null.
114         */
115        Subject getSecuritySubject();
116    }