Skip to content

Commit a74a0fa

Browse files
committed
PDFBOX-6133: refactor
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930925 13f79535-47bb-0310-9956-ffa450edef68
1 parent d6cdca4 commit a74a0fa

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ public boolean isDefinedNamespace(String namespace)
295295
*/
296296
public PropertyType getSpecifiedPropertyType(QName qName, String parentTypeName) throws BadFieldValueException
297297
{
298+
// PDFBOX-6133: the method was rewritten because of photoshop and exif,
299+
// because these namespaces exist as a schema and as a type
300+
// "factory" is checked in the non-schema part to keep the pre PDFBOX-6133 behavior
298301
XMPSchemaFactory factory = getSchemaFactory(qName.getNamespaceURI());
299302
if (factory != null)
300303
{
@@ -307,12 +310,11 @@ public PropertyType getSpecifiedPropertyType(QName qName, String parentTypeName)
307310
}
308311
// try in structured
309312
List<Types> list = structuredNamespaces2.get(qName.getNamespaceURI());
310-
Types st;
311313
if (list != null)
312314
{
313-
st = list.get(0);
314315
if (list.size() == 1)
315316
{
317+
Types st = list.get(0);
316318
PropertiesDescription propDesc = structuredMappings.get(st);
317319
if (factory == null || propDesc.getPropertiesNames().contains(qName.getLocalPart()))
318320
{
@@ -334,20 +336,10 @@ public PropertyType getSpecifiedPropertyType(QName qName, String parentTypeName)
334336
PropertiesDescription propDesc = structuredMappings.get(type);
335337
if (propDesc.getPropertiesNames().contains(qName.getLocalPart()))
336338
{
337-
st = type;
338-
break;
339+
return createPropertyType(type, Cardinality.Simple);
339340
}
340341
}
341342
}
342-
343-
PropertyType propertyType = createPropertyType(st, Cardinality.Simple);
344-
PropertiesDescription propertiesDescription = getStructuredPropMapping(propertyType.type());
345-
// PDFBOX-6133: do an additional check to make sure that the name exists.
346-
// This can happen with photoshop and exif because the namespace exists as a schema and as a type
347-
if (propertiesDescription.getPropertiesNames().contains(qName.getLocalPart()))
348-
{
349-
return propertyType;
350-
}
351343
return null;
352344
}
353345
else

0 commit comments

Comments
 (0)