/** * If no short identifier was provided in the input payload, generate a short identifier from the * preferred term display name or term name. */ private String handleDisplayNameAsShortIdentifier(DocumentModel docModel) throws Exception { String result = (String) docModel.getProperty( authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); if (Tools.isEmpty(result)) { String termDisplayName = getPrimaryDisplayName( docModel, authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_DISPLAY_NAME); String termName = getPrimaryDisplayName( docModel, authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_NAME); String generatedShortIdentifier = AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName( termDisplayName, termName); docModel.setProperty( authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER, generatedShortIdentifier); result = generatedShortIdentifier; } return result; }
/** * If no short identifier was provided in the input payload, generate a short identifier from the * display name. */ private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception { String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER); String displayName = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.DISPLAY_NAME); String shortDisplayName = ""; if (Tools.isEmpty(shortIdentifier)) { String generatedShortIdentifier = AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName( displayName, shortDisplayName); docModel.setProperty( schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER, generatedShortIdentifier); } }