Package org.apache.ws.resource.properties.impl

Source Code of org.apache.ws.resource.properties.impl.AbstractGetResourcePropertiesPortType

/*=============================================================================*
*  Copyright 2005 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.ws.resource.properties.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.resource.ResourceContext;
import org.apache.ws.resource.i18n.Keys;
import org.apache.ws.resource.i18n.MessagesImpl;
import org.apache.ws.resource.properties.NamespaceVersionHolder;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.ws.util.i18n.Messages;
import org.apache.xmlbeans.XmlObject;

import javax.xml.namespace.QName;
import java.util.Iterator;

/**
* A version-neutral base class that is extended by all impls of GetRP and GetMultipleRPs portTypes.
*
* @author Ian Springer
*/
public abstract class AbstractGetResourcePropertiesPortType extends AbstractResourcePropertiesPortType
{

    private static final Log LOG = LogFactory.getLog( AbstractGetResourcePropertiesPortType.class );
    private static final Messages MSG = MessagesImpl.getInstance();

    protected AbstractGetResourcePropertiesPortType( ResourceContext resourceContext )
    {
        super( resourceContext );
    }

    protected void addPropertyToResponse( ResourceProperty prop, XmlObject response )
    {
        Iterator propElemIter = prop.iterator();
        while ( propElemIter.hasNext() )
        {
            XmlObject propElem = (XmlObject) propElemIter.next();
            XmlBeanUtils.addChildElement( response, propElem );
        }
    }

    protected void addPropertiesToResponse( ResourceProperty[] props, XmlObject response )
    {
        for ( int i = 0; i < props.length; i++ )
        {
            addPropertyToResponse( props[i], response );
        }
    }

    protected ResourceProperty[] getMultipleProperties( QName[] propNames )
    {
        ResourceProperty[] props = new ResourceProperty[propNames.length];
        for ( int i = 0; i < propNames.length; i++ )
        {
            props[i] = getProperty( propNames[i] );
        }
        return props;
    }

    protected ResourceProperty getProperty( QName propName )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( MSG.getMessage( Keys.GET_RP_REQ, propName ) );
        }
        ResourceProperty prop = getProperties().get( propName );
        if ( prop == null )
        {
            throw new InvalidResourcePropertyQNameFaultException( getNamespaceSet(), propName );
        }
        refreshProperty( prop );
        return prop;
    }

    protected abstract NamespaceVersionHolder getNamespaceSet();

}
TOP

Related Classes of org.apache.ws.resource.properties.impl.AbstractGetResourcePropertiesPortType

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.