Package org.apache.muse.ws.notification.topics.impl

Source Code of org.apache.muse.ws.notification.topics.impl.SimpleTopicSet

/*=============================================================================*
*  Copyright 2006 The Apache Software Foundation
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*=============================================================================*/

package org.apache.muse.ws.notification.topics.impl;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import org.apache.muse.util.messages.Messages;
import org.apache.muse.util.messages.MessagesFactory;
import org.apache.muse.util.xml.XmlUtils;
import org.apache.muse.ws.notification.faults.InvalidTopicExpressionFault;
import org.apache.muse.ws.notification.topics.TopicNamespace;
import org.apache.muse.ws.notification.topics.TopicSet;
import org.apache.muse.ws.notification.topics.WstConstants;
import org.apache.muse.ws.resource.basefaults.BaseFault;

/**
*
* SimpleTopicSet is Muse's default implementation of the wst:TopicSet data
* structure defined in WS-Topics v1.3.
*
* @author Dan Jemiolo (danj)
*
*/

public class SimpleTopicSet implements TopicSet
{
    //
    // Used to lookup all exception messages
    //
    private static Messages _MESSAGES =
        MessagesFactory.get(SimpleTopicSet.class);
   
    private Map _topicSpacesByNS = new HashMap();
   
    public synchronized final void addTopicNamespace(TopicNamespace topicSpace)
        throws BaseFault
    {
        if (topicSpace == null)
            throw new NullPointerException(_MESSAGES.get("NullTopicSpace"));

        String namespace = topicSpace.getTargetNamespace();
       
        if (_topicSpacesByNS.keySet().contains(namespace))
        {
            Object[] filler = { namespace };
            throw new InvalidTopicExpressionFault(_MESSAGES.get("TopicSpaceNSExists", filler));
        }
       
        _topicSpacesByNS.put(namespace, topicSpace);
    }
   
    public synchronized final TopicNamespace getTopicNamespace(String namespace)
    {
        return (TopicNamespace)_topicSpacesByNS.get(namespace);
    }
   
    public synchronized final Collection getTopicNamespaceURIs()
    {
        return Collections.unmodifiableCollection(_topicSpacesByNS.keySet());
    }
   
    public synchronized final void removeTopicNamespace(String namespace)
    {
        if (namespace == null)
            throw new NullPointerException(_MESSAGES.get("NullTargetNS"));
       
        _topicSpacesByNS.remove(namespace);
    }

    public Element toXML()
    {
        return toXML(XmlUtils.EMPTY_DOC);
    }

    public Element toXML(Document doc)
    {
        Element root = XmlUtils.createElement(doc, WstConstants.TOPIC_SET_QNAME);
       
        //
        // FIXME: not implemented yet, but this property is not nillable
        //
        XmlUtils.setElementText(root, "Serialization of the wst:TopicSet property has not been implemented yet.");
       
        return root;
    }
}
TOP

Related Classes of org.apache.muse.ws.notification.topics.impl.SimpleTopicSet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.