mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
19392: ALF-2101 - Integrated contribution to allow custom content types to be specified as the default when creating or adding content git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19395 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -327,8 +327,14 @@
|
|||||||
</config>
|
</config>
|
||||||
|
|
||||||
<config evaluator="string-compare" condition="Content Wizards">
|
<config evaluator="string-compare" condition="Content Wizards">
|
||||||
|
<!-- The default content type - all content types must be subtypes of it -->
|
||||||
|
<default-content-type>
|
||||||
|
<type name="cm:content" />
|
||||||
|
</default-content-type>
|
||||||
|
|
||||||
<!-- The list of custom content types to show in the content wizards -->
|
<!-- The list of custom content types to show in the content wizards -->
|
||||||
<content-types>
|
<content-types>
|
||||||
|
<type name="cm:content" />
|
||||||
</content-types>
|
</content-types>
|
||||||
|
|
||||||
<!-- The list of mime types that can be created inline -->
|
<!-- The list of mime types that can be created inline -->
|
||||||
|
@@ -92,7 +92,7 @@ public abstract class BaseContentWizard extends BaseWizardBean
|
|||||||
this.description = null;
|
this.description = null;
|
||||||
this.mimeType = null;
|
this.mimeType = null;
|
||||||
this.inlineEdit = false;
|
this.inlineEdit = false;
|
||||||
this.objectType = ContentModel.TYPE_CONTENT.toString();
|
this.objectType = null;
|
||||||
|
|
||||||
initOtherProperties();
|
initOtherProperties();
|
||||||
}
|
}
|
||||||
@@ -300,59 +300,106 @@ public abstract class BaseContentWizard extends BaseWizardBean
|
|||||||
|
|
||||||
// add the well known object type to start with
|
// add the well known object type to start with
|
||||||
this.objectTypes = new ArrayList<SelectItem>(5);
|
this.objectTypes = new ArrayList<SelectItem>(5);
|
||||||
this.objectTypes.add(new SelectItem(ContentModel.TYPE_CONTENT.toString(),
|
|
||||||
Application.getMessage(context, "content")));
|
|
||||||
|
|
||||||
// add any configured content sub-types to the list
|
|
||||||
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
|
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
|
||||||
Config wizardCfg = svc.getConfig("Content Wizards");
|
Config wizardCfg = svc.getConfig("Content Wizards");
|
||||||
if (wizardCfg != null)
|
if (wizardCfg != null)
|
||||||
{
|
{
|
||||||
ConfigElement typesCfg = wizardCfg.getConfigElement("content-types");
|
ConfigElement defaultTypesCfg = wizardCfg.getConfigElement("default-content-type");
|
||||||
if (typesCfg != null)
|
String parentLabel = "";
|
||||||
|
if (defaultTypesCfg != null)
|
||||||
{
|
{
|
||||||
for (ConfigElement child : typesCfg.getChildren())
|
// Get the default content-type to apply
|
||||||
|
ConfigElement typeElement = defaultTypesCfg.getChildren().get(0);
|
||||||
|
QName parentQName = Repository.resolveToQName(typeElement.getAttribute("name"));
|
||||||
|
TypeDefinition parentType = null;
|
||||||
|
if (parentQName != null)
|
||||||
{
|
{
|
||||||
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
|
parentType = this.getDictionaryService().getType(parentQName);
|
||||||
if (idQName != null)
|
|
||||||
|
if (parentType == null)
|
||||||
{
|
{
|
||||||
TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
|
// If no default content type is defined default to content
|
||||||
|
parentQName = ContentModel.TYPE_CONTENT;
|
||||||
|
parentType = this.getDictionaryService().getType(ContentModel.TYPE_CONTENT);
|
||||||
|
this.objectTypes.add(new SelectItem(ContentModel.TYPE_CONTENT.toString(),
|
||||||
|
Application.getMessage(context, "content")));
|
||||||
|
logger.warn("Configured default content type not found in dictionary: " + parentQName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// try and get the display label from config
|
||||||
|
parentLabel = Utils.getDisplayLabel(context, typeElement);
|
||||||
|
|
||||||
if (typeDef != null)
|
// if there wasn't a client based label try and get it from the dictionary
|
||||||
|
if (parentLabel == null)
|
||||||
{
|
{
|
||||||
if (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_CONTENT))
|
parentLabel = parentType.getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally, just use the localname
|
||||||
|
if (parentLabel == null)
|
||||||
|
{
|
||||||
|
parentLabel = parentQName.getLocalName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all content types defined
|
||||||
|
ConfigElement typesCfg = wizardCfg.getConfigElement("content-types");
|
||||||
|
if (typesCfg != null)
|
||||||
|
{
|
||||||
|
for (ConfigElement child : typesCfg.getChildren())
|
||||||
|
{
|
||||||
|
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
|
||||||
|
if (idQName != null)
|
||||||
|
{
|
||||||
|
TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
|
||||||
|
|
||||||
|
if (typeDef != null)
|
||||||
{
|
{
|
||||||
// try and get the display label from config
|
// for each type check if it is a subtype of the default content type
|
||||||
String label = Utils.getDisplayLabel(context, child);
|
if (this.getDictionaryService().isSubClass(typeDef.getName(), parentType.getName()))
|
||||||
|
|
||||||
// if there wasn't a client based label try and get it from the dictionary
|
|
||||||
if (label == null)
|
|
||||||
{
|
{
|
||||||
label = typeDef.getTitle();
|
// try and get the display label from config
|
||||||
}
|
String label = Utils.getDisplayLabel(context, child);
|
||||||
|
|
||||||
// finally, just use the localname
|
// if there wasn't a client based label try and get it from the dictionary
|
||||||
if (label == null)
|
if (label == null)
|
||||||
|
{
|
||||||
|
label = typeDef.getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally, just use the localname
|
||||||
|
if (label == null)
|
||||||
|
{
|
||||||
|
label = idQName.getLocalName();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.objectTypes.add(new SelectItem(idQName.toString(), label));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
label = idQName.getLocalName();
|
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||||
|
"' to the list of content types - it is not a subtype of " + parentQName);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.objectTypes.add(new SelectItem(idQName.toString(), label));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
|
||||||
"' to the list of content types as the type is not a subtype of cm:content");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||||
"' to the list of content types as the type is not recognised");
|
"' to the list of content types as the type is not recognised");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Case when no type is defined - we add the default content type to the list of available types
|
||||||
|
if (this.objectTypes.isEmpty())
|
||||||
|
{
|
||||||
|
// add default content type to the list of available types
|
||||||
|
this.objectTypes.add(new SelectItem(parentQName.toString(), parentLabel));
|
||||||
|
}
|
||||||
|
|
||||||
// make sure the list is sorted by the label
|
// make sure the list is sorted by the label
|
||||||
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||||
sorter.sort();
|
sorter.sort();
|
||||||
|
Reference in New Issue
Block a user