Author: tilman
Date: Sun Dec 28 15:25:27 2025
New Revision: 1930925

Log:
PDFBOX-6133: refactor

Modified:
   pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java

Modified: 
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java   
Sun Dec 28 15:25:22 2025        (r1930924)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java   
Sun Dec 28 15:25:27 2025        (r1930925)
@@ -295,6 +295,9 @@ public final class TypeMapping
      */
     public PropertyType getSpecifiedPropertyType(QName qName, String 
parentTypeName) throws BadFieldValueException
     {
+        // PDFBOX-6133: the method was rewritten because of photoshop and exif,
+        // because these namespaces exist as a schema and as a type
+        // "factory" is checked in the non-schema part to keep the pre 
PDFBOX-6133 behavior
         XMPSchemaFactory factory = getSchemaFactory(qName.getNamespaceURI());
         if (factory != null)
         {
@@ -307,12 +310,11 @@ public final class TypeMapping
         }
         // try in structured
         List<Types> list = structuredNamespaces2.get(qName.getNamespaceURI());
-        Types st;
         if (list != null)
         {
-            st = list.get(0);
             if (list.size() == 1)
             {
+                Types st = list.get(0);
                 PropertiesDescription propDesc = structuredMappings.get(st);
                 if (factory == null || 
propDesc.getPropertiesNames().contains(qName.getLocalPart()))
                 {
@@ -334,20 +336,10 @@ public final class TypeMapping
                     PropertiesDescription propDesc = 
structuredMappings.get(type);
                     if 
(propDesc.getPropertiesNames().contains(qName.getLocalPart()))
                     {
-                        st = type;
-                        break;
+                        return createPropertyType(type, Cardinality.Simple);
                     }
                 }
             }
-
-            PropertyType propertyType = createPropertyType(st, 
Cardinality.Simple);
-            PropertiesDescription propertiesDescription = 
getStructuredPropMapping(propertyType.type());
-            // PDFBOX-6133: do an additional check to make sure that the name 
exists.
-            // This can happen with photoshop and exif because the namespace 
exists as a schema and as a type
-            if 
(propertiesDescription.getPropertiesNames().contains(qName.getLocalPart()))
-            {
-                return propertyType;
-            }
             return null;
         }
         else

Reply via email to