Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 942F1D1D2 for ; Thu, 18 Oct 2012 06:14:03 +0000 (UTC) Received: (qmail 26884 invoked by uid 500); 18 Oct 2012 06:14:03 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 26842 invoked by uid 500); 18 Oct 2012 06:14:03 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 26829 invoked by uid 99); 18 Oct 2012 06:14:03 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Oct 2012 06:14:03 +0000 Date: Thu, 18 Oct 2012 06:14:02 +0000 (UTC) From: "Alexander Berger (JIRA)" To: dev@felix.apache.org Message-ID: <1974578990.62497.1350540842964.JavaMail.jiratomcat@arcas> In-Reply-To: <1283809038.62486.1350540363022.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (FELIX-3720) Designate's pid attribute is optional and not mandatory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FELIX-3720?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Alexander Berger updated FELIX-3720: ------------------------------------ Description: In class org.apache.felix.metatype.MetaDataReader method readDesignate the "pid" attribute of a "Designate" element is read as required attribute: designate.setPid( this.getRequiredAttribute( "pid" ) ); designate.setFactoryPid( this.getOptionalAttribute( "factoryPid" ) ); This is wrong as according to the Metatype Service Specification (Version 1.2) the attributes "pid" and "factoryPid" are both optional but at least one of these two must be present (either "pid" or "factoryPid"). Thus the code should be changed to something like this: final String pid = this.getOptionalAttribute( "pid" ); final String factoryPid = this.getOptionalAttribute( "factoryPid" ); if ( pid == null && factoryPid == null ) { missingAttribute("pid or factoryPid"); } designate.setPid( pid ); designate.setFactoryPid( factoryPid ); Also the class MetaData should be fixed, its addDesignate member looks like this: public void addDesignate( Designate designate ) { if ( designate != null ) { if ( designates == null ) { designates = new HashMap(); } designates.put( designate.getPid(), designate ); } } but should be implemented something like this: public void addDesignate( Designate designate ) { if ( designate != null ) { if ( designates == null ) { designates = new HashMap(); } final String factoryPid = designate.getFactoryPid(); if ( factoryPid == null ) { designates.put( designate.getPid(), designate ); } else { designates.put( factoryPid, designate ); } } } was: In class org.apache.felix.metatype.MetaDataReader method readDesignate the "pid" attribute of a "Designate" element is read as required attribute: designate.setPid( this.getRequiredAttribute( "pid" ) ); designate.setFactoryPid( this.getOptionalAttribute( "factoryPid" ) ); This is wrong as according to the Metatype Service Specification (Version 1.2) the attributes "pid" and "factoryPid" are both optional but at least one of these two must be present (either "pid" or "factoryPid"). Thus the code should be changed to something like this: final String pid = this.getOptionalAttribute( "pid" ); final String factoryPid = this.getOptionalAttribute( "factoryPid" ); if ( pid == null && factoryPid == null ) { missingAttribute("pid or factoryPid"); } designate.setPid( pid ); designate.setFactoryPid( factoryPid ); > Designate's pid attribute is optional and not mandatory > ------------------------------------------------------- > > Key: FELIX-3720 > URL: https://issues.apache.org/jira/browse/FELIX-3720 > Project: Felix > Issue Type: Bug > Components: Metatype Service > Affects Versions: metatype-1.0.4 > Reporter: Alexander Berger > > In class org.apache.felix.metatype.MetaDataReader method readDesignate the "pid" attribute of a "Designate" element is read as required attribute: > designate.setPid( this.getRequiredAttribute( "pid" ) ); > designate.setFactoryPid( this.getOptionalAttribute( "factoryPid" ) ); > This is wrong as according to the Metatype Service Specification (Version 1.2) the attributes "pid" and "factoryPid" are both optional but at least one of these two must be present (either "pid" or "factoryPid"). Thus the code should be changed to something like this: > final String pid = this.getOptionalAttribute( "pid" ); > final String factoryPid = this.getOptionalAttribute( "factoryPid" ); > if ( pid == null && factoryPid == null ) { > missingAttribute("pid or factoryPid"); > } > designate.setPid( pid ); > designate.setFactoryPid( factoryPid ); > Also the class MetaData should be fixed, its addDesignate member looks like this: > public void addDesignate( Designate designate ) > { > if ( designate != null ) > { > if ( designates == null ) > { > designates = new HashMap(); > } > designates.put( designate.getPid(), designate ); > } > } > but should be implemented something like this: > public void addDesignate( Designate designate ) > { > if ( designate != null ) > { > if ( designates == null ) > { > designates = new HashMap(); > } > final String factoryPid = designate.getFactoryPid(); > if ( factoryPid == null ) { > designates.put( designate.getPid(), designate ); > } else { > designates.put( factoryPid, designate ); > } > } > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira