mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V1.3 to HEAD(3161:3179)
svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3161 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3179 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3406 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Binary file not shown.
@@ -90,11 +90,7 @@
|
|||||||
<bean id="openOfficeConnection" class="net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection" />
|
<bean id="openOfficeConnection" class="net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection" />
|
||||||
|
|
||||||
<!-- Metadata Extraction Regisitry -->
|
<!-- Metadata Extraction Regisitry -->
|
||||||
<bean id="metadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry" >
|
<bean id="metadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry" />
|
||||||
<property name="mimetypeMap">
|
|
||||||
<ref bean="mimetypeService" />
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Abstract bean definition defining base definition for all metadata extracters -->
|
<!-- Abstract bean definition defining base definition for all metadata extracters -->
|
||||||
<bean id="baseMetadataExtracter"
|
<bean id="baseMetadataExtracter"
|
||||||
@@ -124,11 +120,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Content Transformation Regisitry -->
|
<!-- Content Transformation Regisitry -->
|
||||||
<bean id="contentTransformerRegistry" class="org.alfresco.repo.content.transform.ContentTransformerRegistry" >
|
<bean id="contentTransformerRegistry" class="org.alfresco.repo.content.transform.ContentTransformerRegistry" />
|
||||||
<constructor-arg>
|
|
||||||
<ref bean="mimetypeService" />
|
|
||||||
</constructor-arg>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Abstract bean definition defining base definition for all transformers -->
|
<!-- Abstract bean definition defining base definition for all transformers -->
|
||||||
<bean id="baseContentTransformer"
|
<bean id="baseContentTransformer"
|
||||||
|
@@ -628,6 +628,13 @@
|
|||||||
<ref bean="policyComponent" />
|
<ref bean="policyComponent" />
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- Temporary Aspect -->
|
||||||
|
<bean id="temporaryAspect" class="org.alfresco.repo.node.TemporaryAspect" init-method="init">
|
||||||
|
<property name="policyComponent">
|
||||||
|
<ref bean="policyComponent" />
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- Configurable service -->
|
<!-- Configurable service -->
|
||||||
<bean id="configurableService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
<bean id="configurableService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||||
|
@@ -1 +1,2 @@
|
|||||||
permissions.err_access_denied=Access Denied. You do not have the appropriate permissions to perform this operation.
|
permissions.err_access_denied=Access Denied. You do not have the appropriate permissions to perform this operation.
|
||||||
|
permissions.err_read_only=Access Denied. The system is currently in read-only mode.
|
@@ -45,11 +45,6 @@
|
|||||||
<title>Folder</title>
|
<title>Folder</title>
|
||||||
<parent>cm:cmobject</parent>
|
<parent>cm:cmobject</parent>
|
||||||
<archive>true</archive>
|
<archive>true</archive>
|
||||||
<properties>
|
|
||||||
<property name="cm:orderedchildren">
|
|
||||||
<type>d:boolean</type>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<associations>
|
<associations>
|
||||||
<child-association name="cm:contains">
|
<child-association name="cm:contains">
|
||||||
<source>
|
<source>
|
||||||
|
@@ -127,6 +127,11 @@
|
|||||||
<title>Incomplete</title>
|
<title>Incomplete</title>
|
||||||
</aspect>
|
</aspect>
|
||||||
|
|
||||||
|
<!-- aspect to tag temporary nodes -->
|
||||||
|
<aspect name="sys:temporary">
|
||||||
|
<title>Temporary</title>
|
||||||
|
</aspect>
|
||||||
|
|
||||||
<!-- details stored on archived nodes -->
|
<!-- details stored on archived nodes -->
|
||||||
<aspect name="sys:archived">
|
<aspect name="sys:archived">
|
||||||
<title>Archived</title>
|
<title>Archived</title>
|
||||||
|
@@ -2,210 +2,155 @@
|
|||||||
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
|
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:doc_info.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:doc_info.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:45.906Z</cm:modified>
|
|
||||||
<cm:description>Displays basic information about the current document</cm:description>
|
<cm:description>Displays basic information about the current document</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/doc_info.ftl|mimetype=text/plain|size=636|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/doc_info.ftl|mimetype=text/plain|size=636|encoding=UTF-8</cm:content>
|
||||||
<cm:title>doc_info.ftl</cm:title>
|
<cm:title>doc_info.ftl</cm:title>
|
||||||
<cm:name>doc_info.ftl</cm:name>
|
<cm:name>doc_info.ftl</cm:name>
|
||||||
<cm:created>2005-10-21T15:11:00.446+01:00</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:localizable.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:localizable.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:50.390Z</cm:modified>
|
|
||||||
<cm:description>Calculates if the document has the localizable aspect applied</cm:description>
|
<cm:description>Calculates if the document has the localizable aspect applied</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/localizable.ftl|mimetype=text/plain|size=380|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/localizable.ftl|mimetype=text/plain|size=380|encoding=UTF-8</cm:content>
|
||||||
<cm:title>localizable.ftl</cm:title>
|
<cm:title>localizable.ftl</cm:title>
|
||||||
<cm:name>localizable.ftl</cm:name>
|
<cm:name>localizable.ftl</cm:name>
|
||||||
<cm:created>2005-10-21T15:11:02.181+01:00</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_docs.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_docs.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:51.937Z</cm:modified>
|
|
||||||
<cm:description>Displays a list of the documents in the current user Home Space</cm:description>
|
<cm:description>Displays a list of the documents in the current user Home Space</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_docs.ftl|mimetype=text/plain|size=750|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_docs.ftl|mimetype=text/plain|size=750|encoding=UTF-8</cm:content>
|
||||||
<cm:title>my_docs.ftl</cm:title>
|
<cm:title>my_docs.ftl</cm:title>
|
||||||
<cm:name>my_docs.ftl</cm:name>
|
<cm:name>my_docs.ftl</cm:name>
|
||||||
<cm:created>2005-10-21T15:11:03.118+01:00</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_spaces.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_spaces.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:57.890Z</cm:modified>
|
|
||||||
<cm:description>Displays a list of spaces in the current user Home Space</cm:description>
|
<cm:description>Displays a list of spaces in the current user Home Space</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_spaces.ftl|mimetype=text/plain|size=682|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_spaces.ftl|mimetype=text/plain|size=682|encoding=UTF-8</cm:content>
|
||||||
<cm:title>my_spaces.ftl</cm:title>
|
<cm:title>my_spaces.ftl</cm:title>
|
||||||
<cm:name>my_spaces.ftl</cm:name>
|
<cm:name>my_spaces.ftl</cm:name>
|
||||||
<cm:created>2005-10-21T15:11:04.665+01:00</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_summary.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_summary.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:59.421Z</cm:modified>
|
|
||||||
<cm:description>Shows a simple summary page about the current user and their Home Space</cm:description>
|
<cm:description>Shows a simple summary page about the current user and their Home Space</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_summary.ftl|mimetype=text/plain|size=537|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_summary.ftl|mimetype=text/plain|size=537|encoding=UTF-8</cm:content>
|
||||||
<cm:title>my_summary.ftl</cm:title>
|
<cm:title>my_summary.ftl</cm:title>
|
||||||
<cm:name>my_summary.ftl</cm:name>
|
<cm:name>my_summary.ftl</cm:name>
|
||||||
<cm:created>2005-10-21T15:11:05.509+01:00</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:translatable.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:translatable.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:11:04.953Z</cm:modified>
|
|
||||||
<cm:description>Calculates if the document has the translatable aspect applied</cm:description>
|
<cm:description>Calculates if the document has the translatable aspect applied</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/translatable.ftl|mimetype=text/plain|size=415|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/translatable.ftl|mimetype=text/plain|size=415|encoding=UTF-8</cm:content>
|
||||||
<cm:title>translatable.ftl</cm:title>
|
<cm:title>translatable.ftl</cm:title>
|
||||||
<cm:name>translatable.ftl</cm:name>
|
<cm:name>translatable.ftl</cm:name>
|
||||||
<cm:created>2005-10-21T15:11:06.306+01:00</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:RSS_2.0_recent_docs.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:RSS_2.0_recent_docs.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:41.656Z</cm:modified>
|
|
||||||
<cm:description>Renders a valid RSS2.0 XML document showing the documents in the current space created or modified in the last 7 days. The template should be configured to use the appropriate server and port before use.</cm:description>
|
<cm:description>Renders a valid RSS2.0 XML document showing the documents in the current space created or modified in the last 7 days. The template should be configured to use the appropriate server and port before use.</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/RSS_2.0_recent_docs.ftl|mimetype=text/plain|size=1917|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/RSS_2.0_recent_docs.ftl|mimetype=text/plain|size=1917|encoding=UTF-8</cm:content>
|
||||||
<cm:title>RSS_2.0_recent_docs.ftl</cm:title>
|
<cm:title>RSS_2.0_recent_docs.ftl</cm:title>
|
||||||
<cm:name>RSS_2.0_recent_docs.ftl</cm:name>
|
<cm:name>RSS_2.0_recent_docs.ftl</cm:name>
|
||||||
<cm:created>2006-01-13T15:49:50.695Z</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:recent_docs.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:recent_docs.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:11:00.953Z</cm:modified>
|
|
||||||
<cm:description>Displays a list of the documents in the current space created or modified in the last 7 days</cm:description>
|
<cm:description>Displays a list of the documents in the current space created or modified in the last 7 days</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/recent_docs.ftl|mimetype=text/plain|size=968|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/recent_docs.ftl|mimetype=text/plain|size=968|encoding=UTF-8</cm:content>
|
||||||
<cm:title>recent_docs.ftl</cm:title>
|
<cm:title>recent_docs.ftl</cm:title>
|
||||||
<cm:name>recent_docs.ftl</cm:name>
|
<cm:name>recent_docs.ftl</cm:name>
|
||||||
<cm:created>2006-01-13T15:50:02.164Z</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:general_example.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:general_example.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:48.062Z</cm:modified>
|
|
||||||
<cm:description>Example of various lists of documents, spaces and summary information about the current user</cm:description>
|
<cm:description>Example of various lists of documents, spaces and summary information about the current user</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/general_example.ftl|mimetype=text/plain|size=1608|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/general_example.ftl|mimetype=text/plain|size=1608|encoding=UTF-8</cm:content>
|
||||||
<cm:title>general_example.ftl</cm:title>
|
<cm:title>general_example.ftl</cm:title>
|
||||||
<cm:name>general_example.ftl</cm:name>
|
<cm:name>general_example.ftl</cm:name>
|
||||||
<cm:created>2006-02-10T09:10:47.796Z</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_docs_inline.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:my_docs_inline.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:10:53.531Z</cm:modified>
|
|
||||||
<cm:description>Displays a list of the documents in the current user Home Space. Text document content is shown inline, as is JPG content as small thumbnail images.</cm:description>
|
<cm:description>Displays a list of the documents in the current user Home Space. Text document content is shown inline, as is JPG content as small thumbnail images.</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_docs_inline.ftl|mimetype=text/plain|size=652|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/my_docs_inline.ftl|mimetype=text/plain|size=652|encoding=UTF-8</cm:content>
|
||||||
<cm:title>my_docs_inline.ftl</cm:title>
|
<cm:title>my_docs_inline.ftl</cm:title>
|
||||||
<cm:name>my_docs_inline.ftl</cm:name>
|
<cm:name>my_docs_inline.ftl</cm:name>
|
||||||
<cm:created>2006-02-10T09:10:53.281Z</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:xpath_search.ftl">
|
<cm:content xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns="" view:childName="cm:xpath_search.ftl">
|
||||||
<view:aspects>
|
<view:aspects>
|
||||||
<cm:auditable></cm:auditable>
|
|
||||||
<app:uifacets></app:uifacets>
|
<app:uifacets></app:uifacets>
|
||||||
<app:inlineeditable></app:inlineeditable>
|
<app:inlineeditable></app:inlineeditable>
|
||||||
</view:aspects>
|
</view:aspects>
|
||||||
<view:properties>
|
<view:properties>
|
||||||
<app:editInline>true</app:editInline>
|
<app:editInline>true</app:editInline>
|
||||||
<cm:modifier>admin</cm:modifier>
|
|
||||||
<cm:modified>2006-02-10T09:11:07.031Z</cm:modified>
|
|
||||||
<cm:description>Example of using XPath and Lucene searches within a template.</cm:description>
|
<cm:description>Example of using XPath and Lucene searches within a template.</cm:description>
|
||||||
<cm:creator>admin</cm:creator>
|
|
||||||
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/xpath_search.ftl|mimetype=text/plain|size=1109|encoding=UTF-8</cm:content>
|
<cm:content>contentUrl=classpath:alfresco/templates/content/examples/xpath_search.ftl|mimetype=text/plain|size=1109|encoding=UTF-8</cm:content>
|
||||||
<cm:title>xpath_search.ftl</cm:title>
|
<cm:title>xpath_search.ftl</cm:title>
|
||||||
<cm:name>xpath_search.ftl</cm:name>
|
<cm:name>xpath_search.ftl</cm:name>
|
||||||
<cm:created>2006-02-10T09:11:06.750Z</cm:created>
|
|
||||||
</view:properties>
|
</view:properties>
|
||||||
<view:associations></view:associations>
|
<view:associations></view:associations>
|
||||||
</cm:content>
|
</cm:content>
|
||||||
|
@@ -20,6 +20,7 @@ import java.io.IOException;
|
|||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
@@ -1485,6 +1486,54 @@ public class NetBIOSNameServer extends NetworkServer implements Runnable
|
|||||||
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
|
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
|
||||||
ipList.add(addrs[i].getAddress());
|
ipList.add(addrs[i].getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the address list is empty, use the network interface list to get the local IP addresses
|
||||||
|
|
||||||
|
if ( ipList.size() == 0)
|
||||||
|
{
|
||||||
|
// Enumerate the network adapter list
|
||||||
|
|
||||||
|
Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces();
|
||||||
|
|
||||||
|
if ( niEnum != null)
|
||||||
|
{
|
||||||
|
while ( niEnum.hasMoreElements())
|
||||||
|
{
|
||||||
|
// Get the current network interface
|
||||||
|
|
||||||
|
NetworkInterface ni = niEnum.nextElement();
|
||||||
|
|
||||||
|
// Enumerate the addresses for the network adapter
|
||||||
|
|
||||||
|
Enumeration<InetAddress> niAddrs = ni.getInetAddresses();
|
||||||
|
if ( niAddrs != null)
|
||||||
|
{
|
||||||
|
// Check for any valid addresses
|
||||||
|
|
||||||
|
while ( niAddrs.hasMoreElements())
|
||||||
|
{
|
||||||
|
InetAddress curAddr = niAddrs.nextElement();
|
||||||
|
|
||||||
|
if ( curAddr.getHostAddress().equals("127.0.0.1") == false &&
|
||||||
|
curAddr.getHostAddress().equals("0.0.0.0") == false)
|
||||||
|
ipList.add( curAddr.getAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
|
||||||
|
if ( ipList.size() > 0 && logger.isDebugEnabled())
|
||||||
|
logger.debug("Found " + ipList.size() + " addresses using interface list");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// DBEUG
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled())
|
||||||
|
logger.debug("Found " + ipList.size() + " addresses using host name lookup");
|
||||||
|
}
|
||||||
|
|
||||||
// Check if any addresses were added to the list
|
// Check if any addresses were added to the list
|
||||||
|
|
||||||
|
@@ -19,7 +19,9 @@ package org.alfresco.filesys.server.config;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.SocketException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
@@ -811,145 +813,199 @@ public class ServerConfiguration implements ApplicationListener
|
|||||||
platformOK = true;
|
platformOK = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the broadcast mask has been specified
|
|
||||||
|
|
||||||
if (getBroadcastMask() == null)
|
|
||||||
throw new AlfrescoRuntimeException("Network broadcast mask not specified");
|
|
||||||
|
|
||||||
// Enable the NetBIOS SMB support, if enabled for this platform
|
// Enable the NetBIOS SMB support, if enabled for this platform
|
||||||
|
|
||||||
setNetBIOSSMB(platformOK);
|
setNetBIOSSMB(platformOK);
|
||||||
|
|
||||||
// Check for a bind address
|
// Parse/check NetBIOS settings, if enabled
|
||||||
|
|
||||||
String bindto = elem.getAttribute("bindto");
|
if ( hasNetBIOSSMB())
|
||||||
if (bindto != null && bindto.length() > 0)
|
|
||||||
{
|
{
|
||||||
|
// Check if the broadcast mask has been specified
|
||||||
// Validate the bind address
|
|
||||||
|
if (getBroadcastMask() == null)
|
||||||
try
|
throw new AlfrescoRuntimeException("Network broadcast mask not specified");
|
||||||
{
|
|
||||||
|
// Check for a bind address
|
||||||
// Check the bind address
|
|
||||||
|
String bindto = elem.getAttribute("bindto");
|
||||||
InetAddress bindAddr = InetAddress.getByName(bindto);
|
if (bindto != null && bindto.length() > 0)
|
||||||
|
{
|
||||||
// Set the bind address for the NetBIOS name server
|
|
||||||
|
// Validate the bind address
|
||||||
setNetBIOSBindAddress(bindAddr);
|
|
||||||
}
|
try
|
||||||
catch (UnknownHostException ex)
|
{
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Invalid NetBIOS bind address");
|
// Check the bind address
|
||||||
}
|
|
||||||
|
InetAddress bindAddr = InetAddress.getByName(bindto);
|
||||||
|
|
||||||
|
// Set the bind address for the NetBIOS name server
|
||||||
|
|
||||||
|
setNetBIOSBindAddress(bindAddr);
|
||||||
|
}
|
||||||
|
catch (UnknownHostException ex)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Invalid NetBIOS bind address");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (hasSMBBindAddress())
|
||||||
|
{
|
||||||
|
|
||||||
|
// Use the SMB bind address for the NetBIOS name server
|
||||||
|
|
||||||
|
setNetBIOSBindAddress(getSMBBindAddress());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get a list of all the local addresses
|
||||||
|
|
||||||
|
InetAddress[] addrs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get the local server IP address list
|
||||||
|
|
||||||
|
addrs = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
|
||||||
|
}
|
||||||
|
catch (UnknownHostException ex)
|
||||||
|
{
|
||||||
|
logger.error("Failed to get local address list", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the address list for one or more valid local addresses filtering out the loopback address
|
||||||
|
|
||||||
|
int addrCnt = 0;
|
||||||
|
|
||||||
|
if ( addrs != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < addrs.length; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Check for a valid address, filter out '127.0.0.1' and '0.0.0.0' addresses
|
||||||
|
|
||||||
|
if (addrs[i].getHostAddress().equals("127.0.0.1") == false
|
||||||
|
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
|
||||||
|
addrCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if any addresses were found
|
||||||
|
|
||||||
|
if ( addrCnt == 0)
|
||||||
|
{
|
||||||
|
// Enumerate the network adapter list
|
||||||
|
|
||||||
|
Enumeration<NetworkInterface> niEnum = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
niEnum = NetworkInterface.getNetworkInterfaces();
|
||||||
|
}
|
||||||
|
catch (SocketException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( niEnum != null)
|
||||||
|
{
|
||||||
|
while ( niEnum.hasMoreElements())
|
||||||
|
{
|
||||||
|
// Get the current network interface
|
||||||
|
|
||||||
|
NetworkInterface ni = niEnum.nextElement();
|
||||||
|
|
||||||
|
// Enumerate the addresses for the network adapter
|
||||||
|
|
||||||
|
Enumeration<InetAddress> niAddrs = ni.getInetAddresses();
|
||||||
|
if ( niAddrs != null)
|
||||||
|
{
|
||||||
|
// Check for any valid addresses
|
||||||
|
|
||||||
|
while ( niAddrs.hasMoreElements())
|
||||||
|
{
|
||||||
|
InetAddress curAddr = niAddrs.nextElement();
|
||||||
|
|
||||||
|
if ( curAddr.getHostAddress().equals("127.0.0.1") == false &&
|
||||||
|
curAddr.getHostAddress().equals("0.0.0.0") == false)
|
||||||
|
addrCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
|
||||||
|
if ( addrCnt > 0 && logger.isDebugEnabled())
|
||||||
|
logger.debug("Found valid IP address from interface list");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we found any valid network addresses
|
||||||
|
|
||||||
|
if ( addrCnt == 0)
|
||||||
|
{
|
||||||
|
// Log the available IP addresses
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Local address list dump :-");
|
||||||
|
if ( addrs != null)
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < addrs.length; i++)
|
||||||
|
logger.debug( " Address: " + addrs[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.debug(" No addresses");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Throw an exception to stop the CIFS/NetBIOS name server from starting
|
||||||
|
|
||||||
|
throw new AlfrescoRuntimeException( "Failed to get IP address(es) for the local server, check hosts file and/or DNS setup");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the session port has been specified
|
||||||
|
|
||||||
|
String portNum = elem.getAttribute("sessionPort");
|
||||||
|
if ( portNum != null && portNum.length() > 0) {
|
||||||
|
try {
|
||||||
|
setNetBIOSSessionPort(Integer.parseInt(portNum));
|
||||||
|
if ( getNetBIOSSessionPort() <= 0 || getNetBIOSSessionPort() >= 65535)
|
||||||
|
throw new AlfrescoRuntimeException("NetBIOS session port out of valid range");
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex) {
|
||||||
|
throw new AlfrescoRuntimeException("Invalid NetBIOS session port");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the name port has been specified
|
||||||
|
|
||||||
|
portNum = elem.getAttribute("namePort");
|
||||||
|
if ( portNum != null && portNum.length() > 0) {
|
||||||
|
try {
|
||||||
|
setNetBIOSNamePort(Integer.parseInt(portNum));
|
||||||
|
if ( getNetBIOSNamePort() <= 0 || getNetBIOSNamePort() >= 65535)
|
||||||
|
throw new AlfrescoRuntimeException("NetBIOS name port out of valid range");
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex) {
|
||||||
|
throw new AlfrescoRuntimeException("Invalid NetBIOS name port");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the datagram port has been specified
|
||||||
|
|
||||||
|
portNum = elem.getAttribute("datagramPort");
|
||||||
|
if ( portNum != null && portNum.length() > 0) {
|
||||||
|
try {
|
||||||
|
setNetBIOSDatagramPort(Integer.parseInt(portNum));
|
||||||
|
if ( getNetBIOSDatagramPort() <= 0 || getNetBIOSDatagramPort() >= 65535)
|
||||||
|
throw new AlfrescoRuntimeException("NetBIOS datagram port out of valid range");
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex) {
|
||||||
|
throw new AlfrescoRuntimeException("Invalid NetBIOS datagram port");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (hasSMBBindAddress())
|
|
||||||
{
|
|
||||||
|
|
||||||
// Use the SMB bind address for the NetBIOS name server
|
|
||||||
|
|
||||||
setNetBIOSBindAddress(getSMBBindAddress());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get a list of all the local addresses
|
|
||||||
|
|
||||||
InetAddress[] addrs = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get the local server IP address list
|
|
||||||
|
|
||||||
addrs = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
|
|
||||||
}
|
|
||||||
catch (UnknownHostException ex)
|
|
||||||
{
|
|
||||||
logger.error("Failed to get local address list", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the address list for one or more valid local addresses filtering out the loopback address
|
|
||||||
|
|
||||||
int addrCnt = 0;
|
|
||||||
|
|
||||||
if ( addrs != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < addrs.length; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Check for a valid address, filter out '127.0.0.1' and '0.0.0.0' addresses
|
|
||||||
|
|
||||||
if (addrs[i].getHostAddress().equals("127.0.0.1") == false
|
|
||||||
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
|
|
||||||
addrCnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if any addresses were found
|
|
||||||
|
|
||||||
if ( addrCnt == 0)
|
|
||||||
{
|
|
||||||
// Log the available IP addresses
|
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Local address list dump :-");
|
|
||||||
if ( addrs != null)
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < addrs.length; i++)
|
|
||||||
logger.debug( " Address: " + addrs[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
logger.debug(" No addresses");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Throw an exception to stop the CIFS/NetBIOS name server from starting
|
|
||||||
|
|
||||||
throw new AlfrescoRuntimeException( "Failed to get IP address(es) for the local server, check hosts file and/or DNS setup");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the session port has been specified
|
|
||||||
|
|
||||||
String portNum = elem.getAttribute("sessionPort");
|
|
||||||
if ( portNum != null && portNum.length() > 0) {
|
|
||||||
try {
|
|
||||||
setNetBIOSSessionPort(Integer.parseInt(portNum));
|
|
||||||
if ( getNetBIOSSessionPort() <= 0 || getNetBIOSSessionPort() >= 65535)
|
|
||||||
throw new AlfrescoRuntimeException("NetBIOS session port out of valid range");
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ex) {
|
|
||||||
throw new AlfrescoRuntimeException("Invalid NetBIOS session port");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the name port has been specified
|
|
||||||
|
|
||||||
portNum = elem.getAttribute("namePort");
|
|
||||||
if ( portNum != null && portNum.length() > 0) {
|
|
||||||
try {
|
|
||||||
setNetBIOSNamePort(Integer.parseInt(portNum));
|
|
||||||
if ( getNetBIOSNamePort() <= 0 || getNetBIOSNamePort() >= 65535)
|
|
||||||
throw new AlfrescoRuntimeException("NetBIOS name port out of valid range");
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ex) {
|
|
||||||
throw new AlfrescoRuntimeException("Invalid NetBIOS name port");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the datagram port has been specified
|
|
||||||
|
|
||||||
portNum = elem.getAttribute("datagramPort");
|
|
||||||
if ( portNum != null && portNum.length() > 0) {
|
|
||||||
try {
|
|
||||||
setNetBIOSDatagramPort(Integer.parseInt(portNum));
|
|
||||||
if ( getNetBIOSDatagramPort() <= 0 || getNetBIOSDatagramPort() >= 65535)
|
|
||||||
throw new AlfrescoRuntimeException("NetBIOS datagram port out of valid range");
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ex) {
|
|
||||||
throw new AlfrescoRuntimeException("Invalid NetBIOS datagram port");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -40,6 +40,9 @@ public interface ContentModel
|
|||||||
// tag for incomplete nodes
|
// tag for incomplete nodes
|
||||||
static final QName ASPECT_INCOMPLETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "incomplete");
|
static final QName ASPECT_INCOMPLETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "incomplete");
|
||||||
|
|
||||||
|
// tag for temporary nodes
|
||||||
|
static final QName ASPECT_TEMPORARY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "temporary");
|
||||||
|
|
||||||
// archived nodes aspect constants
|
// archived nodes aspect constants
|
||||||
static final QName ASPECT_ARCHIVED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived");
|
static final QName ASPECT_ARCHIVED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived");
|
||||||
static final QName PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalParentAssoc");
|
static final QName PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalParentAssoc");
|
||||||
|
@@ -46,7 +46,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* I18N labels
|
* I18N labels
|
||||||
@@ -58,30 +58,30 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
private static final String MSG_ERR_NOT_AUTHENTICATED = "coci_service.err_not_authenticated";
|
private static final String MSG_ERR_NOT_AUTHENTICATED = "coci_service.err_not_authenticated";
|
||||||
private static final String MSG_ERR_WORKINGCOPY_HAS_NO_MIMETYPE = "coci_service.err_workingcopy_has_no_mimetype";
|
private static final String MSG_ERR_WORKINGCOPY_HAS_NO_MIMETYPE = "coci_service.err_workingcopy_has_no_mimetype";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension character, used to recalculate the working copy names
|
* Extension character, used to recalculate the working copy names
|
||||||
*/
|
*/
|
||||||
private static final String EXTENSION_CHARACTER = ".";
|
private static final String EXTENSION_CHARACTER = ".";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The node service
|
* The node service
|
||||||
*/
|
*/
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The version service
|
* The version service
|
||||||
*/
|
*/
|
||||||
private VersionService versionService;
|
private VersionService versionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The lock service
|
* The lock service
|
||||||
*/
|
*/
|
||||||
private LockService lockService;
|
private LockService lockService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The copy service
|
* The copy service
|
||||||
*/
|
*/
|
||||||
private CopyService copyService;
|
private CopyService copyService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The search service
|
* The search service
|
||||||
@@ -97,47 +97,47 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
* The versionable aspect behaviour implementation
|
* The versionable aspect behaviour implementation
|
||||||
*/
|
*/
|
||||||
private VersionableAspect versionableAspect;
|
private VersionableAspect versionableAspect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the node service
|
* Set the node service
|
||||||
*
|
*
|
||||||
* @param nodeService the node service
|
* @param nodeService the node service
|
||||||
*/
|
*/
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the version service
|
* Set the version service
|
||||||
*
|
*
|
||||||
* @param versionService the version service
|
* @param versionService the version service
|
||||||
*/
|
*/
|
||||||
public void setVersionService(VersionService versionService)
|
public void setVersionService(VersionService versionService)
|
||||||
{
|
{
|
||||||
this.versionService = versionService;
|
this.versionService = versionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the lock service
|
* Sets the lock service
|
||||||
*
|
*
|
||||||
* @param lockService the lock service
|
* @param lockService the lock service
|
||||||
*/
|
*/
|
||||||
public void setLockService(LockService lockService)
|
public void setLockService(LockService lockService)
|
||||||
{
|
{
|
||||||
this.lockService = lockService;
|
this.lockService = lockService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the copy service
|
* Sets the copy service
|
||||||
*
|
*
|
||||||
* @param copyService the copy service
|
* @param copyService the copy service
|
||||||
*/
|
*/
|
||||||
public void setCopyService(
|
public void setCopyService(
|
||||||
CopyService copyService)
|
CopyService copyService)
|
||||||
{
|
{
|
||||||
this.copyService = copyService;
|
this.copyService = copyService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the authentication service
|
* Sets the authentication service
|
||||||
@@ -173,57 +173,57 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
/**
|
/**
|
||||||
* Get the working copy label.
|
* Get the working copy label.
|
||||||
*
|
*
|
||||||
* @return the working copy label
|
* @return the working copy label
|
||||||
*/
|
*/
|
||||||
public String getWorkingCopyLabel()
|
public String getWorkingCopyLabel()
|
||||||
{
|
{
|
||||||
return I18NUtil.getMessage(MSG_WORKING_COPY_LABEL);
|
return I18NUtil.getMessage(MSG_WORKING_COPY_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkout(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName)
|
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkout(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName)
|
||||||
*/
|
*/
|
||||||
public NodeRef checkout(
|
public NodeRef checkout(
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
NodeRef destinationParentNodeRef,
|
NodeRef destinationParentNodeRef,
|
||||||
QName destinationAssocTypeQName,
|
QName destinationAssocTypeQName,
|
||||||
QName destinationAssocQName)
|
QName destinationAssocQName)
|
||||||
{
|
{
|
||||||
// Make sure we are no checking out a working copy node
|
// Make sure we are no checking out a working copy node
|
||||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY) == true)
|
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY) == true)
|
||||||
{
|
{
|
||||||
throw new CheckOutCheckInServiceException(MSG_ERR_ALREADY_WORKING_COPY);
|
throw new CheckOutCheckInServiceException(MSG_ERR_ALREADY_WORKING_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the lock aspect if required
|
// Apply the lock aspect if required
|
||||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE) == false)
|
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE) == false)
|
||||||
{
|
{
|
||||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_LOCKABLE, null);
|
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_LOCKABLE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the working copy
|
// Rename the working copy
|
||||||
String copyName = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
String copyName = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
if (this.getWorkingCopyLabel() != null && this.getWorkingCopyLabel().length() != 0)
|
if (this.getWorkingCopyLabel() != null && this.getWorkingCopyLabel().length() != 0)
|
||||||
{
|
{
|
||||||
if (copyName != null && copyName.length() != 0)
|
if (copyName != null && copyName.length() != 0)
|
||||||
{
|
{
|
||||||
int index = copyName.lastIndexOf(EXTENSION_CHARACTER);
|
int index = copyName.lastIndexOf(EXTENSION_CHARACTER);
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
{
|
{
|
||||||
// Insert the working copy label before the file extension
|
// Insert the working copy label before the file extension
|
||||||
copyName = copyName.substring(0, index) + " " + getWorkingCopyLabel() + copyName.substring(index);
|
copyName = copyName.substring(0, index) + " " + getWorkingCopyLabel() + copyName.substring(index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Simply append the working copy label onto the end of the existing name
|
// Simply append the working copy label onto the end of the existing name
|
||||||
copyName = copyName + " " + getWorkingCopyLabel();
|
copyName = copyName + " " + getWorkingCopyLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
copyName = getWorkingCopyLabel();
|
copyName = getWorkingCopyLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the working copy
|
// Make the working copy
|
||||||
destinationAssocQName = QName.createQName(destinationAssocQName.getNamespaceURI(), QName.createValidLocalName(copyName));
|
destinationAssocQName = QName.createQName(destinationAssocQName.getNamespaceURI(), QName.createValidLocalName(copyName));
|
||||||
@@ -236,20 +236,24 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
// Update the working copy name
|
// Update the working copy name
|
||||||
this.nodeService.setProperty(workingCopy, ContentModel.PROP_NAME, copyName);
|
this.nodeService.setProperty(workingCopy, ContentModel.PROP_NAME, copyName);
|
||||||
|
|
||||||
// Get the user
|
// Get the user
|
||||||
String userName = getUserName();
|
String userName = getUserName();
|
||||||
|
|
||||||
// Apply the working copy aspect to the working copy
|
// Apply the working copy aspect to the working copy
|
||||||
Map<QName, Serializable> workingCopyProperties = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> workingCopyProperties = new HashMap<QName, Serializable>(1);
|
||||||
workingCopyProperties.put(ContentModel.PROP_WORKING_COPY_OWNER, userName);
|
workingCopyProperties.put(ContentModel.PROP_WORKING_COPY_OWNER, userName);
|
||||||
this.nodeService.addAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY, workingCopyProperties);
|
this.nodeService.addAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY, workingCopyProperties);
|
||||||
|
|
||||||
// Lock the original node
|
// Apply the sys:temporary aspect to tag the working copy as a temporary node
|
||||||
this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK);
|
// so it doesn't get archived when checked in
|
||||||
|
this.nodeService.addAspect(workingCopy, ContentModel.ASPECT_TEMPORARY, null);
|
||||||
// Return the working copy
|
|
||||||
return workingCopy;
|
// Lock the origional node
|
||||||
}
|
this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK);
|
||||||
|
|
||||||
|
// Return the working copy
|
||||||
|
return workingCopy;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the authenticated users node reference
|
* Gets the authenticated users node reference
|
||||||
@@ -269,64 +273,64 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkout(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkout(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
public NodeRef checkout(NodeRef nodeRef)
|
public NodeRef checkout(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
// Find the primary parent in order to determine where to put the copy
|
// Find the primary parent in order to determine where to put the copy
|
||||||
ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(nodeRef);
|
ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(nodeRef);
|
||||||
|
|
||||||
// Checkout the working copy to the same destination
|
// Checkout the working copy to the same destination
|
||||||
return checkout(nodeRef, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), childAssocRef.getQName());
|
return checkout(nodeRef, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), childAssocRef.getQName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.version.operations.VersionOperationsService#checkin(org.alfresco.repo.ref.NodeRef, Map<String,Serializable>, java.lang.String, boolean)
|
* @see org.alfresco.repo.version.operations.VersionOperationsService#checkin(org.alfresco.repo.ref.NodeRef, Map<String,Serializable>, java.lang.String, boolean)
|
||||||
*/
|
*/
|
||||||
public NodeRef checkin(
|
public NodeRef checkin(
|
||||||
NodeRef workingCopyNodeRef,
|
NodeRef workingCopyNodeRef,
|
||||||
Map<String,Serializable> versionProperties,
|
Map<String,Serializable> versionProperties,
|
||||||
String contentUrl,
|
String contentUrl,
|
||||||
boolean keepCheckedOut)
|
boolean keepCheckedOut)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = null;
|
NodeRef nodeRef = null;
|
||||||
|
|
||||||
// Check that we have been handed a working copy
|
// Check that we have been handed a working copy
|
||||||
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY) == false)
|
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY) == false)
|
||||||
{
|
{
|
||||||
// Error since we have not been passed a working copy
|
// Error since we have not been passed a working copy
|
||||||
throw new AspectMissingException(ContentModel.ASPECT_WORKING_COPY, workingCopyNodeRef);
|
throw new AspectMissingException(ContentModel.ASPECT_WORKING_COPY, workingCopyNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the working node still has the copy aspect applied
|
// Check that the working node still has the copy aspect applied
|
||||||
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
||||||
{
|
{
|
||||||
// Disable versionable behaviours since we don't want the auto version policy behaviour to execute when we check-in
|
// Disable versionable behaviours since we don't want the auto version policy behaviour to execute when we check-in
|
||||||
this.versionableAspect.disableAutoVersion();
|
this.versionableAspect.disableAutoVersion();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> workingCopyProperties = nodeService.getProperties(workingCopyNodeRef);
|
Map<QName, Serializable> workingCopyProperties = nodeService.getProperties(workingCopyNodeRef);
|
||||||
// Try and get the original node reference
|
// Try and get the original node reference
|
||||||
nodeRef = (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE);
|
nodeRef = (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE);
|
||||||
if(nodeRef == null)
|
if(nodeRef == null)
|
||||||
{
|
{
|
||||||
// Error since the original node can not be found
|
// Error since the original node can not be found
|
||||||
throw new CheckOutCheckInServiceException(MSG_ERR_BAD_COPY);
|
throw new CheckOutCheckInServiceException(MSG_ERR_BAD_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Release the lock
|
// Release the lock
|
||||||
this.lockService.unlock(nodeRef);
|
this.lockService.unlock(nodeRef);
|
||||||
}
|
}
|
||||||
catch (UnableToReleaseLockException exception)
|
catch (UnableToReleaseLockException exception)
|
||||||
{
|
{
|
||||||
throw new CheckOutCheckInServiceException(MSG_ERR_NOT_OWNER, exception);
|
throw new CheckOutCheckInServiceException(MSG_ERR_NOT_OWNER, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contentUrl != null)
|
if (contentUrl != null)
|
||||||
{
|
{
|
||||||
ContentData contentData = (ContentData) workingCopyProperties.get(ContentModel.PROP_CONTENT);
|
ContentData contentData = (ContentData) workingCopyProperties.get(ContentModel.PROP_CONTENT);
|
||||||
if (contentData == null)
|
if (contentData == null)
|
||||||
{
|
{
|
||||||
@@ -340,15 +344,15 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
contentData.getSize(),
|
contentData.getSize(),
|
||||||
contentData.getEncoding());
|
contentData.getEncoding());
|
||||||
}
|
}
|
||||||
// Set the content url value onto the working copy
|
// Set the content url value onto the working copy
|
||||||
this.nodeService.setProperty(
|
this.nodeService.setProperty(
|
||||||
workingCopyNodeRef,
|
workingCopyNodeRef,
|
||||||
ContentModel.PROP_CONTENT,
|
ContentModel.PROP_CONTENT,
|
||||||
contentData);
|
contentData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the contents of the working copy onto the original
|
// Copy the contents of the working copy onto the original
|
||||||
this.copyService.copy(workingCopyNodeRef, nodeRef);
|
this.copyService.copy(workingCopyNodeRef, nodeRef);
|
||||||
|
|
||||||
if (versionProperties != null && this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
|
if (versionProperties != null && this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
|
||||||
{
|
{
|
||||||
@@ -356,94 +360,94 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
this.versionService.createVersion(nodeRef, versionProperties);
|
this.versionService.createVersion(nodeRef, versionProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keepCheckedOut == false)
|
if (keepCheckedOut == false)
|
||||||
{
|
{
|
||||||
// Delete the working copy
|
// Delete the working copy
|
||||||
this.nodeService.removeAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY);
|
this.nodeService.removeAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY);
|
||||||
this.nodeService.deleteNode(workingCopyNodeRef);
|
this.nodeService.deleteNode(workingCopyNodeRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Re-lock the original node
|
// Re-lock the original node
|
||||||
this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK);
|
this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
this.versionableAspect.enableAutoVersion();
|
this.versionableAspect.enableAutoVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Error since the copy aspect is missing
|
// Error since the copy aspect is missing
|
||||||
throw new AspectMissingException(ContentModel.ASPECT_COPIEDFROM, workingCopyNodeRef);
|
throw new AspectMissingException(ContentModel.ASPECT_COPIEDFROM, workingCopyNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeRef;
|
return nodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkin(org.alfresco.service.cmr.repository.NodeRef, Map, java.lang.String)
|
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkin(org.alfresco.service.cmr.repository.NodeRef, Map, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public NodeRef checkin(
|
public NodeRef checkin(
|
||||||
NodeRef workingCopyNodeRef,
|
NodeRef workingCopyNodeRef,
|
||||||
Map<String, Serializable> versionProperties,
|
Map<String, Serializable> versionProperties,
|
||||||
String contentUrl)
|
String contentUrl)
|
||||||
{
|
{
|
||||||
return checkin(workingCopyNodeRef, versionProperties, contentUrl, false);
|
return checkin(workingCopyNodeRef, versionProperties, contentUrl, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkin(org.alfresco.service.cmr.repository.NodeRef, Map)
|
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#checkin(org.alfresco.service.cmr.repository.NodeRef, Map)
|
||||||
*/
|
*/
|
||||||
public NodeRef checkin(
|
public NodeRef checkin(
|
||||||
NodeRef workingCopyNodeRef,
|
NodeRef workingCopyNodeRef,
|
||||||
Map<String, Serializable> versionProperties)
|
Map<String, Serializable> versionProperties)
|
||||||
{
|
{
|
||||||
return checkin(workingCopyNodeRef, versionProperties, null, false);
|
return checkin(workingCopyNodeRef, versionProperties, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#cancelCheckout(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#cancelCheckout(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
public NodeRef cancelCheckout(NodeRef workingCopyNodeRef)
|
public NodeRef cancelCheckout(NodeRef workingCopyNodeRef)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = null;
|
NodeRef nodeRef = null;
|
||||||
|
|
||||||
// Check that we have been handed a working copy
|
// Check that we have been handed a working copy
|
||||||
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY) == false)
|
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY) == false)
|
||||||
{
|
{
|
||||||
// Error since we have not been passed a working copy
|
// Error since we have not been passed a working copy
|
||||||
throw new AspectMissingException(ContentModel.ASPECT_WORKING_COPY, workingCopyNodeRef);
|
throw new AspectMissingException(ContentModel.ASPECT_WORKING_COPY, workingCopyNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the node has the copy aspect
|
// Ensure that the node has the copy aspect
|
||||||
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
||||||
{
|
{
|
||||||
// Get the original node
|
// Get the original node
|
||||||
nodeRef = (NodeRef)this.nodeService.getProperty(workingCopyNodeRef, ContentModel.PROP_COPY_REFERENCE);
|
nodeRef = (NodeRef)this.nodeService.getProperty(workingCopyNodeRef, ContentModel.PROP_COPY_REFERENCE);
|
||||||
if (nodeRef == null)
|
if (nodeRef == null)
|
||||||
{
|
{
|
||||||
// Error since the original node can not be found
|
// Error since the original node can not be found
|
||||||
throw new CheckOutCheckInServiceException(MSG_ERR_BAD_COPY);
|
throw new CheckOutCheckInServiceException(MSG_ERR_BAD_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the lock on the original node
|
// Release the lock on the original node
|
||||||
this.lockService.unlock(nodeRef);
|
this.lockService.unlock(nodeRef);
|
||||||
|
|
||||||
// Delete the working copy
|
// Delete the working copy
|
||||||
this.nodeService.removeAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY);
|
this.nodeService.removeAspect(workingCopyNodeRef, ContentModel.ASPECT_WORKING_COPY);
|
||||||
this.nodeService.deleteNode(workingCopyNodeRef);
|
this.nodeService.deleteNode(workingCopyNodeRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Error since the copy aspect is missing
|
// Error since the copy aspect is missing
|
||||||
throw new AspectMissingException(ContentModel.ASPECT_COPIEDFROM, workingCopyNodeRef);
|
throw new AspectMissingException(ContentModel.ASPECT_COPIEDFROM, workingCopyNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeRef;
|
return nodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#getWorkingCopy(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.coci.CheckOutCheckInService#getWorkingCopy(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
@@ -454,6 +458,7 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
|||||||
|
|
||||||
// Do a search to find the working copy document
|
// Do a search to find the working copy document
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resultSet = this.searchService.query(
|
resultSet = this.searchService.query(
|
||||||
|
@@ -150,14 +150,6 @@ public abstract class AbstractContentAccessor implements ContentAccessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Derived classes must implement this to help determine if the underlying
|
|
||||||
* IO Channel is still open.
|
|
||||||
*
|
|
||||||
* @return Returns true if the underlying IO Channel is open
|
|
||||||
*/
|
|
||||||
protected abstract boolean isChannelOpen();
|
|
||||||
|
|
||||||
public String getContentUrl()
|
public String getContentUrl()
|
||||||
{
|
{
|
||||||
return contentUrl;
|
return contentUrl;
|
||||||
|
@@ -141,8 +141,7 @@ public abstract class AbstractContentReader extends AbstractContentAccessor impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** helper implementation for base class */
|
public synchronized boolean isChannelOpen()
|
||||||
protected boolean isChannelOpen()
|
|
||||||
{
|
{
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
{
|
{
|
||||||
|
@@ -156,8 +156,7 @@ public abstract class AbstractContentWriter extends AbstractContentAccessor impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** helper implementation for base class */
|
public synchronized boolean isChannelOpen()
|
||||||
protected boolean isChannelOpen()
|
|
||||||
{
|
{
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
{
|
{
|
||||||
|
@@ -23,6 +23,8 @@ import java.io.OutputStream;
|
|||||||
import javax.transaction.RollbackException;
|
import javax.transaction.RollbackException;
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.filestore.FileContentWriter;
|
import org.alfresco.repo.content.filestore.FileContentWriter;
|
||||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||||
@@ -43,18 +45,21 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.BaseSpringTest;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.alfresco.util.TempFileProvider;
|
import org.alfresco.util.TempFileProvider;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.content.RoutingContentService
|
* @see org.alfresco.repo.content.RoutingContentService
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
public class RoutingContentServiceTest extends BaseSpringTest
|
public class RoutingContentServiceTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
private static final String SOME_CONTENT = "ABC";
|
private static final String SOME_CONTENT = "ABC";
|
||||||
|
|
||||||
private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/RoutingContentServiceTest";
|
private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/RoutingContentServiceTest";
|
||||||
@@ -62,24 +67,30 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
private UserTransaction txn;
|
||||||
private NodeRef rootNodeRef;
|
private NodeRef rootNodeRef;
|
||||||
private NodeRef contentNodeRef;
|
private NodeRef contentNodeRef;
|
||||||
private AuthenticationComponent authenticationComponent;
|
|
||||||
|
|
||||||
public RoutingContentServiceTest()
|
public RoutingContentServiceTest()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetUpInTransaction() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
super.onSetUpInTransaction();
|
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
||||||
nodeService = (NodeService) applicationContext.getBean("dbNodeService");
|
contentService = (ContentService) ctx.getBean(ServiceRegistry.CONTENT_SERVICE.getLocalName());
|
||||||
contentService = (ContentService) applicationContext.getBean(ServiceRegistry.CONTENT_SERVICE.getLocalName());
|
this.policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
|
||||||
this.policyComponent = (PolicyComponent)this.applicationContext.getBean("policyComponent");
|
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
||||||
this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
|
|
||||||
|
|
||||||
|
// authenticate
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
|
||||||
|
// start the transaction
|
||||||
|
txn = getUserTransaction();
|
||||||
|
txn.begin();
|
||||||
|
|
||||||
// create a store and get the root node
|
// create a store and get the root node
|
||||||
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
|
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
|
||||||
if (!nodeService.exists(storeRef))
|
if (!nodeService.exists(storeRef))
|
||||||
@@ -103,7 +114,7 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onTearDownInTransaction() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -113,12 +124,22 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
{
|
{
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
super.onTearDownInTransaction();
|
try
|
||||||
|
{
|
||||||
|
if (txn != null)
|
||||||
|
{
|
||||||
|
txn.rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable e)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserTransaction getUserTransaction()
|
private UserTransaction getUserTransaction()
|
||||||
{
|
{
|
||||||
TransactionService transactionService = (TransactionService)applicationContext.getBean("transactionComponent");
|
TransactionService transactionService = (TransactionService) ctx.getBean("transactionComponent");
|
||||||
return (UserTransaction) transactionService.getUserTransaction();
|
return (UserTransaction) transactionService.getUserTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,8 +257,8 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
assertFalse("Reader should indicate that content is missing", reader.exists());
|
assertFalse("Reader should indicate that content is missing", reader.exists());
|
||||||
|
|
||||||
// check the indexing doesn't spank everthing
|
// check the indexing doesn't spank everthing
|
||||||
setComplete();
|
txn.commit();
|
||||||
endTransaction();
|
txn = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -405,8 +426,8 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
public void testConcurrentWritesNoTxn() throws Exception
|
public void testConcurrentWritesNoTxn() throws Exception
|
||||||
{
|
{
|
||||||
// ensure that the transaction is ended - ofcourse, we need to force a commit
|
// ensure that the transaction is ended - ofcourse, we need to force a commit
|
||||||
setComplete();
|
txn.commit();
|
||||||
endTransaction();
|
txn = null;
|
||||||
|
|
||||||
ContentWriter writer1 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
|
ContentWriter writer1 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
|
||||||
ContentWriter writer2 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
|
ContentWriter writer2 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
|
||||||
@@ -425,8 +446,8 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
public void testConcurrentWritesWithSingleTxn() throws Exception
|
public void testConcurrentWritesWithSingleTxn() throws Exception
|
||||||
{
|
{
|
||||||
// want to operate in a user transaction
|
// want to operate in a user transaction
|
||||||
setComplete();
|
txn.commit();
|
||||||
endTransaction();
|
txn = null;
|
||||||
|
|
||||||
UserTransaction txn = getUserTransaction();
|
UserTransaction txn = getUserTransaction();
|
||||||
txn.begin();
|
txn.begin();
|
||||||
@@ -472,8 +493,8 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
public synchronized void testConcurrentWritesWithMultipleTxns() throws Exception
|
public synchronized void testConcurrentWritesWithMultipleTxns() throws Exception
|
||||||
{
|
{
|
||||||
// commit node so that threads can see node
|
// commit node so that threads can see node
|
||||||
setComplete();
|
txn.commit();
|
||||||
endTransaction();
|
txn = null;
|
||||||
|
|
||||||
UserTransaction txn = getUserTransaction();
|
UserTransaction txn = getUserTransaction();
|
||||||
txn.begin();
|
txn.begin();
|
||||||
@@ -527,8 +548,8 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
public void testTransformation() throws Exception
|
public void testTransformation() throws Exception
|
||||||
{
|
{
|
||||||
// commit node so that threads can see node
|
// commit node so that threads can see node
|
||||||
setComplete();
|
txn.commit();
|
||||||
endTransaction();
|
txn = null;
|
||||||
|
|
||||||
UserTransaction txn = getUserTransaction();
|
UserTransaction txn = getUserTransaction();
|
||||||
txn.begin();
|
txn.begin();
|
||||||
@@ -655,4 +676,27 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that the system is able to handle the uploading of content with an unknown mimetype.
|
||||||
|
* The unknown mimetype should be preserved, but treated just like an octet stream.
|
||||||
|
*/
|
||||||
|
public void testUnknownMimetype() throws Exception
|
||||||
|
{
|
||||||
|
String bogusMimetype = "text/bamboozle";
|
||||||
|
// get a writer onto the node
|
||||||
|
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
|
||||||
|
writer.setMimetype(bogusMimetype);
|
||||||
|
|
||||||
|
// write something in
|
||||||
|
writer.putContent(SOME_CONTENT);
|
||||||
|
|
||||||
|
// commit the transaction to ensure that it goes in OK
|
||||||
|
txn.commit();
|
||||||
|
|
||||||
|
// so far, so good
|
||||||
|
ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
|
||||||
|
assertNotNull("Should be able to get reader", reader);
|
||||||
|
assertEquals("Unknown mimetype was changed", bogusMimetype, reader.getMimetype());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,220 +1,220 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
abstract public class AbstractMetadataExtracter implements MetadataExtracter
|
abstract public class AbstractMetadataExtracter implements MetadataExtracter
|
||||||
{
|
{
|
||||||
protected static Log logger = LogFactory.getLog(AbstractMetadataExtracter.class);
|
protected static Log logger = LogFactory.getLog(AbstractMetadataExtracter.class);
|
||||||
|
|
||||||
private MimetypeService mimetypeService;
|
private MimetypeService mimetypeService;
|
||||||
private MetadataExtracterRegistry registry;
|
private MetadataExtracterRegistry registry;
|
||||||
private Set<String> supportedMimetypes;
|
private Set<String> supportedMimetypes;
|
||||||
private double reliability;
|
private double reliability;
|
||||||
private long extractionTime;
|
private long extractionTime;
|
||||||
|
|
||||||
protected AbstractMetadataExtracter(String supportedMimetype, double reliability, long extractionTime)
|
protected AbstractMetadataExtracter(String supportedMimetype, double reliability, long extractionTime)
|
||||||
{
|
{
|
||||||
this.supportedMimetypes = Collections.singleton(supportedMimetype);
|
this.supportedMimetypes = Collections.singleton(supportedMimetype);
|
||||||
this.reliability = reliability;
|
this.reliability = reliability;
|
||||||
this.extractionTime = extractionTime;
|
this.extractionTime = extractionTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractMetadataExtracter(Set<String> supportedMimetypes, double reliability, long extractionTime)
|
protected AbstractMetadataExtracter(Set<String> supportedMimetypes, double reliability, long extractionTime)
|
||||||
{
|
{
|
||||||
this.supportedMimetypes = supportedMimetypes;
|
this.supportedMimetypes = supportedMimetypes;
|
||||||
this.reliability = reliability;
|
this.reliability = reliability;
|
||||||
this.extractionTime = extractionTime;
|
this.extractionTime = extractionTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the registry to register with
|
* Set the registry to register with
|
||||||
*
|
*
|
||||||
* @param registry a metadata extracter registry
|
* @param registry a metadata extracter registry
|
||||||
*/
|
*/
|
||||||
public void setRegistry(MetadataExtracterRegistry registry)
|
public void setRegistry(MetadataExtracterRegistry registry)
|
||||||
{
|
{
|
||||||
this.registry = registry;
|
this.registry = registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper setter of the mimetype service. This is not always required.
|
* Helper setter of the mimetype service. This is not always required.
|
||||||
*
|
*
|
||||||
* @param mimetypeService
|
* @param mimetypeService
|
||||||
*/
|
*/
|
||||||
public void setMimetypeService(MimetypeService mimetypeService)
|
public void setMimetypeService(MimetypeService mimetypeService)
|
||||||
{
|
{
|
||||||
this.mimetypeService = mimetypeService;
|
this.mimetypeService = mimetypeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the mimetype helper
|
* @return Returns the mimetype helper
|
||||||
*/
|
*/
|
||||||
protected MimetypeService getMimetypeService()
|
protected MimetypeService getMimetypeService()
|
||||||
{
|
{
|
||||||
return mimetypeService;
|
return mimetypeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers this instance of the extracter with the registry.
|
* Registers this instance of the extracter with the registry.
|
||||||
*
|
*
|
||||||
* @see #setRegistry(MetadataExtracterRegistry)
|
* @see #setRegistry(MetadataExtracterRegistry)
|
||||||
*/
|
*/
|
||||||
public void register()
|
public void register()
|
||||||
{
|
{
|
||||||
if (registry == null)
|
if (registry == null)
|
||||||
{
|
{
|
||||||
logger.warn("Property 'registry' has not been set. Ignoring auto-registration: \n" +
|
logger.warn("Property 'registry' has not been set. Ignoring auto-registration: \n" +
|
||||||
" extracter: " + this);
|
" extracter: " + this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
registry.register(this);
|
registry.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default reliability check that returns the reliability as configured by the contstructor
|
* Default reliability check that returns the reliability as configured by the contstructor
|
||||||
* if the mimetype is in the list of supported mimetypes.
|
* if the mimetype is in the list of supported mimetypes.
|
||||||
*
|
*
|
||||||
* @param mimetype the mimetype to check
|
* @param mimetype the mimetype to check
|
||||||
*/
|
*/
|
||||||
public double getReliability(String mimetype)
|
public double getReliability(String mimetype)
|
||||||
{
|
{
|
||||||
if (supportedMimetypes.contains(mimetype))
|
if (supportedMimetypes.contains(mimetype))
|
||||||
return reliability;
|
return reliability;
|
||||||
else
|
else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getExtractionTime()
|
public long getExtractionTime()
|
||||||
{
|
{
|
||||||
return extractionTime;
|
return extractionTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the mimetype is supported.
|
* Checks if the mimetype is supported.
|
||||||
*
|
*
|
||||||
* @param reader the reader to check
|
* @param reader the reader to check
|
||||||
* @throws AlfrescoRuntimeException if the mimetype is not supported
|
* @throws AlfrescoRuntimeException if the mimetype is not supported
|
||||||
*/
|
*/
|
||||||
protected void checkReliability(ContentReader reader)
|
protected void checkReliability(ContentReader reader)
|
||||||
{
|
{
|
||||||
String mimetype = reader.getMimetype();
|
String mimetype = reader.getMimetype();
|
||||||
if (getReliability(mimetype) <= 0.0)
|
if (getReliability(mimetype) <= 0.0)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException(
|
throw new AlfrescoRuntimeException(
|
||||||
"Metadata extracter does not support mimetype: \n" +
|
"Metadata extracter does not support mimetype: \n" +
|
||||||
" reader: " + reader + "\n" +
|
" reader: " + reader + "\n" +
|
||||||
" supported: " + supportedMimetypes + "\n" +
|
" supported: " + supportedMimetypes + "\n" +
|
||||||
" extracter: " + this);
|
" extracter: " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void extract(ContentReader reader, Map<QName, Serializable> destination) throws ContentIOException
|
public final void extract(ContentReader reader, Map<QName, Serializable> destination) throws ContentIOException
|
||||||
{
|
{
|
||||||
// check the reliability
|
// check the reliability
|
||||||
checkReliability(reader);
|
checkReliability(reader);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
extractInternal(reader, destination);
|
extractInternal(reader, destination);
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
throw new ContentIOException("Metadata extraction failed: \n" +
|
throw new ContentIOException("Metadata extraction failed: \n" +
|
||||||
" reader: " + reader,
|
" reader: " + reader,
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// check that the reader was closed
|
// check that the reader was closed
|
||||||
if (!reader.isClosed())
|
if (!reader.isClosed())
|
||||||
{
|
{
|
||||||
logger.error("Content reader not closed by metadata extracter: \n" +
|
logger.error("Content reader not closed by metadata extracter: \n" +
|
||||||
" reader: " + reader + "\n" +
|
" reader: " + reader + "\n" +
|
||||||
" extracter: " + this);
|
" extracter: " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Completed metadata extraction: \n" +
|
logger.debug("Completed metadata extraction: \n" +
|
||||||
" reader: " + reader + "\n" +
|
" reader: " + reader + "\n" +
|
||||||
" extracter: " + this);
|
" extracter: " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override to provide the necessary extraction logic. Implementations must ensure that the reader
|
* Override to provide the necessary extraction logic. Implementations must ensure that the reader
|
||||||
* is closed before the method exits.
|
* is closed before the method exits.
|
||||||
*
|
*
|
||||||
* @param reader the source of the content
|
* @param reader the source of the content
|
||||||
* @param destination the property map to fill
|
* @param destination the property map to fill
|
||||||
* @throws Throwable an exception
|
* @throws Throwable an exception
|
||||||
*/
|
*/
|
||||||
protected abstract void extractInternal(ContentReader reader, Map<QName, Serializable> destination) throws Throwable;
|
protected abstract void extractInternal(ContentReader reader, Map<QName, Serializable> destination) throws Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Examines a value or string for nulls and adds it to the map (if
|
* Examines a value or string for nulls and adds it to the map (if
|
||||||
* non-empty)
|
* non-empty)
|
||||||
*
|
*
|
||||||
* @param prop Alfresco's <code>ContentModel.PROP_</code> to set.
|
* @param prop Alfresco's <code>ContentModel.PROP_</code> to set.
|
||||||
* @param value Value to set it to
|
* @param value Value to set it to
|
||||||
* @param destination Map into which to set it
|
* @param destination Map into which to set it
|
||||||
* @return true, if set, false otherwise
|
* @return true, if set, false otherwise
|
||||||
*/
|
*/
|
||||||
protected boolean trimPut(QName prop, Object value, Map<QName, Serializable> destination)
|
protected boolean trimPut(QName prop, Object value, Map<QName, Serializable> destination)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return false;
|
return false;
|
||||||
if (value instanceof String)
|
if (value instanceof String)
|
||||||
{
|
{
|
||||||
String svalue = ((String) value).trim();
|
String svalue = ((String) value).trim();
|
||||||
if (svalue.length() > 0)
|
if (svalue.length() > 0)
|
||||||
{
|
{
|
||||||
destination.put(prop, svalue);
|
destination.put(prop, svalue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (value instanceof Serializable)
|
else if (value instanceof Serializable)
|
||||||
{
|
{
|
||||||
destination.put(prop, (Serializable) value);
|
destination.put(prop, (Serializable) value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
destination.put(prop, value.toString());
|
destination.put(prop, value.toString());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,116 +1,116 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||||
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.alfresco.util.TempFileProvider;
|
import org.alfresco.util.TempFileProvider;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.content.metadata.MetadataExtracter
|
* @see org.alfresco.repo.content.metadata.MetadataExtracter
|
||||||
* @see org.alfresco.repo.content.metadata.AbstractMetadataExtracter
|
* @see org.alfresco.repo.content.metadata.AbstractMetadataExtracter
|
||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractMetadataExtracterTest extends TestCase
|
public abstract class AbstractMetadataExtracterTest extends TestCase
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
protected static final String QUICK_TITLE = "The quick brown fox jumps over the lazy dog";
|
protected static final String QUICK_TITLE = "The quick brown fox jumps over the lazy dog";
|
||||||
protected static final String QUICK_DESCRIPTION = "Gym class featuring a brown fox and lazy dog";
|
protected static final String QUICK_DESCRIPTION = "Gym class featuring a brown fox and lazy dog";
|
||||||
protected static final String QUICK_CREATOR = "Nevin Nollop";
|
protected static final String QUICK_CREATOR = "Nevin Nollop";
|
||||||
|
|
||||||
protected MimetypeMap mimetypeMap;
|
protected MimetypeMap mimetypeMap;
|
||||||
|
|
||||||
protected abstract MetadataExtracter getExtracter();
|
protected abstract MetadataExtracter getExtracter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the temp locations are cleaned out before the tests start
|
* Ensures that the temp locations are cleaned out before the tests start
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
this.mimetypeMap = (MimetypeMap) ctx.getBean("mimetypeService");
|
this.mimetypeMap = (MimetypeMap) ctx.getBean("mimetypeService");
|
||||||
|
|
||||||
// perform a little cleaning up
|
// perform a little cleaning up
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TempFileProvider.TempFileCleanerJob.removeFiles(now);
|
TempFileProvider.TempFileCleanerJob.removeFiles(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that all objects are present
|
* Check that all objects are present
|
||||||
*/
|
*/
|
||||||
public void testSetUp() throws Exception
|
public void testSetUp() throws Exception
|
||||||
{
|
{
|
||||||
assertNotNull("MimetypeMap not present", mimetypeMap);
|
assertNotNull("MimetypeMap not present", mimetypeMap);
|
||||||
// check that the quick resources are available
|
// check that the quick resources are available
|
||||||
File sourceFile = AbstractContentTransformerTest.loadQuickTestFile("txt");
|
File sourceFile = AbstractContentTransformerTest.loadQuickTestFile("txt");
|
||||||
assertNotNull("quick.* files should be available from Tests", sourceFile);
|
assertNotNull("quick.* files should be available from Tests", sourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testExtractFromMimetype(String mimetype) throws Exception
|
protected void testExtractFromMimetype(String mimetype) throws Exception
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> properties = extractFromMimetype(mimetype);
|
Map<QName, Serializable> properties = extractFromMimetype(mimetype);
|
||||||
// check
|
// check
|
||||||
testCommonMetadata(mimetype, properties);
|
testCommonMetadata(mimetype, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<QName, Serializable> extractFromMimetype(String mimetype) throws Exception
|
protected Map<QName, Serializable> extractFromMimetype(String mimetype) throws Exception
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||||
|
|
||||||
// get the extension for the mimetype
|
// get the extension for the mimetype
|
||||||
String ext = mimetypeMap.getExtension(mimetype);
|
String ext = mimetypeMap.getExtension(mimetype);
|
||||||
|
|
||||||
// attempt to get a source file for each mimetype
|
// attempt to get a source file for each mimetype
|
||||||
File sourceFile = AbstractContentTransformerTest.loadQuickTestFile(ext);
|
File sourceFile = AbstractContentTransformerTest.loadQuickTestFile(ext);
|
||||||
if (sourceFile == null)
|
if (sourceFile == null)
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException("No quick." + ext + " file found for test");
|
throw new FileNotFoundException("No quick." + ext + " file found for test");
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct a reader onto the source file
|
// construct a reader onto the source file
|
||||||
ContentReader sourceReader = new FileContentReader(sourceFile);
|
ContentReader sourceReader = new FileContentReader(sourceFile);
|
||||||
sourceReader.setMimetype(mimetype);
|
sourceReader.setMimetype(mimetype);
|
||||||
getExtracter().extract(sourceReader, properties);
|
getExtracter().extract(sourceReader, properties);
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testCommonMetadata(String mimetype, Map<QName, Serializable> properties)
|
protected void testCommonMetadata(String mimetype, Map<QName, Serializable> properties)
|
||||||
{
|
{
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Property " + ContentModel.PROP_TITLE + " not found for mimetype " + mimetype,
|
"Property " + ContentModel.PROP_TITLE + " not found for mimetype " + mimetype,
|
||||||
QUICK_TITLE, properties.get(ContentModel.PROP_TITLE));
|
QUICK_TITLE, properties.get(ContentModel.PROP_TITLE));
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Property " + ContentModel.PROP_DESCRIPTION + " not found for mimetype " + mimetype,
|
"Property " + ContentModel.PROP_DESCRIPTION + " not found for mimetype " + mimetype,
|
||||||
QUICK_DESCRIPTION, properties.get(ContentModel.PROP_DESCRIPTION));
|
QUICK_DESCRIPTION, properties.get(ContentModel.PROP_DESCRIPTION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,169 +1,169 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.swing.text.ChangedCharSetException;
|
import javax.swing.text.ChangedCharSetException;
|
||||||
import javax.swing.text.MutableAttributeSet;
|
import javax.swing.text.MutableAttributeSet;
|
||||||
import javax.swing.text.html.HTML;
|
import javax.swing.text.html.HTML;
|
||||||
import javax.swing.text.html.HTMLEditorKit;
|
import javax.swing.text.html.HTMLEditorKit;
|
||||||
import javax.swing.text.html.parser.ParserDelegator;
|
import javax.swing.text.html.parser.ParserDelegator;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
public class HtmlMetadataExtracter extends AbstractMetadataExtracter
|
public class HtmlMetadataExtracter extends AbstractMetadataExtracter
|
||||||
{
|
{
|
||||||
private static final Set<String> MIMETYPES = new HashSet<String>(5);
|
private static final Set<String> MIMETYPES = new HashSet<String>(5);
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
MIMETYPES.add(MimetypeMap.MIMETYPE_HTML);
|
MIMETYPES.add(MimetypeMap.MIMETYPE_HTML);
|
||||||
MIMETYPES.add(MimetypeMap.MIMETYPE_XHTML);
|
MIMETYPES.add(MimetypeMap.MIMETYPE_XHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HtmlMetadataExtracter()
|
public HtmlMetadataExtracter()
|
||||||
{
|
{
|
||||||
super(MIMETYPES, 1.0, 1000);
|
super(MIMETYPES, 1.0, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extractInternal(ContentReader reader, Map<QName, Serializable> destination) throws Throwable
|
public void extractInternal(ContentReader reader, Map<QName, Serializable> destination) throws Throwable
|
||||||
{
|
{
|
||||||
final Map<QName, Serializable> tempDestination = new HashMap<QName, Serializable>();
|
final Map<QName, Serializable> tempDestination = new HashMap<QName, Serializable>();
|
||||||
|
|
||||||
HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback()
|
HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback()
|
||||||
{
|
{
|
||||||
StringBuffer title = null;
|
StringBuffer title = null;
|
||||||
boolean inHead = false;
|
boolean inHead = false;
|
||||||
|
|
||||||
public void handleText(char[] data, int pos)
|
public void handleText(char[] data, int pos)
|
||||||
{
|
{
|
||||||
if (title != null)
|
if (title != null)
|
||||||
{
|
{
|
||||||
title.append(data);
|
title.append(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleComment(char[] data, int pos)
|
public void handleComment(char[] data, int pos)
|
||||||
{
|
{
|
||||||
// Perhaps sniff for Office 9+ metadata in here?
|
// Perhaps sniff for Office 9+ metadata in here?
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos)
|
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos)
|
||||||
{
|
{
|
||||||
if (HTML.Tag.HEAD.equals(t))
|
if (HTML.Tag.HEAD.equals(t))
|
||||||
{
|
{
|
||||||
inHead = true;
|
inHead = true;
|
||||||
}
|
}
|
||||||
else if (HTML.Tag.TITLE.equals(t) && inHead)
|
else if (HTML.Tag.TITLE.equals(t) && inHead)
|
||||||
{
|
{
|
||||||
title = new StringBuffer();
|
title = new StringBuffer();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
handleSimpleTag(t, a, pos);
|
handleSimpleTag(t, a, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleEndTag(HTML.Tag t, int pos)
|
public void handleEndTag(HTML.Tag t, int pos)
|
||||||
{
|
{
|
||||||
if (HTML.Tag.HEAD.equals(t))
|
if (HTML.Tag.HEAD.equals(t))
|
||||||
{
|
{
|
||||||
inHead = false;
|
inHead = false;
|
||||||
}
|
}
|
||||||
else if (HTML.Tag.TITLE.equals(t) && title != null)
|
else if (HTML.Tag.TITLE.equals(t) && title != null)
|
||||||
{
|
{
|
||||||
trimPut(ContentModel.PROP_TITLE, title.toString(), tempDestination);
|
trimPut(ContentModel.PROP_TITLE, title.toString(), tempDestination);
|
||||||
title = null;
|
title = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
|
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
|
||||||
{
|
{
|
||||||
if (HTML.Tag.META.equals(t))
|
if (HTML.Tag.META.equals(t))
|
||||||
{
|
{
|
||||||
Object nameO = a.getAttribute(HTML.Attribute.NAME);
|
Object nameO = a.getAttribute(HTML.Attribute.NAME);
|
||||||
Object valueO = a.getAttribute(HTML.Attribute.CONTENT);
|
Object valueO = a.getAttribute(HTML.Attribute.CONTENT);
|
||||||
if (nameO == null || valueO == null)
|
if (nameO == null || valueO == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String name = nameO.toString();
|
String name = nameO.toString();
|
||||||
|
|
||||||
if (name.equalsIgnoreCase("creator") || name.equalsIgnoreCase("author")
|
if (name.equalsIgnoreCase("creator") || name.equalsIgnoreCase("author")
|
||||||
|| name.equalsIgnoreCase("dc.creator"))
|
|| name.equalsIgnoreCase("dc.creator"))
|
||||||
{
|
{
|
||||||
trimPut(ContentModel.PROP_AUTHOR, valueO, tempDestination);
|
trimPut(ContentModel.PROP_AUTHOR, valueO, tempDestination);
|
||||||
}
|
}
|
||||||
if (name.equalsIgnoreCase("description") || name.equalsIgnoreCase("dc.description"))
|
if (name.equalsIgnoreCase("description") || name.equalsIgnoreCase("dc.description"))
|
||||||
{
|
{
|
||||||
trimPut(ContentModel.PROP_DESCRIPTION, valueO, tempDestination);
|
trimPut(ContentModel.PROP_DESCRIPTION, valueO, tempDestination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleError(String errorMsg, int pos)
|
public void handleError(String errorMsg, int pos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
String charsetGuess = "UTF-8";
|
String charsetGuess = "UTF-8";
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
while (tries < 3)
|
while (tries < 3)
|
||||||
{
|
{
|
||||||
tempDestination.clear();
|
tempDestination.clear();
|
||||||
Reader r = null;
|
Reader r = null;
|
||||||
InputStream cis = null;
|
InputStream cis = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cis = reader.getContentInputStream();
|
cis = reader.getContentInputStream();
|
||||||
// TODO: for now, use default charset; we should attempt to map from html meta-data
|
// TODO: for now, use default charset; we should attempt to map from html meta-data
|
||||||
r = new InputStreamReader(cis);
|
r = new InputStreamReader(cis);
|
||||||
HTMLEditorKit.Parser parser = new ParserDelegator();
|
HTMLEditorKit.Parser parser = new ParserDelegator();
|
||||||
parser.parse(r, callback, tries > 0);
|
parser.parse(r, callback, tries > 0);
|
||||||
destination.putAll(tempDestination);
|
destination.putAll(tempDestination);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (ChangedCharSetException ccse)
|
catch (ChangedCharSetException ccse)
|
||||||
{
|
{
|
||||||
tries++;
|
tries++;
|
||||||
charsetGuess = ccse.getCharSetSpec();
|
charsetGuess = ccse.getCharSetSpec();
|
||||||
int begin = charsetGuess.indexOf("charset=");
|
int begin = charsetGuess.indexOf("charset=");
|
||||||
if (begin > 0)
|
if (begin > 0)
|
||||||
charsetGuess = charsetGuess.substring(begin + 8, charsetGuess.length());
|
charsetGuess = charsetGuess.substring(begin + 8, charsetGuess.length());
|
||||||
reader = reader.getReader();
|
reader = reader.getReader();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (r != null)
|
if (r != null)
|
||||||
r.close();
|
r.close();
|
||||||
if (cis != null)
|
if (cis != null)
|
||||||
cis.close();
|
cis.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,57 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
public class HtmlMetadataExtracterTest extends AbstractMetadataExtracterTest
|
public class HtmlMetadataExtracterTest extends AbstractMetadataExtracterTest
|
||||||
{
|
{
|
||||||
private MetadataExtracter extracter;
|
private MetadataExtracter extracter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
extracter = new HtmlMetadataExtracter();
|
extracter = new HtmlMetadataExtracter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the same transformer regardless - it is allowed
|
* @return Returns the same transformer regardless - it is allowed
|
||||||
*/
|
*/
|
||||||
protected MetadataExtracter getExtracter()
|
protected MetadataExtracter getExtracter()
|
||||||
{
|
{
|
||||||
return extracter;
|
return extracter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReliability() throws Exception
|
public void testReliability() throws Exception
|
||||||
{
|
{
|
||||||
double reliability = 0.0;
|
double reliability = 0.0;
|
||||||
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
assertEquals("Mimetype text should not be supported", 0.0, reliability);
|
assertEquals("Mimetype text should not be supported", 0.0, reliability);
|
||||||
|
|
||||||
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_HTML);
|
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_HTML);
|
||||||
assertEquals("HTML should be supported", 1.0, reliability);
|
assertEquals("HTML should be supported", 1.0, reliability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHtmlExtraction() throws Exception
|
public void testHtmlExtraction() throws Exception
|
||||||
{
|
{
|
||||||
testExtractFromMimetype(MimetypeMap.MIMETYPE_HTML);
|
testExtractFromMimetype(MimetypeMap.MIMETYPE_HTML);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,72 +1,72 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
public interface MetadataExtracter
|
public interface MetadataExtracter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Provides the approximate accuracy with which this extracter can extract
|
* Provides the approximate accuracy with which this extracter can extract
|
||||||
* metadata for the mimetype.
|
* metadata for the mimetype.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param sourceMimetype the source mimetype
|
* @param sourceMimetype the source mimetype
|
||||||
* @return Returns a score 0.0 to 1.0. 0.0 indicates that the extraction
|
* @return Returns a score 0.0 to 1.0. 0.0 indicates that the extraction
|
||||||
* cannot be performed at all. 1.0 indicates that the extraction can
|
* cannot be performed at all. 1.0 indicates that the extraction can
|
||||||
* be performed perfectly.
|
* be performed perfectly.
|
||||||
*/
|
*/
|
||||||
public double getReliability(String sourceMimetype);
|
public double getReliability(String sourceMimetype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an estimate, usually a worst case guess, of how long an
|
* Provides an estimate, usually a worst case guess, of how long an
|
||||||
* extraction will take.
|
* extraction will take.
|
||||||
* <p>
|
* <p>
|
||||||
* This method is used to determine, up front, which of a set of equally
|
* This method is used to determine, up front, which of a set of equally
|
||||||
* reliant transformers will be used for a specific extraction.
|
* reliant transformers will be used for a specific extraction.
|
||||||
*
|
*
|
||||||
* @return Returns the approximate number of milliseconds per transformation
|
* @return Returns the approximate number of milliseconds per transformation
|
||||||
*/
|
*/
|
||||||
public long getExtractionTime();
|
public long getExtractionTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the metadata from the content provided by the reader and source
|
* Extracts the metadata from the content provided by the reader and source
|
||||||
* mimetype to the supplied map.
|
* mimetype to the supplied map.
|
||||||
* <p>
|
* <p>
|
||||||
* The extraction viability can be determined by an up front call to
|
* The extraction viability can be determined by an up front call to
|
||||||
* {@link #getReliability(String)}.
|
* {@link #getReliability(String)}.
|
||||||
* <p>
|
* <p>
|
||||||
* The source mimetype <b>must</b> be available on the
|
* The source mimetype <b>must</b> be available on the
|
||||||
* {@link org.alfresco.service.cmr.repository.ContentAccessor#getMimetype()} method
|
* {@link org.alfresco.service.cmr.repository.ContentAccessor#getMimetype()} method
|
||||||
* of the reader.
|
* of the reader.
|
||||||
*
|
*
|
||||||
* @param reader the source of the content
|
* @param reader the source of the content
|
||||||
* @param destination the destination of the extraction
|
* @param destination the destination of the extraction
|
||||||
* @throws ContentIOException if an IO exception occurs
|
* @throws ContentIOException if an IO exception occurs
|
||||||
*/
|
*/
|
||||||
public void extract(ContentReader reader, Map<QName, Serializable> destination) throws ContentIOException;
|
public void extract(ContentReader reader, Map<QName, Serializable> destination) throws ContentIOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,191 +1,172 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.apache.commons.logging.Log;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
/**
|
||||||
|
* Holds and provides the most appropriate metadate extracter for a particular
|
||||||
/**
|
* mimetype.
|
||||||
* Holds and provides the most appropriate metadate extracter for a particular
|
* <p>
|
||||||
* mimetype.
|
* The extracters themselves know how well they are able to extract metadata.
|
||||||
* <p>
|
*
|
||||||
* The extracters themselves know how well they are able to extract metadata.
|
* @see org.alfresco.repo.content.metadata.MetadataExtracter
|
||||||
*
|
* @author Jesper Steen Møller
|
||||||
* @see org.alfresco.repo.content.metadata.MetadataExtracter
|
*/
|
||||||
* @author Jesper Steen Møller
|
public class MetadataExtracterRegistry
|
||||||
*/
|
{
|
||||||
public class MetadataExtracterRegistry
|
private static final Log logger = LogFactory.getLog(MetadataExtracterRegistry.class);
|
||||||
{
|
|
||||||
private static final Log logger = LogFactory.getLog(MetadataExtracterRegistry.class);
|
private List<MetadataExtracter> extracters;
|
||||||
|
private Map<String, MetadataExtracter> extracterCache;
|
||||||
private List<MetadataExtracter> extracters;
|
|
||||||
private Map<String, MetadataExtracter> extracterCache;
|
/** Controls read access to the cache */
|
||||||
|
private Lock extracterCacheReadLock;
|
||||||
private MimetypeMap mimetypeMap;
|
/** controls write access to the cache */
|
||||||
/** Controls read access to the cache */
|
private Lock extracterCacheWriteLock;
|
||||||
private Lock extracterCacheReadLock;
|
|
||||||
/** controls write access to the cache */
|
public MetadataExtracterRegistry()
|
||||||
private Lock extracterCacheWriteLock;
|
{
|
||||||
|
// initialise lists
|
||||||
public MetadataExtracterRegistry()
|
extracters = new ArrayList<MetadataExtracter>(10);
|
||||||
{
|
extracterCache = new HashMap<String, MetadataExtracter>(17);
|
||||||
// initialise lists
|
|
||||||
extracters = new ArrayList<MetadataExtracter>(10);
|
// create lock objects for access to the cache
|
||||||
extracterCache = new HashMap<String, MetadataExtracter>(17);
|
ReadWriteLock extractionCacheLock = new ReentrantReadWriteLock();
|
||||||
|
extracterCacheReadLock = extractionCacheLock.readLock();
|
||||||
// create lock objects for access to the cache
|
extracterCacheWriteLock = extractionCacheLock.writeLock();
|
||||||
ReadWriteLock extractionCacheLock = new ReentrantReadWriteLock();
|
}
|
||||||
extracterCacheReadLock = extractionCacheLock.readLock();
|
|
||||||
extracterCacheWriteLock = extractionCacheLock.writeLock();
|
/**
|
||||||
}
|
* Register an instance of an extracter for use
|
||||||
|
*
|
||||||
/**
|
* @param extracter an extracter
|
||||||
* The mimetype map that will be used to check requests against
|
*/
|
||||||
*
|
public void register(MetadataExtracter extracter)
|
||||||
* @param mimetypeMap a map of mimetypes
|
{
|
||||||
*/
|
if (logger.isDebugEnabled())
|
||||||
public void setMimetypeMap(MimetypeMap mimetypeMap)
|
{
|
||||||
{
|
logger.debug("Registering metadata extracter: " + extracter);
|
||||||
this.mimetypeMap = mimetypeMap;
|
}
|
||||||
}
|
|
||||||
|
extracterCacheWriteLock.lock();
|
||||||
/**
|
try
|
||||||
* Register an instance of an extracter for use
|
{
|
||||||
*
|
extracters.add(extracter);
|
||||||
* @param extracter an extracter
|
extracterCache.clear();
|
||||||
*/
|
}
|
||||||
public void register(MetadataExtracter extracter)
|
finally
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
extracterCacheWriteLock.unlock();
|
||||||
{
|
}
|
||||||
logger.debug("Registering metadata extracter: " + extracter);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
extracterCacheWriteLock.lock();
|
* Gets the best metadata extracter. This is a combination of the most
|
||||||
try
|
* reliable and the most performant extracter.
|
||||||
{
|
* <p>
|
||||||
extracters.add(extracter);
|
* The result is cached for quicker access next time.
|
||||||
extracterCache.clear();
|
*
|
||||||
}
|
* @param mimetype the source MIME of the extraction
|
||||||
finally
|
* @return Returns a metadata extracter that can extract metadata from the
|
||||||
{
|
* chosen MIME type.
|
||||||
extracterCacheWriteLock.unlock();
|
*/
|
||||||
}
|
public MetadataExtracter getExtracter(String sourceMimetype)
|
||||||
}
|
{
|
||||||
|
MetadataExtracter extracter = null;
|
||||||
/**
|
extracterCacheReadLock.lock();
|
||||||
* Gets the best metadata extracter. This is a combination of the most
|
try
|
||||||
* reliable and the most performant extracter.
|
{
|
||||||
* <p>
|
if (extracterCache.containsKey(sourceMimetype))
|
||||||
* The result is cached for quicker access next time.
|
{
|
||||||
*
|
// the translation has been requested before
|
||||||
* @param mimetype the source MIME of the extraction
|
// it might have been null
|
||||||
* @return Returns a metadata extracter that can extract metadata from the
|
return extracterCache.get(sourceMimetype);
|
||||||
* chosen MIME type.
|
}
|
||||||
*/
|
}
|
||||||
public MetadataExtracter getExtracter(String sourceMimetype)
|
finally
|
||||||
{
|
{
|
||||||
// check that the mimetypes are valid
|
extracterCacheReadLock.unlock();
|
||||||
if (!mimetypeMap.getMimetypes().contains(sourceMimetype))
|
}
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Unknown extraction source mimetype: " + sourceMimetype);
|
// the translation has not been requested before
|
||||||
}
|
// get a write lock on the cache
|
||||||
|
// no double check done as it is not an expensive task
|
||||||
MetadataExtracter extracter = null;
|
extracterCacheWriteLock.lock();
|
||||||
extracterCacheReadLock.lock();
|
try
|
||||||
try
|
{
|
||||||
{
|
// find the most suitable transformer - may be empty list
|
||||||
if (extracterCache.containsKey(sourceMimetype))
|
extracter = findBestExtracter(sourceMimetype);
|
||||||
{
|
// store the result even if it is null
|
||||||
// the translation has been requested before
|
extracterCache.put(sourceMimetype, extracter);
|
||||||
// it might have been null
|
return extracter;
|
||||||
return extracterCache.get(sourceMimetype);
|
}
|
||||||
}
|
finally
|
||||||
}
|
{
|
||||||
finally
|
extracterCacheWriteLock.unlock();
|
||||||
{
|
}
|
||||||
extracterCacheReadLock.unlock();
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
// the translation has not been requested before
|
* @param sourceMimetype The MIME type under examination
|
||||||
// get a write lock on the cache
|
* @return The fastest of the most reliable extracters in <code>extracters</code>
|
||||||
// no double check done as it is not an expensive task
|
* for the given MIME type, or null if none is available.
|
||||||
extracterCacheWriteLock.lock();
|
*/
|
||||||
try
|
private MetadataExtracter findBestExtracter(String sourceMimetype)
|
||||||
{
|
{
|
||||||
// find the most suitable transformer - may be empty list
|
double bestReliability = -1;
|
||||||
extracter = findBestExtracter(sourceMimetype);
|
long bestTime = Long.MAX_VALUE;
|
||||||
// store the result even if it is null
|
logger.debug("Finding best extracter for " + sourceMimetype);
|
||||||
extracterCache.put(sourceMimetype, extracter);
|
|
||||||
return extracter;
|
MetadataExtracter bestExtracter = null;
|
||||||
}
|
|
||||||
finally
|
for (MetadataExtracter ext : extracters)
|
||||||
{
|
{
|
||||||
extracterCacheWriteLock.unlock();
|
double r = ext.getReliability(sourceMimetype);
|
||||||
}
|
if (r <= 0.0)
|
||||||
}
|
{
|
||||||
|
// extraction not achievable
|
||||||
/**
|
continue;
|
||||||
* @param sourceMimetype The MIME type under examination
|
}
|
||||||
* @return The fastest of the most reliable extracters in <code>extracters</code>
|
else if (r == bestReliability)
|
||||||
* for the given MIME type, or null if none is available.
|
{
|
||||||
*/
|
long time = ext.getExtractionTime();
|
||||||
private MetadataExtracter findBestExtracter(String sourceMimetype)
|
if (time < bestTime)
|
||||||
{
|
{
|
||||||
double bestReliability = -1;
|
bestExtracter = ext;
|
||||||
long bestTime = Long.MAX_VALUE;
|
bestTime = time;
|
||||||
logger.debug("Finding best extracter for " + sourceMimetype);
|
}
|
||||||
|
}
|
||||||
MetadataExtracter bestExtracter = null;
|
else if (r > bestReliability)
|
||||||
|
{
|
||||||
for (MetadataExtracter ext : extracters)
|
bestExtracter = ext;
|
||||||
{
|
bestReliability = r;
|
||||||
double r = ext.getReliability(sourceMimetype);
|
bestTime = ext.getExtractionTime();
|
||||||
if (r <= 0.0)
|
}
|
||||||
{
|
}
|
||||||
// extraction not achievable
|
return bestExtracter;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
else if (r == bestReliability)
|
|
||||||
{
|
|
||||||
long time = ext.getExtractionTime();
|
|
||||||
if (time < bestTime)
|
|
||||||
{
|
|
||||||
bestExtracter = ext;
|
|
||||||
bestTime = time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (r > bestReliability)
|
|
||||||
{
|
|
||||||
bestExtracter = ext;
|
|
||||||
bestReliability = r;
|
|
||||||
bestTime = ext.getExtractionTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bestExtracter;
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -1,101 +1,101 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.apache.poi.hpsf.PropertySet;
|
import org.apache.poi.hpsf.PropertySet;
|
||||||
import org.apache.poi.hpsf.PropertySetFactory;
|
import org.apache.poi.hpsf.PropertySetFactory;
|
||||||
import org.apache.poi.hpsf.SummaryInformation;
|
import org.apache.poi.hpsf.SummaryInformation;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Office file format Metadata Extracter
|
* Office file format Metadata Extracter
|
||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
public class OfficeMetadataExtracter extends AbstractMetadataExtracter
|
public class OfficeMetadataExtracter extends AbstractMetadataExtracter
|
||||||
{
|
{
|
||||||
public static String[] SUPPORTED_MIMETYPES = new String[] {
|
public static String[] SUPPORTED_MIMETYPES = new String[] {
|
||||||
MimetypeMap.MIMETYPE_WORD,
|
MimetypeMap.MIMETYPE_WORD,
|
||||||
MimetypeMap.MIMETYPE_EXCEL,
|
MimetypeMap.MIMETYPE_EXCEL,
|
||||||
MimetypeMap.MIMETYPE_PPT};
|
MimetypeMap.MIMETYPE_PPT};
|
||||||
|
|
||||||
public OfficeMetadataExtracter()
|
public OfficeMetadataExtracter()
|
||||||
{
|
{
|
||||||
super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)), 1.0, 1000);
|
super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)), 1.0, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extractInternal(ContentReader reader, final Map<QName, Serializable> destination) throws Throwable
|
public void extractInternal(ContentReader reader, final Map<QName, Serializable> destination) throws Throwable
|
||||||
{
|
{
|
||||||
POIFSReaderListener readerListener = new POIFSReaderListener()
|
POIFSReaderListener readerListener = new POIFSReaderListener()
|
||||||
{
|
{
|
||||||
public void processPOIFSReaderEvent(final POIFSReaderEvent event)
|
public void processPOIFSReaderEvent(final POIFSReaderEvent event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PropertySet ps = PropertySetFactory.create(event.getStream());
|
PropertySet ps = PropertySetFactory.create(event.getStream());
|
||||||
if (ps instanceof SummaryInformation)
|
if (ps instanceof SummaryInformation)
|
||||||
{
|
{
|
||||||
SummaryInformation si = (SummaryInformation) ps;
|
SummaryInformation si = (SummaryInformation) ps;
|
||||||
|
|
||||||
// Titled aspect
|
// Titled aspect
|
||||||
trimPut(ContentModel.PROP_TITLE, si.getTitle(), destination);
|
trimPut(ContentModel.PROP_TITLE, si.getTitle(), destination);
|
||||||
trimPut(ContentModel.PROP_DESCRIPTION, si.getSubject(), destination);
|
trimPut(ContentModel.PROP_DESCRIPTION, si.getSubject(), destination);
|
||||||
|
|
||||||
// Auditable aspect
|
// Auditable aspect
|
||||||
trimPut(ContentModel.PROP_CREATED, si.getCreateDateTime(), destination);
|
trimPut(ContentModel.PROP_CREATED, si.getCreateDateTime(), destination);
|
||||||
trimPut(ContentModel.PROP_MODIFIED, si.getLastSaveDateTime(), destination);
|
trimPut(ContentModel.PROP_MODIFIED, si.getLastSaveDateTime(), destination);
|
||||||
trimPut(ContentModel.PROP_AUTHOR, si.getAuthor(), destination);
|
trimPut(ContentModel.PROP_AUTHOR, si.getAuthor(), destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new ContentIOException("Property set stream: " + event.getPath() + event.getName(), ex);
|
throw new ContentIOException("Property set stream: " + event.getPath() + event.getName(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
is = reader.getContentInputStream();
|
is = reader.getContentInputStream();
|
||||||
POIFSReader poiFSReader = new POIFSReader();
|
POIFSReader poiFSReader = new POIFSReader();
|
||||||
poiFSReader.registerListener(readerListener, SummaryInformation.DEFAULT_STREAM_NAME);
|
poiFSReader.registerListener(readerListener, SummaryInformation.DEFAULT_STREAM_NAME);
|
||||||
poiFSReader.read(is);
|
poiFSReader.read(is);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (is != null)
|
if (is != null)
|
||||||
{
|
{
|
||||||
try { is.close(); } catch (IOException e) {}
|
try { is.close(); } catch (IOException e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,75 +1,75 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Jesper Steen Møller
|
* Copyright (C) 2005 Jesper Steen Møller
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
* copy of the License at
|
* copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.alfresco.org/legal/license.txt
|
* http://www.alfresco.org/legal/license.txt
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
* either express or implied. See the License for the specific
|
* either express or implied. See the License for the specific
|
||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.pdfbox.pdmodel.PDDocument;
|
import org.pdfbox.pdmodel.PDDocument;
|
||||||
import org.pdfbox.pdmodel.PDDocumentInformation;
|
import org.pdfbox.pdmodel.PDDocumentInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
public class PdfBoxMetadataExtracter extends AbstractMetadataExtracter
|
public class PdfBoxMetadataExtracter extends AbstractMetadataExtracter
|
||||||
{
|
{
|
||||||
public PdfBoxMetadataExtracter()
|
public PdfBoxMetadataExtracter()
|
||||||
{
|
{
|
||||||
super(MimetypeMap.MIMETYPE_PDF, 1.0, 1000);
|
super(MimetypeMap.MIMETYPE_PDF, 1.0, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extractInternal(ContentReader reader, Map<QName, Serializable> destination) throws Throwable
|
public void extractInternal(ContentReader reader, Map<QName, Serializable> destination) throws Throwable
|
||||||
{
|
{
|
||||||
PDDocument pdf = null;
|
PDDocument pdf = null;
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
is = reader.getContentInputStream();
|
is = reader.getContentInputStream();
|
||||||
// stream the document in
|
// stream the document in
|
||||||
pdf = PDDocument.load(is);
|
pdf = PDDocument.load(is);
|
||||||
// Scoop out the metadata
|
// Scoop out the metadata
|
||||||
PDDocumentInformation docInfo = pdf.getDocumentInformation();
|
PDDocumentInformation docInfo = pdf.getDocumentInformation();
|
||||||
|
|
||||||
trimPut(ContentModel.PROP_AUTHOR, docInfo.getAuthor(), destination);
|
trimPut(ContentModel.PROP_AUTHOR, docInfo.getAuthor(), destination);
|
||||||
trimPut(ContentModel.PROP_TITLE, docInfo.getTitle(), destination);
|
trimPut(ContentModel.PROP_TITLE, docInfo.getTitle(), destination);
|
||||||
trimPut(ContentModel.PROP_DESCRIPTION, docInfo.getSubject(), destination);
|
trimPut(ContentModel.PROP_DESCRIPTION, docInfo.getSubject(), destination);
|
||||||
|
|
||||||
Calendar created = docInfo.getCreationDate();
|
Calendar created = docInfo.getCreationDate();
|
||||||
if (created != null)
|
if (created != null)
|
||||||
destination.put(ContentModel.PROP_CREATED, created.getTime());
|
destination.put(ContentModel.PROP_CREATED, created.getTime());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (is != null)
|
if (is != null)
|
||||||
{
|
{
|
||||||
try { is.close(); } catch (IOException e) {}
|
try { is.close(); } catch (IOException e) {}
|
||||||
}
|
}
|
||||||
if (pdf != null)
|
if (pdf != null)
|
||||||
{
|
{
|
||||||
try { pdf.close(); } catch (Throwable e) { e.printStackTrace(); }
|
try { pdf.close(); } catch (Throwable e) { e.printStackTrace(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,43 +1,43 @@
|
|||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.content.metadata.PdfBoxMetadataExtracter
|
* @see org.alfresco.repo.content.metadata.PdfBoxMetadataExtracter
|
||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @author Jesper Steen Møller
|
||||||
*/
|
*/
|
||||||
public class PdfBoxMetadataExtracterTest extends AbstractMetadataExtracterTest
|
public class PdfBoxMetadataExtracterTest extends AbstractMetadataExtracterTest
|
||||||
{
|
{
|
||||||
private MetadataExtracter extracter;
|
private MetadataExtracter extracter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
extracter = new PdfBoxMetadataExtracter();
|
extracter = new PdfBoxMetadataExtracter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the same transformer regardless - it is allowed
|
* @return Returns the same transformer regardless - it is allowed
|
||||||
*/
|
*/
|
||||||
protected MetadataExtracter getExtracter()
|
protected MetadataExtracter getExtracter()
|
||||||
{
|
{
|
||||||
return extracter;
|
return extracter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReliability() throws Exception
|
public void testReliability() throws Exception
|
||||||
{
|
{
|
||||||
double reliability = 0.0;
|
double reliability = 0.0;
|
||||||
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
assertEquals("Mimetype should not be supported", 0.0, reliability);
|
assertEquals("Mimetype should not be supported", 0.0, reliability);
|
||||||
|
|
||||||
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_PDF);
|
reliability = extracter.getReliability(MimetypeMap.MIMETYPE_PDF);
|
||||||
assertEquals("Mimetype should be supported", 1.0, reliability);
|
assertEquals("Mimetype should be supported", 1.0, reliability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPdfExtraction() throws Exception
|
public void testPdfExtraction() throws Exception
|
||||||
{
|
{
|
||||||
testExtractFromMimetype(MimetypeMap.MIMETYPE_PDF);
|
testExtractFromMimetype(MimetypeMap.MIMETYPE_PDF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -252,13 +252,13 @@ public abstract class AbstractContentTransformer implements ContentTransformer
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// check that the reader and writer are both closed
|
// check that the reader and writer are both closed
|
||||||
if (!reader.isClosed())
|
if (reader.isChannelOpen())
|
||||||
{
|
{
|
||||||
logger.error("Content reader not closed by transformer: \n" +
|
logger.error("Content reader not closed by transformer: \n" +
|
||||||
" reader: " + reader + "\n" +
|
" reader: " + reader + "\n" +
|
||||||
" transformer: " + this);
|
" transformer: " + this);
|
||||||
}
|
}
|
||||||
if (!writer.isClosed())
|
if (writer.isChannelOpen())
|
||||||
{
|
{
|
||||||
logger.error("Content writer not closed by transformer: \n" +
|
logger.error("Content writer not closed by transformer: \n" +
|
||||||
" writer: " + writer + "\n" +
|
" writer: " + writer + "\n" +
|
||||||
|
@@ -25,11 +25,8 @@ import java.util.concurrent.locks.Lock;
|
|||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds and provides the most appropriate content transformer for
|
* Holds and provides the most appropriate content transformer for
|
||||||
@@ -47,7 +44,6 @@ public class ContentTransformerRegistry
|
|||||||
private static final Log logger = LogFactory.getLog(ContentTransformerRegistry.class);
|
private static final Log logger = LogFactory.getLog(ContentTransformerRegistry.class);
|
||||||
|
|
||||||
private List<ContentTransformer> transformers;
|
private List<ContentTransformer> transformers;
|
||||||
private MimetypeMap mimetypeMap;
|
|
||||||
/** Cache of previously used transactions */
|
/** Cache of previously used transactions */
|
||||||
private Map<TransformationKey, List<ContentTransformer>> transformationCache;
|
private Map<TransformationKey, List<ContentTransformer>> transformationCache;
|
||||||
/** Controls read access to the transformation cache */
|
/** Controls read access to the transformation cache */
|
||||||
@@ -58,11 +54,8 @@ public class ContentTransformerRegistry
|
|||||||
/**
|
/**
|
||||||
* @param mimetypeMap all the mimetypes available to the system
|
* @param mimetypeMap all the mimetypes available to the system
|
||||||
*/
|
*/
|
||||||
public ContentTransformerRegistry(MimetypeMap mimetypeMap)
|
public ContentTransformerRegistry()
|
||||||
{
|
{
|
||||||
Assert.notNull(mimetypeMap, "The MimetypeMap is mandatory");
|
|
||||||
this.mimetypeMap = mimetypeMap;
|
|
||||||
|
|
||||||
this.transformers = new ArrayList<ContentTransformer>(10);
|
this.transformers = new ArrayList<ContentTransformer>(10);
|
||||||
transformationCache = new HashMap<TransformationKey, List<ContentTransformer>>(17);
|
transformationCache = new HashMap<TransformationKey, List<ContentTransformer>>(17);
|
||||||
|
|
||||||
@@ -143,16 +136,6 @@ public class ContentTransformerRegistry
|
|||||||
*/
|
*/
|
||||||
public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype)
|
public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype)
|
||||||
{
|
{
|
||||||
// check that the mimetypes are valid
|
|
||||||
if (!mimetypeMap.getMimetypes().contains(sourceMimetype))
|
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Unknown source mimetype: " + sourceMimetype);
|
|
||||||
}
|
|
||||||
if (!mimetypeMap.getMimetypes().contains(targetMimetype))
|
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Unknown target mimetype: " + targetMimetype);
|
|
||||||
}
|
|
||||||
|
|
||||||
TransformationKey key = new TransformationKey(sourceMimetype, targetMimetype);
|
TransformationKey key = new TransformationKey(sourceMimetype, targetMimetype);
|
||||||
List<ContentTransformer> transformers = null;
|
List<ContentTransformer> transformers = null;
|
||||||
transformationCacheReadLock.lock();
|
transformationCacheReadLock.lock();
|
||||||
|
@@ -69,7 +69,7 @@ public class ContentTransformerRegistryTest extends AbstractContentTransformerTe
|
|||||||
bytes[i] = (byte)i;
|
bytes[i] = (byte)i;
|
||||||
}
|
}
|
||||||
// create the dummyRegistry
|
// create the dummyRegistry
|
||||||
dummyRegistry = new ContentTransformerRegistry(mimetypeMap);
|
dummyRegistry = new ContentTransformerRegistry();
|
||||||
// create some dummy transformers for reliability tests
|
// create some dummy transformers for reliability tests
|
||||||
new DummyTransformer(mimetypeMap, dummyRegistry, A, B, 0.3, 10L);
|
new DummyTransformer(mimetypeMap, dummyRegistry, A, B, 0.3, 10L);
|
||||||
new DummyTransformer(mimetypeMap, dummyRegistry, A, B, 0.6, 10L);
|
new DummyTransformer(mimetypeMap, dummyRegistry, A, B, 0.6, 10L);
|
||||||
|
@@ -536,7 +536,13 @@ public class CopyServiceImpl implements CopyService
|
|||||||
ClassDefinition classDefinition = this.dictionaryService.getClass(classRef);
|
ClassDefinition classDefinition = this.dictionaryService.getClass(classRef);
|
||||||
if (classDefinition != null)
|
if (classDefinition != null)
|
||||||
{
|
{
|
||||||
// Copy the properties
|
if (classDefinition.isAspect() == true)
|
||||||
|
{
|
||||||
|
// make sure any aspects without any properties or associations are copied
|
||||||
|
copyDetails.addAspect(classRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the properties
|
||||||
Map<QName,PropertyDefinition> propertyDefinitions = classDefinition.getProperties();
|
Map<QName,PropertyDefinition> propertyDefinitions = classDefinition.getProperties();
|
||||||
for (QName propertyName : propertyDefinitions.keySet())
|
for (QName propertyName : propertyDefinitions.keySet())
|
||||||
{
|
{
|
||||||
|
@@ -18,7 +18,9 @@ package org.alfresco.repo.dictionary;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
@@ -52,8 +54,8 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
// Namespace Data Access
|
// Namespace Data Access
|
||||||
private NamespaceDAO namespaceDAO;
|
private NamespaceDAO namespaceDAO;
|
||||||
|
|
||||||
// Map of namespace to model name
|
// Map of Namespace URI usages to Models
|
||||||
private Map<String,QName> namespaceToModel = new HashMap<String,QName>();
|
private Map<String, List<CompiledModel>> uriToModels = new HashMap<String, List<CompiledModel>>();
|
||||||
|
|
||||||
// Map of model name to compiled model
|
// Map of model name to compiled model
|
||||||
private Map<QName,CompiledModel> compiledModels = new HashMap<QName,CompiledModel>();
|
private Map<QName,CompiledModel> compiledModels = new HashMap<QName,CompiledModel>();
|
||||||
@@ -90,7 +92,11 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
{
|
{
|
||||||
namespaceDAO.removePrefix(namespace.getPrefix());
|
namespaceDAO.removePrefix(namespace.getPrefix());
|
||||||
namespaceDAO.removeURI(namespace.getUri());
|
namespaceDAO.removeURI(namespace.getUri());
|
||||||
namespaceToModel.remove(namespace.getUri());
|
unmapUriToModel(namespace.getUri(), previousVersion);
|
||||||
|
}
|
||||||
|
for (M2Namespace importNamespace : previousVersion.getM2Model().getImports())
|
||||||
|
{
|
||||||
|
unmapUriToModel(importNamespace.getUri(), previousVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +105,11 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
{
|
{
|
||||||
namespaceDAO.addURI(namespace.getUri());
|
namespaceDAO.addURI(namespace.getUri());
|
||||||
namespaceDAO.addPrefix(namespace.getPrefix(), namespace.getUri());
|
namespaceDAO.addPrefix(namespace.getPrefix(), namespace.getUri());
|
||||||
namespaceToModel.put(namespace.getUri(), modelName);
|
mapUriToModel(namespace.getUri(), compiledModel);
|
||||||
|
}
|
||||||
|
for (M2Namespace importNamespace : model.getImports())
|
||||||
|
{
|
||||||
|
mapUriToModel(importNamespace.getUri(), compiledModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish new Model Definition
|
// Publish new Model Definition
|
||||||
@@ -115,6 +125,7 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.dictionary.DictionaryDAO#removeModel(org.alfresco.service.namespace.QName)
|
* @see org.alfresco.repo.dictionary.DictionaryDAO#removeModel(org.alfresco.service.namespace.QName)
|
||||||
*/
|
*/
|
||||||
@@ -129,7 +140,7 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
{
|
{
|
||||||
namespaceDAO.removePrefix(namespace.getPrefix());
|
namespaceDAO.removePrefix(namespace.getPrefix());
|
||||||
namespaceDAO.removeURI(namespace.getUri());
|
namespaceDAO.removeURI(namespace.getUri());
|
||||||
namespaceToModel.remove(namespace.getUri());
|
unmapUriToModel(namespace.getUri(), compiledModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the model from the list
|
// Remove the model from the list
|
||||||
@@ -137,18 +148,61 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map Namespace URI to Model
|
||||||
|
*
|
||||||
|
* @param uri namespace uri
|
||||||
|
* @param model model
|
||||||
|
*/
|
||||||
|
private void mapUriToModel(String uri, CompiledModel model)
|
||||||
|
{
|
||||||
|
List<CompiledModel> models = uriToModels.get(uri);
|
||||||
|
if (models == null)
|
||||||
|
{
|
||||||
|
models = new ArrayList<CompiledModel>();
|
||||||
|
uriToModels.put(uri, models);
|
||||||
|
}
|
||||||
|
if (!models.contains(model))
|
||||||
|
{
|
||||||
|
models.add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uri the namespace uri
|
* Unmap Namespace URI from Model
|
||||||
* @return the compiled model which defines the specified namespace
|
*
|
||||||
|
* @param uri namespace uri
|
||||||
|
* @param model model
|
||||||
*/
|
*/
|
||||||
private CompiledModel getCompiledModelForNamespace(String uri)
|
private void unmapUriToModel(String uri, CompiledModel model)
|
||||||
{
|
{
|
||||||
QName modelName = namespaceToModel.get(uri);
|
List<CompiledModel> models = uriToModels.get(uri);
|
||||||
return (modelName == null) ? null : getCompiledModel(modelName);
|
if (models != null)
|
||||||
|
{
|
||||||
|
models.remove(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Models mapped to Namespace Uri
|
||||||
|
*
|
||||||
|
* @param uri namespace uri
|
||||||
|
* @return mapped models
|
||||||
|
*/
|
||||||
|
private List<CompiledModel> getModelsForUri(String uri)
|
||||||
|
{
|
||||||
|
List<CompiledModel> models = uriToModels.get(uri);
|
||||||
|
if (models == null)
|
||||||
|
{
|
||||||
|
models = Collections.emptyList();
|
||||||
|
}
|
||||||
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param modelName the model name
|
* @param modelName the model name
|
||||||
* @return the compiled model of the given name
|
* @return the compiled model of the given name
|
||||||
@@ -170,8 +224,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
*/
|
*/
|
||||||
public DataTypeDefinition getDataType(QName typeName)
|
public DataTypeDefinition getDataType(QName typeName)
|
||||||
{
|
{
|
||||||
CompiledModel model = getCompiledModelForNamespace(typeName.getNamespaceURI());
|
List<CompiledModel> models = getModelsForUri(typeName.getNamespaceURI());
|
||||||
return (model == null) ? null : model.getDataType(typeName);
|
for (CompiledModel model : models)
|
||||||
|
{
|
||||||
|
DataTypeDefinition dataType = model.getDataType(typeName);
|
||||||
|
if (dataType != null)
|
||||||
|
{
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -207,8 +269,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
*/
|
*/
|
||||||
public TypeDefinition getType(QName typeName)
|
public TypeDefinition getType(QName typeName)
|
||||||
{
|
{
|
||||||
CompiledModel model = getCompiledModelForNamespace(typeName.getNamespaceURI());
|
List<CompiledModel> models = getModelsForUri(typeName.getNamespaceURI());
|
||||||
return (model == null) ? null : model.getType(typeName);
|
for (CompiledModel model : models)
|
||||||
|
{
|
||||||
|
TypeDefinition type = model.getType(typeName);
|
||||||
|
if (type != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,8 +287,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
*/
|
*/
|
||||||
public AspectDefinition getAspect(QName aspectName)
|
public AspectDefinition getAspect(QName aspectName)
|
||||||
{
|
{
|
||||||
CompiledModel model = getCompiledModelForNamespace(aspectName.getNamespaceURI());
|
List<CompiledModel> models = getModelsForUri(aspectName.getNamespaceURI());
|
||||||
return (model == null) ? null : model.getAspect(aspectName);
|
for (CompiledModel model : models)
|
||||||
|
{
|
||||||
|
AspectDefinition aspect = model.getAspect(aspectName);
|
||||||
|
if (aspect != null)
|
||||||
|
{
|
||||||
|
return aspect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -227,8 +305,16 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
*/
|
*/
|
||||||
public ClassDefinition getClass(QName className)
|
public ClassDefinition getClass(QName className)
|
||||||
{
|
{
|
||||||
CompiledModel model = getCompiledModelForNamespace(className.getNamespaceURI());
|
List<CompiledModel> models = getModelsForUri(className.getNamespaceURI());
|
||||||
return (model == null) ? null : model.getClass(className);
|
for (CompiledModel model : models)
|
||||||
|
{
|
||||||
|
ClassDefinition classDef = model.getClass(className);
|
||||||
|
if (classDef != null)
|
||||||
|
{
|
||||||
|
return classDef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -237,23 +323,52 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
*/
|
*/
|
||||||
public PropertyDefinition getProperty(QName propertyName)
|
public PropertyDefinition getProperty(QName propertyName)
|
||||||
{
|
{
|
||||||
CompiledModel model = getCompiledModelForNamespace(propertyName.getNamespaceURI());
|
List<CompiledModel> models = getModelsForUri(propertyName.getNamespaceURI());
|
||||||
return (model == null) ? null : model.getProperty(propertyName);
|
for (CompiledModel model : models)
|
||||||
|
{
|
||||||
|
PropertyDefinition propDef = model.getProperty(propertyName);
|
||||||
|
if (propDef != null)
|
||||||
|
{
|
||||||
|
return propDef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.dictionary.ModelQuery#getConstraint(org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
public ConstraintDefinition getConstraint(QName constraintQName)
|
public ConstraintDefinition getConstraint(QName constraintQName)
|
||||||
{
|
{
|
||||||
CompiledModel model = getCompiledModelForNamespace(constraintQName.getNamespaceURI());
|
List<CompiledModel> models = getModelsForUri(constraintQName.getNamespaceURI());
|
||||||
return (model == null) ? null : model.getConstraint(constraintQName);
|
for (CompiledModel model : models)
|
||||||
|
{
|
||||||
|
ConstraintDefinition constraintDef = model.getConstraint(constraintQName);
|
||||||
|
if (constraintDef != null)
|
||||||
|
{
|
||||||
|
return constraintDef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.impl.ModelQuery#getAssociation(org.alfresco.repo.ref.QName)
|
* @see org.alfresco.repo.dictionary.impl.ModelQuery#getAssociation(org.alfresco.repo.ref.QName)
|
||||||
*/
|
*/
|
||||||
public AssociationDefinition getAssociation(QName assocName)
|
public AssociationDefinition getAssociation(QName assocName)
|
||||||
{
|
{
|
||||||
CompiledModel model = getCompiledModelForNamespace(assocName.getNamespaceURI());
|
List<CompiledModel> models = getModelsForUri(assocName.getNamespaceURI());
|
||||||
return (model == null) ? null : model.getAssociation(assocName);
|
for (CompiledModel model : models)
|
||||||
|
{
|
||||||
|
AssociationDefinition assocDef = model.getAssociation(assocName);
|
||||||
|
if (assocDef != null)
|
||||||
|
{
|
||||||
|
return assocDef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -36,7 +36,6 @@ import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
|||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
|
||||||
|
|
||||||
|
|
||||||
public class DictionaryDAOTest extends TestCase
|
public class DictionaryDAOTest extends TestCase
|
||||||
@@ -186,6 +185,15 @@ public class DictionaryDAOTest extends TestCase
|
|||||||
ClassDefinition fileClassDef = service.getClass(testFileQName);
|
ClassDefinition fileClassDef = service.getClass(testFileQName);
|
||||||
assertTrue("File type should have the archive flag", fileClassDef.isArchive());
|
assertTrue("File type should have the archive flag", fileClassDef.isArchive());
|
||||||
|
|
||||||
|
QName testFileDerivedQName = QName.createQName(TEST_URL, "file-derived");
|
||||||
|
ClassDefinition fileDerivedClassDef = service.getClass(testFileDerivedQName);
|
||||||
|
assertTrue("Direct derived File type should have the archive flag", fileDerivedClassDef.isArchive());
|
||||||
|
|
||||||
|
QName testFileDerivedNoArchiveQName = QName.createQName(TEST_URL, "file-derived-no-archive");
|
||||||
|
ClassDefinition fileDerivedNoArchiveClassDef = service.getClass(testFileDerivedNoArchiveQName);
|
||||||
|
assertFalse("Derived File with archive override type should NOT have the archive flag",
|
||||||
|
fileDerivedNoArchiveClassDef.isArchive());
|
||||||
|
|
||||||
QName testFolderQName = QName.createQName(TEST_URL, "folder");
|
QName testFolderQName = QName.createQName(TEST_URL, "folder");
|
||||||
ClassDefinition folderClassDef = service.getClass(testFolderQName);
|
ClassDefinition folderClassDef = service.getClass(testFolderQName);
|
||||||
assertFalse("Folder type should not have the archive flag", folderClassDef.isArchive());
|
assertFalse("Folder type should not have the archive flag", folderClassDef.isArchive());
|
||||||
|
@@ -32,7 +32,7 @@ public abstract class M2Class
|
|||||||
private String title = null;
|
private String title = null;
|
||||||
private String description = null;
|
private String description = null;
|
||||||
private String parentName = null;
|
private String parentName = null;
|
||||||
private boolean archive = false;
|
private Boolean archive = null;
|
||||||
|
|
||||||
private List<M2Property> properties = new ArrayList<M2Property>();
|
private List<M2Property> properties = new ArrayList<M2Property>();
|
||||||
private List<M2PropertyOverride> propertyOverrides = new ArrayList<M2PropertyOverride>();
|
private List<M2PropertyOverride> propertyOverrides = new ArrayList<M2PropertyOverride>();
|
||||||
@@ -92,14 +92,14 @@ public abstract class M2Class
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isArchive()
|
public Boolean getArchive()
|
||||||
{
|
{
|
||||||
return archive;
|
return archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArchive(boolean archive)
|
public void setArchive(boolean archive)
|
||||||
{
|
{
|
||||||
this.archive = archive;
|
this.archive = Boolean.valueOf(archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public M2Property createProperty(String name)
|
public M2Property createProperty(String name)
|
||||||
|
@@ -46,7 +46,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
protected M2Class m2Class;
|
protected M2Class m2Class;
|
||||||
protected QName name;
|
protected QName name;
|
||||||
protected QName parentName = null;
|
protected QName parentName = null;
|
||||||
protected boolean archive = false;
|
|
||||||
|
|
||||||
private Map<QName, M2PropertyOverride> propertyOverrides = new HashMap<QName, M2PropertyOverride>();
|
private Map<QName, M2PropertyOverride> propertyOverrides = new HashMap<QName, M2PropertyOverride>();
|
||||||
private Map<QName, PropertyDefinition> properties = new HashMap<QName, PropertyDefinition>();
|
private Map<QName, PropertyDefinition> properties = new HashMap<QName, PropertyDefinition>();
|
||||||
@@ -57,8 +56,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
private List<AspectDefinition> defaultAspects = new ArrayList<AspectDefinition>();
|
private List<AspectDefinition> defaultAspects = new ArrayList<AspectDefinition>();
|
||||||
private List<QName> defaultAspectNames = new ArrayList<QName>();
|
private List<QName> defaultAspectNames = new ArrayList<QName>();
|
||||||
private List<AspectDefinition> inheritedDefaultAspects = new ArrayList<AspectDefinition>();
|
private List<AspectDefinition> inheritedDefaultAspects = new ArrayList<AspectDefinition>();
|
||||||
|
private Boolean archive = null;
|
||||||
|
private Boolean inheritedArchive = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
*
|
*
|
||||||
@@ -74,7 +74,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
// Resolve Names
|
// Resolve Names
|
||||||
this.name = QName.createQName(m2Class.getName(), resolver);
|
this.name = QName.createQName(m2Class.getName(), resolver);
|
||||||
this.archive = m2Class.isArchive();
|
this.archive = m2Class.getArchive();
|
||||||
if (m2Class.getParentName() != null && m2Class.getParentName().length() > 0)
|
if (m2Class.getParentName() != null && m2Class.getParentName().length() > 0)
|
||||||
{
|
{
|
||||||
this.parentName = QName.createQName(m2Class.getParentName(), resolver);
|
this.parentName = QName.createQName(m2Class.getParentName(), resolver);
|
||||||
@@ -280,6 +280,13 @@ import org.alfresco.service.namespace.QName;
|
|||||||
inheritedDefaultAspects.add(def);
|
inheritedDefaultAspects.add(def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolve archive inheritance
|
||||||
|
if (parentClass != null && archive == null)
|
||||||
|
{
|
||||||
|
// archive not explicitly set on this class and there is a parent class
|
||||||
|
inheritedArchive = ((M2ClassDefinition)parentClass).isArchive();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -340,8 +347,23 @@ import org.alfresco.service.namespace.QName;
|
|||||||
return (m2Class instanceof M2Aspect);
|
return (m2Class instanceof M2Aspect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the archive flag, which defaults to <tt>false</tt>
|
||||||
|
*/
|
||||||
public boolean isArchive()
|
public boolean isArchive()
|
||||||
{
|
{
|
||||||
|
if (archive == null)
|
||||||
|
{
|
||||||
|
if (inheritedArchive != null)
|
||||||
|
{
|
||||||
|
return inheritedArchive.booleanValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// default to false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return archive;
|
return archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -150,6 +150,15 @@
|
|||||||
</overrides>
|
</overrides>
|
||||||
</type>
|
</type>
|
||||||
|
|
||||||
|
<type name="test:file-derived">
|
||||||
|
<parent>test:file</parent>
|
||||||
|
</type>
|
||||||
|
|
||||||
|
<type name="test:file-derived-no-archive">
|
||||||
|
<parent>test:file</parent>
|
||||||
|
<archive>false</archive>
|
||||||
|
</type>
|
||||||
|
|
||||||
<type name="test:folder">
|
<type name="test:folder">
|
||||||
<parent>test:base</parent>
|
<parent>test:base</parent>
|
||||||
<properties>
|
<properties>
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
<cm:systemfolder view:childName="system" view:id="the root system folder">
|
<cm:systemfolder view:childName="system" view:id="the root system folder">
|
||||||
<cm:name>System</cm:name>
|
<cm:name>System</cm:name>
|
||||||
<cm:orderedchildren>true</cm:orderedchildren>
|
|
||||||
<cm:contains>
|
<cm:contains>
|
||||||
|
|
||||||
<cm:systemfolder view:childName="cm:people folder">
|
<cm:systemfolder view:childName="cm:people folder">
|
||||||
|
@@ -70,7 +70,7 @@ public class FileFolderServiceImpl implements FileFolderService
|
|||||||
"[not (subtypeOf('" + ContentModel.TYPE_SYSTEM_FOLDER + "'))" +
|
"[not (subtypeOf('" + ContentModel.TYPE_SYSTEM_FOLDER + "'))" +
|
||||||
" and (subtypeOf('" + ContentModel.TYPE_FOLDER + "'))]";
|
" and (subtypeOf('" + ContentModel.TYPE_FOLDER + "'))]";
|
||||||
|
|
||||||
/** Shallow search for all files and folders */
|
/** Shallow search for files and folders with a name pattern */
|
||||||
private static final String XPATH_QUERY_SHALLOW_ALL =
|
private static final String XPATH_QUERY_SHALLOW_ALL =
|
||||||
"./*" +
|
"./*" +
|
||||||
"[like(@cm:name, $cm:name, false)" +
|
"[like(@cm:name, $cm:name, false)" +
|
||||||
|
82
source/java/org/alfresco/repo/node/TemporaryAspect.java
Normal file
82
source/java/org/alfresco/repo/node/TemporaryAspect.java
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.node;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.copy.CopyServicePolicies;
|
||||||
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
|
import org.alfresco.repo.policy.PolicyScope;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers and contains the behaviour specific to the
|
||||||
|
* {@link org.alfresco.model.ContentModel#ASPECT_TEMPORARY temporary aspect}.
|
||||||
|
*
|
||||||
|
* @author gavinc
|
||||||
|
*/
|
||||||
|
public class TemporaryAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||||
|
{
|
||||||
|
// Dependencies
|
||||||
|
private PolicyComponent policyComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param policyComponent the policy component to register behaviour with
|
||||||
|
*/
|
||||||
|
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||||
|
{
|
||||||
|
this.policyComponent = policyComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the Temporary Aspect
|
||||||
|
* <p>
|
||||||
|
* Ensures that the {@link ContentModel#ASPECT_TEMPORARY temporary aspect}
|
||||||
|
* copy behaviour is disabled when update copies are performed.
|
||||||
|
*/
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
// disable copy for referencable aspect
|
||||||
|
this.policyComponent.bindClassBehaviour(
|
||||||
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onCopyNode"),
|
||||||
|
ContentModel.ASPECT_TEMPORARY,
|
||||||
|
new JavaBehaviour(this, "onCopyNode"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does nothing
|
||||||
|
*/
|
||||||
|
public void onCopyNode(
|
||||||
|
QName classRef,
|
||||||
|
NodeRef sourceNodeRef,
|
||||||
|
StoreRef destinationStoreRef,
|
||||||
|
boolean copyToNewNode,
|
||||||
|
PolicyScope copyDetails)
|
||||||
|
{
|
||||||
|
if (copyToNewNode)
|
||||||
|
{
|
||||||
|
copyDetails.addAspect(ContentModel.ASPECT_TEMPORARY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// don't copy if this is an update operation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -645,10 +645,11 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
|
|
||||||
public void deleteNode(NodeRef nodeRef)
|
public void deleteNode(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
boolean isArchivedNode = false;
|
boolean isArchivedNode = false;
|
||||||
|
boolean requiresDelete = false;
|
||||||
|
|
||||||
// Invoke policy behaviours
|
// Invoke policy behaviours
|
||||||
invokeBeforeDeleteNode(nodeRef);
|
invokeBeforeDeleteNode(nodeRef);
|
||||||
|
|
||||||
// get the node
|
// get the node
|
||||||
Node node = getNodeNotNull(nodeRef);
|
Node node = getNodeNotNull(nodeRef);
|
||||||
@@ -659,11 +660,27 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
Set<QName> nodeAspectQNames = node.getAspects();
|
Set<QName> nodeAspectQNames = node.getAspects();
|
||||||
|
|
||||||
// check if we need to archive the node
|
// check if we need to archive the node
|
||||||
StoreRef storeRef = nodeRef.getStoreRef();
|
StoreRef archiveStoreRef = null;
|
||||||
StoreRef archiveStoreRef = storeArchiveMap.getArchiveMap().get(storeRef);
|
if (nodeAspectQNames.contains(ContentModel.ASPECT_TEMPORARY))
|
||||||
// get the type and check if we need archiving
|
{
|
||||||
TypeDefinition typeDef = dictionaryService.getType(node.getTypeQName());
|
// the node has the temporary aspect meaning
|
||||||
if (typeDef == null || !typeDef.isArchive() || archiveStoreRef == null)
|
// it can not be archived
|
||||||
|
requiresDelete = true;
|
||||||
|
isArchivedNode = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StoreRef storeRef = nodeRef.getStoreRef();
|
||||||
|
archiveStoreRef = storeArchiveMap.getArchiveMap().get(storeRef);
|
||||||
|
// get the type and check if we need archiving
|
||||||
|
TypeDefinition typeDef = dictionaryService.getType(node.getTypeQName());
|
||||||
|
if (typeDef == null || !typeDef.isArchive() || archiveStoreRef == null)
|
||||||
|
{
|
||||||
|
requiresDelete = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requiresDelete)
|
||||||
{
|
{
|
||||||
// perform a normal deletion
|
// perform a normal deletion
|
||||||
nodeDaoService.deleteNode(node, true);
|
nodeDaoService.deleteNode(node, true);
|
||||||
|
@@ -27,6 +27,7 @@ import org.springframework.dao.InvalidDataAccessApiUsageException;
|
|||||||
public class ExceptionTranslatorMethodInterceptor implements MethodInterceptor
|
public class ExceptionTranslatorMethodInterceptor implements MethodInterceptor
|
||||||
{
|
{
|
||||||
private static final String MSG_ACCESS_DENIED = "permissions.err_access_denied";
|
private static final String MSG_ACCESS_DENIED = "permissions.err_access_denied";
|
||||||
|
private static final String MSG_READ_ONLY = "permissions.err_read_only";
|
||||||
|
|
||||||
public ExceptionTranslatorMethodInterceptor()
|
public ExceptionTranslatorMethodInterceptor()
|
||||||
{
|
{
|
||||||
@@ -46,7 +47,7 @@ public class ExceptionTranslatorMethodInterceptor implements MethodInterceptor
|
|||||||
catch (InvalidDataAccessApiUsageException e)
|
catch (InvalidDataAccessApiUsageException e)
|
||||||
{
|
{
|
||||||
// this usually occurs when the server is in read-only mode
|
// this usually occurs when the server is in read-only mode
|
||||||
throw new AccessDeniedException(MSG_ACCESS_DENIED, e);
|
throw new AccessDeniedException(MSG_READ_ONLY, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,13 @@ import org.alfresco.service.transaction.TransactionService;
|
|||||||
*/
|
*/
|
||||||
public interface ContentAccessor
|
public interface ContentAccessor
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Gets the open/close state of the underlying IO Channel.
|
||||||
|
*
|
||||||
|
* @return Returns true if the underlying IO Channel is open
|
||||||
|
*/
|
||||||
|
public boolean isChannelOpen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this method to register any interest in events against underlying
|
* Use this method to register any interest in events against underlying
|
||||||
* content streams.
|
* content streams.
|
||||||
|
Reference in New Issue
Block a user