felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Berger (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (FELIX-3720) Designate's pid attribute is optional and not mandatory
Date Thu, 18 Oct 2012 07:24:03 GMT

     [ https://issues.apache.org/jira/browse/FELIX-3720?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexander Berger updated FELIX-3720:
------------------------------------

    Attachment: metatype.diff

A patch against trunk which should fix all the problems mentioned in this issue.
                
> 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
>         Attachments: metatype.diff
>
>
> 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 );
>             }            
>         }
>     }
> Additionally the attribute OCD/name should also be treated to be optional (see MetaDataReader's
member readOCD).
> And last but not least MetaTypeInformationImpl's addMetaData member should be changed
like this:
>                 // gather pids and factory pids
>                 if (designate.getFactoryPid() != null) {
>                     this.factoryPids.add( designate.getFactoryPid() );
>                     this.addMetaTypeProvider(designate.getFactoryPid(), dmtp);
>                 } else {
>                     this.pids.add(designate.getPid());
>                     this.addMetaTypeProvider(designate.getPid(), dmtp);
>                 }

--
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

Mime
View raw message