<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at legal-notices/CDDLv1_0.txt.
! If applicable, add the following below this CDDL HEADER, with the
! fields enclosed by brackets "[]" replaced with your own identifying
! information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
!
! Copyright 2008-2009 Sun Microsystems, Inc.
! -->
xmlns:admpp="http://www.opends.org/admin-preprocessor"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="us-ascii" />
<!--
Template for generating the interface declaration.
-->
<xsl:template name="generate-interface-declaration">
<xsl:value-of select="'/**
'" />
<xsl:call-template name="add-java-comment">
<xsl:with-param name="indent-text" select="' *'" />
<xsl:with-param name="content"
select="concat('A client-side interface for reading and modifying ',
$this-ufn, ' settings.')" />
</xsl:call-template>
<xsl:value-of select="' * <p>
'" />
<xsl:call-template name="add-java-comment">
<xsl:with-param name="indent-text" select="' *'" />
</xsl:call-template>
<xsl:value-of select="' */
'" />
<xsl:value-of
select="concat('public interface ',
$this-java-class,
'CfgClient extends ')" />
<xsl:choose>
<xsl:when test="boolean($this/@extends)">
<xsl:value-of select="concat($parent-java-class,'CfgClient ')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'ConfigurationClient '" />
</xsl:otherwise>
</xsl:choose>
<xsl:text>{
</xsl:text>
</xsl:template>
<!--
Template for generating the configuration definition getter.
-->
<xsl:template name="generate-configuration-definition-getter">
<xsl:value-of
select="concat(' /**
',
' * Get the configuration definition associated with this ', $this-ufn, '.
',
' *
',
' * @return Returns the configuration definition associated with this ', $this-ufn, '.
',
' */
')" />
<xsl:value-of
select="concat(' ManagedObjectDefinition<? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg> definition();
')" />
</xsl:template>
<!--
Template for generating the relation getter declarations.
-->
<xsl:template name="generate-relation-declarations">
<xsl:variable name="name" select="@name" />
<xsl:variable name="ufn">
<xsl:call-template name="name-to-ufn">
<xsl:with-param name="value" select="$name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="java-relation-name">
<xsl:call-template name="name-to-java">
<xsl:with-param name="value" select="$name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="java-class-name">
<xsl:call-template name="name-to-java">
<xsl:with-param name="value" select="@managed-object-name" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="adm:one-to-one">
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Gets the ', $ufn,'.
',
'
',
'@return Returns the ', $ufn,'.
',
'@throws DefinitionDecodingException
',
' If the ', $ufn, ' was found but its type could not be determined.
',
'@throws ManagedObjectDecodingException
',
' If the ', $ufn, ' was found but one or more of its properties could not be decoded.
',
'@throws ManagedObjectNotFoundException
',
' If the ', $ufn, ' could not be found on the server.
',
'@throws ConcurrentModificationException
',
' If this ', $this-ufn, ' has been removed from the server by another client.
',
'@throws AuthorizationException
',
' If the server refuses to retrieve the ', $ufn, ' because the client does not have the correct privileges.
',
'@throws CommunicationException
',
' If the client cannot contact the server due to an underlying communication problem.')" />
</xsl:call-template>
<xsl:value-of
select="concat(' ', $java-class-name, 'CfgClient get', $java-relation-name, '()
',
' throws DefinitionDecodingException, ManagedObjectDecodingException,
',
' ManagedObjectNotFoundException, ConcurrentModificationException,
',
' AuthorizationException, CommunicationException;
')" />
</xsl:when>
<xsl:when test="adm:one-to-zero-or-one">
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat('Determines whether or not the ', $ufn,' exists.
',
'
',
'@return Returns <true> if the ', $ufn,' exists.
',
'@throws ConcurrentModificationException
',
' If this ', $this-ufn, ' has been removed from the server by another client.
',
'@throws AuthorizationException
',
' If the server refuses to make the determination because the client does not have the correct privileges.
',
'@throws CommunicationException
',
' If the client cannot contact the server due to an underlying communication problem.')" />
</xsl:call-template>
<xsl:value-of
select="concat(' boolean has',
$java-relation-name, '() throws ConcurrentModificationException,
',
' AuthorizationException, CommunicationException;
')" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Gets the ', $ufn,' if it is present.
',
'
',
'@return Returns the ', $ufn, ' if it is present.
',
'@throws DefinitionDecodingException
',
' If the ', $ufn, ' was found but its type could not be determined.
',
'@throws ManagedObjectDecodingException
',
' If the ', $ufn, ' was found but one or more of its properties could not be decoded.
',
'@throws ManagedObjectNotFoundException
',
' If the ', $ufn, ' is not present.
',
'@throws ConcurrentModificationException
',
' If this ', $this-ufn, ' has been removed from the server by another client.
',
'@throws AuthorizationException
',
' If the server refuses to retrieve the ', $ufn, ' because the client does not have the correct privileges.
',
'@throws CommunicationException
',
' If the client cannot contact the server due to an underlying communication problem.')" />
</xsl:call-template>
<xsl:value-of
select="concat(' ', $java-class-name, 'CfgClient get', $java-relation-name, '()
',
' throws DefinitionDecodingException, ManagedObjectDecodingException,
',
' ManagedObjectNotFoundException, ConcurrentModificationException,
',
' AuthorizationException, CommunicationException;
')" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Creates a new ', $ufn,'. The new ', $ufn,' will initially ',
'not contain any property values (including mandatory ',
'properties). Once the ', $ufn,' has been configured it ',
'can be added to the server using the {@link #commit()} ',
'method.
',
'
',
'@param <C>
',
' The type of the ', $ufn,' being created.
',
'@param d
',
' The definition of the ', $ufn,' to be created.
',
'@param exceptions
',
' An optional collection in which to place any ',
'{@link PropertyException}s that occurred whilst ',
'attempting to determine the default values of the ', $ufn,
'. This argument can be <code>null<code>.
',
'@return Returns a new ', $ufn,' configuration instance.
')" />
</xsl:call-template>
<xsl:value-of
select="concat(' <C extends ', $java-class-name,'CfgClient> C create', $java-relation-name, '(
',
' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, Collection<PropertyException> exceptions);
')" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Removes the ', $ufn,' if it exists.
',
'
',
'@throws ManagedObjectNotFoundException
',
' If the ', $ufn, ' does not exist.
',
'@throws OperationRejectedException
',
' If the server refuses to remove the ', $ufn, ' due to some server-side constraint which cannot be satisfied (for example, if it is referenced by another managed object).
',
'@throws ConcurrentModificationException
',
' If this ', $this-ufn, ' has been removed from the server by another client.
',
'@throws AuthorizationException
',
' If the server refuses to remove the ', $ufn, ' because the client does not have the correct privileges.
',
'@throws CommunicationException
',
' If the client cannot contact the server due to an underlying communication problem.')" />
</xsl:call-template>
<xsl:value-of
select="concat(' void remove', $java-relation-name, '()
',
' throws ManagedObjectNotFoundException, OperationRejectedException,
',
' ConcurrentModificationException, AuthorizationException,
',
' CommunicationException;
')" />
</xsl:when>
<xsl:when test="adm:one-to-many">
<xsl:variable name="plural-name"
select="adm:one-to-many/@plural-name" />
<xsl:variable name="ufpn">
<xsl:call-template name="name-to-ufn">
<xsl:with-param name="value" select="$plural-name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="java-relation-plural-name">
<xsl:call-template name="name-to-java">
<xsl:with-param name="value" select="$plural-name" />
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat('Lists the ', $ufpn,'.
',
'
',
'@return Returns an array containing the names of the ', $ufpn,'.
',
'@throws ConcurrentModificationException
',
' If this ', $this-ufn, ' has been removed from the server by another client.
',
'@throws AuthorizationException
',
' If the server refuses to list the ', $ufpn, ' because the client does not have the correct privileges.
',
'@throws CommunicationException
',
' If the client cannot contact the server due to an underlying communication problem.')" />
</xsl:call-template>
<xsl:value-of
select="concat(' String[] list',
$java-relation-plural-name, '() throws ConcurrentModificationException,
',
' AuthorizationException, CommunicationException;
')" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Gets the named ', $ufn, '.
',
'
',
'@param name
',
' The name of the ', $ufn,' to retrieve.
',
'@return Returns the named ', $ufn, '.
',
'@throws DefinitionDecodingException
',
' If the named ', $ufn, ' was found but its type could not be determined.
',
'@throws ManagedObjectDecodingException
',
' If the named ', $ufn, ' was found but one or more of its properties could not be decoded.
',
'@throws ManagedObjectNotFoundException
',
' If the named ', $ufn, ' was not found on the server.
',
'@throws ConcurrentModificationException
',
' If this ', $this-ufn, ' has been removed from the server by another client.
',
'@throws AuthorizationException
',
' If the server refuses to retrieve the named ', $ufn, ' because the client does not have the correct privileges.
',
'@throws CommunicationException
',
' If the client cannot contact the server due to an underlying communication problem.')" />
</xsl:call-template>
<xsl:value-of
select="concat(' ', $java-class-name, 'CfgClient get', $java-relation-name, '(String name)
',
' throws DefinitionDecodingException, ManagedObjectDecodingException,
',
' ManagedObjectNotFoundException, ConcurrentModificationException,
',
' AuthorizationException, CommunicationException;
')" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:choose>
<xsl:when test="string(adm:one-to-many/@unique) != 'true'">
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Creates a new ', $ufn,'. The new ', $ufn,' will initially ',
'not contain any property values (including mandatory ',
'properties). Once the ', $ufn,' has been configured it ',
'can be added to the server using the {@link #commit()} ',
'method.
',
'
',
'@param <C>
',
' The type of the ', $ufn,' being created.
',
'@param d
',
' The definition of the ', $ufn,' to be created.
',
'@param name
',
' The name of the new ', $ufn,'.
',
'@param exceptions
',
' An optional collection in which to place any ',
'{@link PropertyException}s that occurred whilst ',
'attempting to determine the default values of the ', $ufn,
'. This argument can be <code>null<code>.
',
'@return Returns a new ', $ufn,' configuration instance.
',
'@throws IllegalManagedObjectNameException
',
' If the name of the new ', $ufn,' is invalid.
')" />
</xsl:call-template>
<xsl:value-of
select="concat(' <C extends ', $java-class-name,'CfgClient> C create', $java-relation-name, '(
',
' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException;
')" />
</xsl:when>
<xsl:when test="string(adm:one-to-many/@unique) = 'true'">
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Creates a new ', $ufn,'. The new ', $ufn,' will initially ',
'not contain any property values (including mandatory ',
'properties). Once the ', $ufn,' has been configured it ',
'can be added to the server using the {@link #commit()} ',
'method.
',
'
',
'@param <C>
',
' The type of the ', $ufn,' being created.
',
'@param d
',
' The definition of the ', $ufn,' to be created.
',
'@param exceptions
',
' An optional collection in which to place any ',
'{@link PropertyException}s that occurred whilst ',
'attempting to determine the default values of the ', $ufn,
'. This argument can be <code>null<code>.
',
'@return Returns a new ', $ufn,' configuration instance.
')" />
</xsl:call-template>
<xsl:value-of
select="concat(' <C extends ', $java-class-name,'CfgClient> C create', $java-relation-name, '(
',
' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, Collection<PropertyException> exceptions);
')" />
</xsl:when>
</xsl:choose>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="add-java-comment2">
<xsl:with-param name="indent" select="2" />
<xsl:with-param name="content"
select="concat(
'Removes the named ', $ufn,'.
',
'
',
'@param name
',
' The name of the ', $ufn,' to remove.
',
'@throws ManagedObjectNotFoundException
',
' If the ', $ufn, ' does not exist.
',
'@throws OperationRejectedException
',
' If the server refuses to remove the ', $ufn, ' due to some server-side constraint which cannot be satisfied (for example, if it is referenced by another managed object).
',
'@throws ConcurrentModificationException
',
' If this ', $this-ufn, ' has been removed from the server by another client.
',
'@throws AuthorizationException
',
' If the server refuses to remove the ', $ufn, ' because the client does not have the correct privileges.
',
'@throws CommunicationException
',
' If the client cannot contact the server due to an underlying communication problem.')" />
</xsl:call-template>
<xsl:value-of
select="concat(' void remove', $java-relation-name, '(String name)
',
' throws ManagedObjectNotFoundException, OperationRejectedException,
',
' ConcurrentModificationException, AuthorizationException,
',
' CommunicationException;
')" />
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of
select="concat('Unknown relation type "', local-name(*), '" in relation "', $name, '".')" />
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
Main document parsing template.
-->
<xsl:template match="/">
<xsl:call-template name="copyright-notice" />
<xsl:value-of
select="concat('package ', $this-package, '.client;
')" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-import-statements">
<xsl:with-param name="imports">
<xsl:for-each select="$this-local-properties">
<xsl:call-template name="get-property-java-imports">
<xsl:with-param name="interface" select="'client'" />
</xsl:call-template>
</xsl:for-each>
<xsl:if test="$this-local-properties[@multi-valued='true']">
</xsl:if>
<xsl:if
test="$this-local-properties[not(@monitoring='true')]">
<import>
</import>
</xsl:if>
<xsl:if test="$this-local-properties[@read-only='true']">
<import>
</import>
</xsl:if>
<xsl:if test="$this-local-relations">
<import>
</import>
<import>
</import>
<import>
</import>
<import>
</import>
<import>
</import>
<import>
</import>
</xsl:if>
<xsl:for-each
select="$this-local-relations[adm:one-to-zero-or-one]|$this-local-relations[adm:one-to-many]">
<xsl:variable name="java-class-name">
<xsl:call-template name="name-to-java">
<xsl:with-param name="value"
select="@managed-object-name" />
</xsl:call-template>
</xsl:variable>
<xsl:element name="import">
<xsl:value-of
select="concat(@managed-object-package, '.server.', $java-class-name, 'Cfg')" />
</xsl:element>
</xsl:for-each>
<xsl:if
test="$this-local-relations/adm:one-to-zero-or-one|$this-local-relations/adm:one-to-many">
<import>
</import>
<import>
</import>
</xsl:if>
<import>
</import>
</xsl:if>
<xsl:choose>
<xsl:when test="$this/@extends">
<xsl:if test="$parent-package != $this-package">
<xsl:element name="import">
<xsl:value-of
select="concat($parent-package, '.client.', $parent-java-class, 'CfgClient')" />
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="import">
<xsl:value-of
select="concat($this-package, '.server.', $this-java-class, 'Cfg')" />
</xsl:element>
</xsl:with-param>
</xsl:call-template>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-interface-declaration" />
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-configuration-definition-getter" />
<xsl:for-each select="$this-local-properties">
<xsl:sort select="@name" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-property-getter-declaration">
<xsl:with-param name="interface" select="'client'" />
</xsl:call-template>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-property-setter-declaration" />
</xsl:for-each>
<xsl:for-each select="$this-local-relations">
<xsl:sort select="@name" />
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-relation-declarations" />
</xsl:for-each>
<xsl:text>
</xsl:text>
<xsl:text>}
</xsl:text>
</xsl:template>
</xsl:stylesheet>