Merged BRANCHES/DEV/RGAUSS/4.2-CORE-CHANGES-43298 to HEAD:

43309: Merged BRANCHES/DEV/RGAUSS/V4.1-BUG-FIX-TAG-MAPPING to BRANCHES/DEV/RGAUSS/4.2-CORE-CHANGES-43298:
        39447: Merged BRANCHES/DEV/RGAUSS/V4.1-BUG-FIX-38527 to BRANCHES/DEV/RGAUSS/V4.1-BUG-FIX-TAG-MAPPING:
             38719: ALF-14965: Ability to Map Extracted Metadata to Standard Tags
                  - Added more specific MalformedNodeRefException
                  - Changed NodeRef to throw MalformedNodeRefException on a bad string constructor rather than generic AlfrescoRunTimeException
                  - ContentMetadataExtracter: Added enableStringTagging boolean field
                  - ContentMetadataExtracter: Added taggingService
                  - ContentMetadataExtracter: Added addTags method responsible for iterating the raw value from the metadata extracter and creating either string tags or NodeRef links
                  - ContentMetadataExtracter: Added check for instanceof AbstractMappingMetadataExtracter and if so set its enableStringTagging field
                  - ContentMetadataExtracter: Added check for enableStringTagging in executeImpl and if enabled call addTags
                  - AbstractMappingMetadataExtracter: Added enableStringTagging boolean field
                  - AbstractMappingMetadataExtracter: Added catch of MalformedNodeRefException and if string tagging enabled leave the raw properties for processing by ContentMetadataExtracter
        39448: ALF-14965: Ability to Map Extracted Metadata to Standard Tags
             - Added fix for single valued raw properties
             - Added tag mapping unit test and test resource
        39449: ALF-14965: Ability to Map Extracted Metadata to Standard Tags
             - Added better class javadoc
        39479: ALF-14965: Ability to Map Extracted Metadata to Standard Tags
             - Changed behavior of addition of tags by NodeRef
             - Changed where some items were setup in the unit test
             - Added manual test keywords to those extracted from file in unit test
             - Added testing of addition of tag by NodeRef
   43324: ALF-14965: Ability to Map Extracted Metadata to Standard Tags
        - Added Javadoc to AbstractMappingMetadataExtracter.setEnableStringTagging
        - Changed check of enableStringTagging in AbstractMappingMetadataExtracter.convertSystemPropertyValues to allow graceful failure if mappings to cm:taggable are present but enableStringTagging is false


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@43335 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ray Gauss
2012-11-02 11:53:52 +00:00
parent 7c67a013ee
commit be1a9f5d17
4 changed files with 552 additions and 5 deletions

View File

@@ -38,11 +38,13 @@ import java.util.Set;
import java.util.StringTokenizer;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.MalformedNodeRefException;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
@@ -114,6 +116,7 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
private Map<QName, Set<String>> embedMapping;
private boolean inheritDefaultMapping;
private boolean inheritDefaultEmbedMapping;
private boolean enableStringTagging;
/**
* Default constructor. If this is called, then {@link #isSupported(String)} should
@@ -351,6 +354,18 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
this.inheritDefaultMapping = inheritDefaultMapping;
}
/**
* Whether or not to enable the pass through of simple strings to cm:taggable tags
*
* @param enableStringTagging <tt>true</tt> find or create tags for each string
* mapped to cm:taggable. <tt>false</tt> (default)
* ignore mapping strings to tags.
*/
public void setEnableStringTagging(boolean enableStringTagging)
{
this.enableStringTagging = enableStringTagging;
}
/**
* Set if the embed property mappings augment or override the mapping generically provided by the
* extracter implementation. The default is <tt>false</tt>, i.e. any mapping set completely
@@ -1298,6 +1313,38 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
propertyValue);
}
}
catch (MalformedNodeRefException e)
{
if (propertyQName.equals(ContentModel.PROP_TAGS))
{
if (enableStringTagging)
{
// We must want to map tag string values instead of nodeRefs
// ContentMetadataExtracter will take care of tagging by string
ArrayList<Object> list = new ArrayList<Object>(1);
for (Object value : (Object[]) propertyValue)
{
list.add(value);
}
convertedProperties.put(propertyQName, list);
}
else
{
if (logger.isInfoEnabled())
{
logger.info("enableStringTagging is false and could not convert " +
propertyQName.toString() + ": " + e.getMessage());
}
}
}
else
{
if (failOnTypeConversion)
{
throw e;
}
}
}
}
// Done
return convertedProperties;