Merged V2.1 to HEAD

6580: AVM bulk import performance tweaks.
   6582: WCM-767, WCM-768
   6583: Fix for AWC-1528 (potential NPE in ErrorsRenderer)
   6584: Fix for AWC-1256 (Links produced by inline HTML editor are incorrect)
   6585: AR-1635: event listeners added in a beforeCommit event are now executed successfully
   6586: AR-1561 Update Web Scripts readme.html to be consistent with "Category Search Sample" (or vice-versa)
   6587: Fix for AWC-1390 (Paste all doesn't work for forum items)
   6588: AR-1701 Script getDocument call doesn't check for non-existent content
   6589: Fix for AWC-1530 - Saved search does not work for custom properties of type d:text with list constraint
   6591: Improvement for submit speed.
   6592: Removed obsolete tests.
   6594: Index tracking sample to include AVM index tracking
   6595: Added the AVM helpers methods from the FreeMarker AVM API that were missing from the JavaScript API
   6597: Rationalize post commit execution hooks for deployment receiver
   6598: Properly escape path names for ProgramRunnable.
   6599: AVM store name lookup cache is (theoretically) clusterable.
   6600: Some or other gramatically incorrect stuff about Chiba.
   6601: Fix for AR-1121 and AR-1673
   6602: AR-1655: Versioning is not MLText aware
   6603: Updated messages from lang packs
   6604: Fixed AR-1476: JCR import end element escaping
   6605: Updated Japanese lang messages


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6746 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-11 03:03:50 +00:00
parent 19e1af2314
commit 57554088ae
33 changed files with 638 additions and 85 deletions

View File

@@ -44,6 +44,9 @@
<property name="sessionFactory"> <property name="sessionFactory">
<ref bean="sessionFactory"/> <ref bean="sessionFactory"/>
</property> </property>
<property name="cache">
<ref bean="avmStoreLookupCache"/>
</property>
</bean> </bean>
<bean id="versionRootDAO" class="org.alfresco.repo.avm.hibernate.VersionRootDAOHibernate"> <bean id="versionRootDAO" class="org.alfresco.repo.avm.hibernate.VersionRootDAOHibernate">

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
<view:reference xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:alf="http://www.alfresco.org" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:wf="http://www.alfresco.org/model/workflow/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:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:wcm="http://www.alfresco.org/model/wcmmodel/1.0" xmlns:wca="http://www.alfresco.org/model/wcmappmodel/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:wcmwf="http://www.alfresco.org/model/wcmworkflow/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:custom="custom.model" xmlns:reg="http://www.alfresco.org/system/registry/1.0" xmlns:module="http://www.alfresco.org/system/modules/1.0" xmlns="" view:pathref="/app:company_home/app:dictionary/app:content_templates/cm:readme.ftl">
<view:properties>
<cm:content>contentUrl=classpath:alfresco/bootstrap/webscripts/readme.html|mimetype=text/html|size=|encoding=UTF-8|locale=en_US_</cm:content>
</view:properties>
</view:reference>
</view:view>

View File

@@ -1 +1,23 @@
<h1>Web Scripts</h1><p>Documentation on how to develop a Web Script may be found <a href="http://wiki.alfresco.com/wiki/Web_Scripts">here</a>. </p><p>Web Scripts allow you to bind new Alfresco-based functionality to a HTTP method and custom URL. A library of URLs may be built up to provide a complete API accessible via HTTP.&nbsp; They are ideal for building data access &amp; update APIs and simple UI components such as Portlets.&nbsp; Development of Web Scripts may be performed within Alfresco.&nbsp; Knowledge of Java is <em><strong>not</strong></em> required.<br /> </p><p>For example, you could create the following API for your particular application... </p> <dl><dt><strong>Execute a search</strong> </dt></dl> <p>GET http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/category?c=Web20 </p> <dl><dt><strong>Retrieve meta-data for an item in the repository</strong> </dt></dl> <p>GET http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/2007/03/04/new-release </p> <dl><dt><strong>Update meta-data for an item in the repository</strong> </dt></dl> <p>POST http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/2007/03/04/new-release?status=Draft </p> <dl><dt><strong>Delete an item in the repository</strong> </dt></dl> <p>DELETE http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/2007/03/04/new-release </p> <h1>Web Scripts</h1>
<p>
Documentation on how to develop a Web Script may be found <a href="http://wiki.alfresco.com/wiki/Web_Scripts">here</a>. </p><p>Web Scripts allow you to bind new Alfresco-based functionality to a HTTP method and custom URL. A library of URLs may be built up to provide a complete API accessible via HTTP.&nbsp; They are ideal for building data access &amp; update APIs and simple UI components such as Portlets.&nbsp; Development of Web Scripts may be performed within Alfresco.&nbsp; Knowledge of Java is <em><strong>not</strong></em> required.<br/>
</p>
<p>
For example, you could create the following API for your particular application...
</p>
<dl><dt><strong>Execute a search</strong> </dt></dl>
<p>
GET http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/category/{category}
</p>
<dl><dt><strong>Retrieve meta-data for an item in the repository</strong> </dt></dl>
<p>
GET http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/2007/03/04/new-release
</p>
<dl><dt><strong>Update meta-data for an item in the repository</strong> </dt></dl>
<p>
POST http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/2007/03/04/new-release?status=Draft
</p>
<dl><dt><strong>Delete an item in the repository</strong></dt></dl>
<p>
DELETE http://&lt;host&gt;:&lt;port&gt;/alfresco/service/blog/2007/03/04/new-release
</p>

View File

@@ -281,6 +281,42 @@
</property> </property>
</bean> </bean>
<!-- ===================================== -->
<!-- AVM Store lookup cache -->
<!-- ===================================== -->
<!-- The cross-transaction shared cache for AVM store lookups -->
<bean name="avmStoreLookupSharedCache" class="org.alfresco.repo.cache.EhCacheAdapter">
<property name="cache">
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<ref bean="internalEHCacheManager"/>
</property>
<property name="cacheName">
<value>org.alfresco.repo.avm.storeLookupSharedCache</value>
</property>
</bean>
</property>
</bean>
<!-- Transactional cache for AVM store lookups -->
<bean name="avmStoreLookupCache" class="org.alfresco.repo.cache.TransactionalCache">
<property name="sharedCache">
<ref bean="avmStoreLookupSharedCache"/>
</property>
<property name="cacheManager">
<ref bean="transactionalEHCacheManager"/>
</property>
<property name="name">
<value>org.alfresco.repo.avm.storeLookupTransactionalCache</value>
</property>
<property name="maxCacheSize">
<value>100</value>
</property>
</bean>
<!-- ===================================== --> <!-- ===================================== -->
<!-- WebServices Query Session Cache --> <!-- WebServices Query Session Cache -->
<!-- ===================================== --> <!-- ===================================== -->

View File

@@ -3,8 +3,12 @@
<beans> <beans>
<!-- Schedule index tracking every 30s --> <!--===========================-->
<bean id="indexTrackerTrigger" class="org.alfresco.util.CronTriggerBean"> <!-- ADM index tracking -->
<!--===========================-->
<!-- Schedule index tracking for ADM every 10s -->
<bean id="admIndexTrackerTrigger" class="org.alfresco.util.CronTriggerBean">
<property name="jobDetail"> <property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.JobDetailBean"> <bean class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass"> <property name="jobClass">
@@ -13,7 +17,7 @@
<property name="jobDataAsMap"> <property name="jobDataAsMap">
<map> <map>
<entry key="indexRecoveryComponent"> <entry key="indexRecoveryComponent">
<ref bean="indexTrackerComponent" /> <ref bean="admIndexTrackerComponent" />
</entry> </entry>
</map> </map>
</property> </property>
@@ -28,7 +32,7 @@
</bean> </bean>
<bean <bean
id="indexTrackerComponent" id="admIndexTrackerComponent"
class="org.alfresco.repo.node.index.IndexRemoteTransactionTracker" class="org.alfresco.repo.node.index.IndexRemoteTransactionTracker"
parent="indexRecoveryComponentBase"> parent="indexRecoveryComponentBase">
<property name="remoteOnly"> <property name="remoteOnly">
@@ -36,15 +40,12 @@
</property> </property>
</bean> </bean>
<!-- Forces the reindexing of nodes where content may have been missing before --> <!--===========================-->
<!-- <!-- AVM (WCM) index tracking -->
This component can be triggered at intervals where asynchronous content sharing <!--===========================-->
between clustered servers has been set up. If content sharing is synchronous
(see ReplicatingContentStore.setOutboundThreadPoolExecutor) then this component <!-- Schedule index tracking for AVM every 60s -->
is not required. <bean id="indexTrackerTrigger" class="org.alfresco.util.CronTriggerBean">
-->
<!--
<bean id="missingContentReindexTrigger" class="org.alfresco.util.TriggerBean">
<property name="jobDetail"> <property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.JobDetailBean"> <bean class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass"> <property name="jobClass">
@@ -53,7 +54,7 @@
<property name="jobDataAsMap"> <property name="jobDataAsMap">
<map> <map>
<entry key="indexRecoveryComponent"> <entry key="indexRecoveryComponent">
<ref bean="missingContentReindexComponent" /> <ref bean="avmIndexTrackerComponent" />
</entry> </entry>
</map> </map>
</property> </property>
@@ -62,13 +63,21 @@
<property name="scheduler"> <property name="scheduler">
<ref bean="schedulerFactory" /> <ref bean="schedulerFactory" />
</property> </property>
<property name="startDelayMinutes"> <property name="cronExpression">
<value>5</value> <value>15 * * * * ?</value>
</property> </property>
<property name="repeatCount"> </bean>
<value>0</value>
<bean
id="avmIndexTrackerComponent"
class="org.alfresco.repo.node.index.AVMRemoteSnapshotTracker"
parent="indexRecoveryComponentBase">
<property name="avmService">
<ref bean="avmService" />
</property>
<property name="avmSnapShotTriggeredIndexingMethodInterceptor">
<ref bean="avmSnapShotTriggeredIndexingMethodInterceptor" />
</property> </property>
</bean> </bean>
-->
</beans> </beans>

View File

@@ -148,6 +148,7 @@ patch.AVMGuidPatch.result=AVM GUIDS set.
patch.webscripts.description=Adds Web Scripts to Data Dictionary. patch.webscripts.description=Adds Web Scripts to Data Dictionary.
patch.webscripts2.description=Adds Web Scripts (second set) to Data Dictionary. patch.webscripts2.description=Adds Web Scripts (second set) to Data Dictionary.
patch.webscripts3.description=Update Web Scripts ReadMe.
patch.webscriptsExtension.description=Adds Web Scripts Extension to Data Dictionary. patch.webscriptsExtension.description=Adds Web Scripts Extension to Data Dictionary.
patch.AVMLayeredSnapshot.description=Set indirectionVersion on Layered Nodes. patch.AVMLayeredSnapshot.description=Set indirectionVersion on Layered Nodes.

View File

@@ -1001,4 +1001,21 @@
</property> </property>
</bean> </bean>
<bean id="patch.webscripts3" class="org.alfresco.repo.admin.patch.impl.GenericBootstrapPatch" parent="basePatch" >
<property name="id"><value>patch.webscripts3</value></property>
<property name="description"><value>patch.webscripts3.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>104</value></property>
<property name="targetSchema"><value>105</value></property>
<property name="importerBootstrap">
<ref bean="spacesBootstrap" />
</property>
<property name="bootstrapView">
<props>
<prop key="path">/</prop>
<prop key="location">alfresco/bootstrap/webScriptsReadme2.xml</prop>
</props>
</property>
</bean>
</beans> </beans>

View File

@@ -129,6 +129,9 @@
<property name="serviceRegistry"> <property name="serviceRegistry">
<ref bean="ServiceRegistry"/> <ref bean="ServiceRegistry"/>
</property> </property>
<property name="nameMatcher">
<ref bean="globalPathExcluder"/>
</property>
</bean> </bean>
<bean id="crossCopyScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.CrossRepositoryCopy"> <bean id="crossCopyScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.CrossRepositoryCopy">

View File

@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number # Schema number
version.schema=104 version.schema=105

View File

@@ -318,7 +318,7 @@ public class JCRDocXMLHandler implements ImportContentHandler
{ {
// ensure context matches parse // ensure context matches parse
ElementContext context = (ElementContext)contextStack.pop(); ElementContext context = (ElementContext)contextStack.pop();
QName elementName = QName.createQName(qName, importResolver); QName elementName = decodeQName(QName.createQName(qName, importResolver));
if (!context.getElementName().equals(elementName)) if (!context.getElementName().equals(elementName))
{ {
throw new InvalidSerializedDataException("Expected element " + context.getElementName() + " but was " + elementName); throw new InvalidSerializedDataException("Expected element " + context.getElementName() + " but was " + elementName);

View File

@@ -280,7 +280,9 @@ public class AttributeServiceTest extends TestCase
assertEquals(27, fService.getKeys("map/submap").size()); assertEquals(27, fService.getKeys("map/submap").size());
fService.removeAttribute("map/submap/subsubmap", "b"); fService.removeAttribute("map/submap/subsubmap", "b");
assertEquals(25, fService.getKeys("map/submap/subsubmap").size()); assertEquals(25, fService.getKeys("map/submap/subsubmap").size());
System.out.println("Before-------------------------------------------------------------");
fService.removeAttribute("map/submap", "subsubmap"); fService.removeAttribute("map/submap", "subsubmap");
System.out.println("After--------------------------------------------------------------");
assertEquals(26, fService.getKeys("map/submap").size()); assertEquals(26, fService.getKeys("map/submap").size());
fService.removeEntries("map/submap", new AttrAndQuery(new AttrQueryGTE("a"), fService.removeEntries("map/submap", new AttrAndQuery(new AttrQueryGTE("a"),
new AttrQueryLTE("d"))); new AttrQueryLTE("d")));

View File

@@ -34,6 +34,7 @@ import org.alfresco.repo.attributes.AttrQueryHelperImpl;
import org.alfresco.repo.attributes.Attribute; import org.alfresco.repo.attributes.Attribute;
import org.alfresco.repo.attributes.AttributeDAO; import org.alfresco.repo.attributes.AttributeDAO;
import org.alfresco.repo.attributes.ListAttribute; import org.alfresco.repo.attributes.ListAttribute;
import org.alfresco.repo.attributes.ListEntry;
import org.alfresco.repo.attributes.ListEntryDAO; import org.alfresco.repo.attributes.ListEntryDAO;
import org.alfresco.repo.attributes.MapAttribute; import org.alfresco.repo.attributes.MapAttribute;
import org.alfresco.repo.attributes.MapEntry; import org.alfresco.repo.attributes.MapEntry;
@@ -78,24 +79,23 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
if (attr.getType() == Type.MAP) if (attr.getType() == Type.MAP)
{ {
MapAttribute map = (MapAttribute)attr; MapAttribute map = (MapAttribute)attr;
Collection<Attribute> attrs = map.values(); List<MapEntry> mapEntries = fMapEntryDAO.get(map);
fMapEntryDAO.delete(map); for (MapEntry entry : mapEntries)
for (Attribute subAttr : attrs)
{ {
Attribute subAttr = entry.getAttribute();
fMapEntryDAO.delete(entry);
delete(subAttr); delete(subAttr);
} }
} }
if (attr.getType() == Type.LIST) if (attr.getType() == Type.LIST)
{ {
List<Attribute> children = new ArrayList<Attribute>(); ListAttribute list = (ListAttribute)attr;
for (Attribute child : attr) List<ListEntry> listEntries = fListEntryDAO.get(list);
for (ListEntry entry : listEntries)
{ {
children.add(child); Attribute subAttr = entry.getAttribute();
} fListEntryDAO.delete(entry);
fListEntryDAO.delete((ListAttribute)attr); delete(subAttr);
for (Attribute child : children)
{
delete(child);
} }
} }
getSession().delete(attr); getSession().delete(attr);

View File

@@ -882,4 +882,21 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
} }
} }
} }
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avm.AVMService#createDirectory(java.lang.String, java.lang.String, java.util.List, java.util.Map)
*/
public void createDirectory(String path, String name, List<QName> aspects, Map<QName, PropertyValue> properties)
{
fService.createDirectory(path, name, aspects, properties);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avm.AVMService#createFile(java.lang.String, java.lang.String, java.io.InputStream, java.util.List, java.util.Map)
*/
public void createFile(String path, String name, InputStream in, List<QName> aspects, Map<QName, PropertyValue> properties)
{
grabLock(path + '/' + name);
fService.createFile(path, name, in, aspects, properties);
}
} }

View File

@@ -254,7 +254,7 @@ public class AVMRepository
* @param name The name to give the file. * @param name The name to give the file.
* @param data The file contents. * @param data The file contents.
*/ */
public void createFile(String path, String name, File data) public void createFile(String path, String name, File data, List<QName> aspects, Map<QName, PropertyValue> properties)
{ {
fLookupCount.set(1); fLookupCount.set(1);
try try
@@ -266,7 +266,7 @@ public class AVMRepository
throw new AVMNotFoundException("Store not found."); throw new AVMNotFoundException("Store not found.");
} }
fLookupCache.onWrite(pathParts[0]); fLookupCache.onWrite(pathParts[0]);
store.createFile(pathParts[1], name, data); store.createFile(pathParts[1], name, data, aspects, properties);
} }
finally finally
{ {
@@ -279,7 +279,7 @@ public class AVMRepository
* @param path The path to the containing directory. * @param path The path to the containing directory.
* @param name The name to give the directory. * @param name The name to give the directory.
*/ */
public void createDirectory(String path, String name) public void createDirectory(String path, String name, List<QName> aspects, Map<QName, PropertyValue> properties)
{ {
fLookupCount.set(1); fLookupCount.set(1);
try try
@@ -291,7 +291,7 @@ public class AVMRepository
throw new AVMNotFoundException("Store not found."); throw new AVMNotFoundException("Store not found.");
} }
fLookupCache.onWrite(pathParts[0]); fLookupCache.onWrite(pathParts[0]);
store.createDirectory(pathParts[1], name); store.createDirectory(pathParts[1], name, aspects, properties);
} }
finally finally
{ {

View File

@@ -357,6 +357,14 @@ public class AVMServiceImpl implements AVMService
* @param in An InputStream containing data for file. * @param in An InputStream containing data for file.
*/ */
public void createFile(String path, String name, InputStream in) public void createFile(String path, String name, InputStream in)
{
createFile(path, name, in, null, null);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avm.AVMService#createFile(java.lang.String, java.lang.String, java.io.InputStream, java.util.List, java.util.Map)
*/
public void createFile(String path, String name, InputStream in, List<QName> aspects, Map<QName, PropertyValue> properties)
{ {
if (path == null || name == null || in == null || !FileNameValidator.IsValid(name)) if (path == null || name == null || in == null || !FileNameValidator.IsValid(name))
{ {
@@ -383,7 +391,7 @@ public class AVMServiceImpl implements AVMService
} }
try try
{ {
fAVMRepository.createFile(path, name, temp); fAVMRepository.createFile(path, name, temp, aspects, properties);
} }
finally finally
{ {
@@ -397,12 +405,20 @@ public class AVMServiceImpl implements AVMService
* @param name The name of the new directory. * @param name The name of the new directory.
*/ */
public void createDirectory(String path, String name) public void createDirectory(String path, String name)
{
createDirectory(path, name, null, null);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avm.AVMService#createDirectory(java.lang.String, java.lang.String, java.util.List, java.util.Map)
*/
public void createDirectory(String path, String name, List<QName> aspects, Map<QName, PropertyValue> properties)
{ {
if (path == null || name == null || !FileNameValidator.IsValid(name)) if (path == null || name == null || !FileNameValidator.IsValid(name))
{ {
throw new AVMBadArgumentException("Illegal argument."); throw new AVMBadArgumentException("Illegal argument.");
} }
fAVMRepository.createDirectory(path, name); fAVMRepository.createDirectory(path, name, aspects, properties);
} }
/** /**

View File

@@ -5043,6 +5043,8 @@ public class AVMServiceTest extends AVMServiceTestBase
AVMStoreDescriptor desc = fService.getStore("main"); AVMStoreDescriptor desc = fService.getStore("main");
assertNotNull(desc); assertNotNull(desc);
System.out.println(desc); System.out.println(desc);
fService.purgeStore("main");
assertNull(fService.getStore("main"));
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -87,7 +87,7 @@ public interface AVMStore
* @param path The path to the parent directory. * @param path The path to the parent directory.
* @param name The name to give the new directory. * @param name The name to give the new directory.
*/ */
public void createDirectory(String path, String name); public void createDirectory(String path, String name, List<QName> aspects, Map<QName, PropertyValue> properties);
/** /**
* Create a new layered directory. * Create a new layered directory.
@@ -112,7 +112,7 @@ public interface AVMStore
* @param name The name to give the file. * @param name The name to give the file.
* @param data The contents of the file. * @param data The contents of the file.
*/ */
public void createFile(String path, String name, File data); public void createFile(String path, String name, File data, List<QName> aspects, Map<QName, PropertyValue> properties);
/** /**
* Create a new layered file. * Create a new layered file.

View File

@@ -319,7 +319,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the containing directory. * @param path The path to the containing directory.
* @param name The name of the new directory. * @param name The name of the new directory.
*/ */
public void createDirectory(String path, String name) public void createDirectory(String path, String name, List<QName> aspects, Map<QName, PropertyValue> properties)
{ {
Lookup lPath = lookupDirectory(-1, path, true); Lookup lPath = lookupDirectory(-1, path, true);
if (lPath == null) if (lPath == null)
@@ -353,6 +353,14 @@ public class AVMStoreImpl implements AVMStore, Serializable
} }
dir.updateModTime(); dir.updateModTime();
dir.putChild(name, newDir); dir.putChild(name, newDir);
if (aspects != null)
{
newDir.getAspects().addAll(aspects);
}
if (properties != null)
{
newDir.getProperties().putAll(properties);
}
} }
/** /**
@@ -442,7 +450,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param name The name to give the new file. * @param name The name to give the new file.
* @param data The contents. * @param data The contents.
*/ */
public void createFile(String path, String name, File data) public void createFile(String path, String name, File data, List<QName> aspects, Map<QName, PropertyValue> properties)
{ {
Lookup lPath = lookupDirectory(-1, path, true); Lookup lPath = lookupDirectory(-1, path, true);
if (lPath == null) if (lPath == null)
@@ -468,10 +476,19 @@ public class AVMStoreImpl implements AVMStore, Serializable
RawServices.Instance().getMimetypeService().guessMimetype(name), RawServices.Instance().getMimetypeService().guessMimetype(name),
-1, -1,
"UTF-8")); "UTF-8"));
if (aspects != null)
{
file.getAspects().addAll(aspects);
}
if (properties != null)
{
file.getProperties().putAll(properties);
}
// Yet another flush. // Yet another flush.
AVMDAOs.Instance().fAVMNodeDAO.flush(); AVMDAOs.Instance().fAVMNodeDAO.flush();
ContentWriter writer = createContentWriter(AVMNodeConverter.ExtendAVMPath(path, name)); ContentWriter writer = createContentWriter(AVMNodeConverter.ExtendAVMPath(path, name));
writer.putContent(data); writer.putContent(data);
} }
/** /**

View File

@@ -24,14 +24,13 @@
package org.alfresco.repo.avm.hibernate; package org.alfresco.repo.avm.hibernate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.alfresco.repo.avm.AVMNode; import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.AVMStore; import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.AVMStoreDAO; import org.alfresco.repo.avm.AVMStoreDAO;
import org.alfresco.repo.avm.AVMStoreImpl; import org.alfresco.repo.avm.AVMStoreImpl;
import org.alfresco.repo.cache.SimpleCache;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@@ -46,7 +45,7 @@ class AVMStoreDAOHibernate extends HibernateDaoSupport implements
/** /**
* An in memory cache of name to primary key mappings. * An in memory cache of name to primary key mappings.
*/ */
private Map<String, Long> fNameCache; private SimpleCache<String, Long> fNameCache;
/** /**
* Do nothing constructor. * Do nothing constructor.
@@ -54,7 +53,11 @@ class AVMStoreDAOHibernate extends HibernateDaoSupport implements
public AVMStoreDAOHibernate() public AVMStoreDAOHibernate()
{ {
super(); super();
fNameCache = new HashMap<String, Long>(); }
public void setCache(SimpleCache<String, Long> cache)
{
fNameCache = cache;
} }
/** /**
@@ -100,10 +103,7 @@ class AVMStoreDAOHibernate extends HibernateDaoSupport implements
public AVMStore getByName(String name) public AVMStore getByName(String name)
{ {
Long id = null; Long id = null;
synchronized (this)
{
id = fNameCache.get(name); id = fNameCache.get(name);
}
if (id != null) if (id != null)
{ {
return forceNonLazy((AVMStore)getSession().get(AVMStoreImpl.class, id)); return forceNonLazy((AVMStore)getSession().get(AVMStoreImpl.class, id));
@@ -112,13 +112,10 @@ class AVMStoreDAOHibernate extends HibernateDaoSupport implements
"where st.name = :name"); "where st.name = :name");
query.setParameter("name", name); query.setParameter("name", name);
AVMStore result = (AVMStore)query.uniqueResult(); AVMStore result = (AVMStore)query.uniqueResult();
synchronized (this)
{
if (result != null) if (result != null)
{ {
fNameCache.put(name, result.getId()); fNameCache.put(name, result.getId());
} }
}
return forceNonLazy(result); return forceNonLazy(result);
} }

View File

@@ -182,7 +182,9 @@ public class AVMLockingServiceTest extends TestCase
System.out.println(fAttributeService.getAttribute(".avm_lock_table")); System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
// assertEquals(2, fService.getUsersLocks("Buffy").size()); // assertEquals(2, fService.getUsersLocks("Buffy").size());
assertEquals(2, fService.getWebProjectLocks("alfresco").size()); assertEquals(2, fService.getWebProjectLocks("alfresco").size());
System.out.println("Before----------------------------");
fService.removeLock("alfresco", "Revello Drive/1630"); fService.removeLock("alfresco", "Revello Drive/1630");
System.out.println("After----------------------------");
System.out.println(fAttributeService.getAttribute(".avm_lock_table")); System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
// assertEquals(1, fService.getUsersLocks("Buffy").size()); // assertEquals(1, fService.getUsersLocks("Buffy").size());
assertEquals(1, fService.getWebProjectLocks("alfresco").size()); assertEquals(1, fService.getWebProjectLocks("alfresco").size());

View File

@@ -108,7 +108,9 @@ public class AVMSubmitTransactionListener extends TransactionListenerAdapter
true true
); );
if (log.isDebugEnabled()) if (log.isDebugEnabled())
log.debug("JMX update to virt server called after commit"); log.debug("JMX update to virt server called after commit." +
" Version: " + requiresUpdate.getDestinationVersion() +
" Path: " + requiresUpdate.getDestinationPath());
} }
// Remove virtual webapps from workflow sandbox prior to // Remove virtual webapps from workflow sandbox prior to

View File

@@ -99,6 +99,7 @@ public class FSDeploymentTest extends AVMServiceTestBase
fService.removeNode("main:/d/e"); fService.removeNode("main:/d/e");
fService.createDirectory("main:/d", "e"); fService.createDirectory("main:/d", "e");
fService.createFile("main:/d/e", "Warren.txt").close(); fService.createFile("main:/d/e", "Warren.txt").close();
fService.createFile("main:/d/e", "It's a silly name.txt").close();
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null); report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
count = 0; count = 0;
for (DeploymentEvent event : report) for (DeploymentEvent event : report)
@@ -106,7 +107,7 @@ public class FSDeploymentTest extends AVMServiceTestBase
System.out.println(event); System.out.println(event);
count++; count++;
} }
assertEquals(4, count); assertEquals(5, count);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -24,13 +24,21 @@
*/ */
package org.alfresco.repo.jscript; package org.alfresco.repo.jscript;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.alfresco.config.JNDIConstants; import org.alfresco.config.JNDIConstants;
import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor; import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.NameMatcher;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.mozilla.javascript.Context; import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Scriptable;
@@ -45,6 +53,8 @@ public final class AVM extends BaseScopableProcessorExtension
/** Repository Service Registry */ /** Repository Service Registry */
private ServiceRegistry services; private ServiceRegistry services;
private NameMatcher matcher;
/** /**
* Set the service registry * Set the service registry
* *
@@ -55,6 +65,11 @@ public final class AVM extends BaseScopableProcessorExtension
this.services = serviceRegistry; this.services = serviceRegistry;
} }
public void setNameMatcher(NameMatcher matcher)
{
this.matcher = matcher;
}
/** /**
* @return a array of all AVM stores in the system * @return a array of all AVM stores in the system
*/ */
@@ -137,6 +152,172 @@ public final class AVM extends BaseScopableProcessorExtension
return node; return node;
} }
/**
* Return the list of modified items for the specified user sandbox against staging store id
* for a specific webapp.
*
* @param storeId Root Store ID
* @param username Username to get modified items for
* @param webapp Webapp name to filter by
*
* @return List of AVMNode objects representing the modified items
*/
public List<AVMNode> getModifiedItems(String storeId, String username, String webapp)
{
ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username);
ParameterCheck.mandatoryString("Webapp", webapp);
List<AVMNode> items;
AVMService avmService = this.services.getAVMService();
// build the paths to the stores to compare - filter by current webapp
String userStore = userSandboxStore(storeId, username);
String userStorePath = getStoreRootWebappPath(userStore, webapp);
String stagingStore = stagingStore(storeId);
String stagingStorePath = getStoreRootWebappPath(stagingStore, webapp);
List<AVMDifference> diffs = this.services.getAVMSyncService().compare(
-1, userStorePath, -1, stagingStorePath, this.matcher);
items = new ArrayList<AVMNode>(diffs.size());
for (AVMDifference diff : diffs)
{
// convert each diff record into an AVM Node template wrapper
String sourcePath = diff.getSourcePath();
AVMNodeDescriptor node = avmService.lookup(-1, sourcePath);
if (node != null)
{
items.add(new AVMNode(node.getPath(), -1, this.services, getScope()));
}
}
return items;
}
/**
* @param storeId Store ID to build staging store name for
*
* @return the Staging Store name for the given store ID
*/
public static String stagingStore(String storeId)
{
ParameterCheck.mandatoryString("Store ID", storeId);
return storeId;
}
/**
* @param storeId Store ID to build sandbox store name for
* @param username Username of the sandbox user
*
* @return the Sandbox Store name for the given store ID and username
*/
public static String userSandboxStore(String storeId, String username)
{
ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username);
return storeId + "--" + username;
}
/**
* @param storeId Store ID to build preview URL for
*
* @return the preview URL to the staging store for the specified store ID
*/
public String websiteStagingUrl(String storeId)
{
ParameterCheck.mandatoryString("Store ID", storeId);
return MessageFormat.format(JNDIConstants.PREVIEW_SANDBOX_URL,
lookupStoreDNS(storeId), getVServerDomain(), getVServerPort());
}
/**
* @param storeId Store ID to build preview URL for
* @param username Username to build sandbox preview URL for
*
* @return the preview URL to the user sandbox for the specified store ID and username
*/
public String websiteUserSandboxUrl(String storeId, String username)
{
ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username);
return websiteStagingUrl(userSandboxStore(storeId, username));
}
/**
* @param store Store ID of the asset
* @param assetPath Store relative path to the asset
*
* @return the preview URL to the specified store asset
*/
public String assetUrl(String store, String assetPath)
{
ParameterCheck.mandatoryString("Store", store);
ParameterCheck.mandatoryString("Asset Path", assetPath);
if (assetPath.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE))
{
assetPath = assetPath.substring(('/' + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE).length());
}
if (assetPath.startsWith("/ROOT"))
{
assetPath = assetPath.substring(("/ROOT").length());
}
if (assetPath.length() == 0 || assetPath.charAt(0) != '/')
{
assetPath = '/' + assetPath;
}
return MessageFormat.format(JNDIConstants.PREVIEW_ASSET_URL,
lookupStoreDNS(store), getVServerDomain(), getVServerPort(), assetPath);
}
/**
* @param avmPath Fully qualified AVM path of the asset
*
* @return the preview URL to the specified asset
*/
public String assetUrl(String avmPath)
{
ParameterCheck.mandatoryString("AVM Path", avmPath);
String[] s = avmPath.split(":");
if (s.length != 2)
{
throw new IllegalArgumentException("Expected exactly one ':' in " + avmPath);
}
return assetUrl(s[0], s[1]);
}
/**
* @return VServer Port
*/
private String getVServerPort()
{
Integer port = this.services.getVirtServerRegistry().getVirtServerHttpPort();
if (port == null)
{
port = JNDIConstants.DEFAULT_VSERVER_PORT;
}
return port.toString();
}
/**
* @return VServer Domain
*/
private String getVServerDomain()
{
String domain = this.services.getVirtServerRegistry().getVirtServerFQDN();
if (domain == null)
{
domain = JNDIConstants.DEFAULT_VSERVER_IP;
}
return domain;
}
/**
* @return the path to the webapps folder in a standard web store.
*/
public static String getWebappsFolderPath() public static String getWebappsFolderPath()
{ {
return '/' + JNDIConstants.DIR_DEFAULT_WWW + return '/' + JNDIConstants.DIR_DEFAULT_WWW +
@@ -147,4 +328,24 @@ public final class AVM extends BaseScopableProcessorExtension
{ {
return getWebappsFolderPath(); return getWebappsFolderPath();
} }
private static String getStoreRootPath(String store)
{
return store + ":" + getWebappsFolderPath();
}
private static String getStoreRootWebappPath(String store, String webapp)
{
return getStoreRootPath(store) + '/' + webapp;
}
private String lookupStoreDNS(String store)
{
Map<QName, PropertyValue> props =
this.services.getAVMService().queryStorePropertyKey(store, QName.createQName(null, PROP_DNS + '%'));
return (props.size() == 1
? props.keySet().iterator().next().getLocalName().substring(PROP_DNS.length()) : null);
}
private final static String PROP_DNS = ".dns.";
} }

View File

@@ -0,0 +1,86 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.repo.jscript;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.namespace.QName;
/**
* Specialised map class for supporting the initialisation of 'cm:content' properties for JavaScript API
* objects. The JavaScript needs supporting objects to be initialised for certain data-types. If the
* 'cm:content' property is not already initialised then it must be created on demand or it will not be
* available to the users of the API. See AR-1673.
*
* @author Kevin Roast
*/
public class ContentAwareScriptableQNameMap<K,V> extends ScriptableQNameMap<K,V>
{
private ServiceRegistry services;
private ScriptNode factory;
public ContentAwareScriptableQNameMap(ScriptNode factory, ServiceRegistry services)
{
super(services.getNamespaceService());
this.services = services;
this.factory = factory;
}
/* (non-Javadoc)
* @see org.alfresco.service.namespace.QNameMap#get(java.lang.Object)
*/
@Override
public Object get(Object name)
{
Object value = super.get(name);
if (value == null)
{
// convert the key to a qname and look up the data-type for the property
QName qname = QName.resolveToQName(this.resolver, name.toString());
PropertyDefinition propDef = this.services.getDictionaryService().getProperty(qname);
if (propDef != null && DataTypeDefinition.CONTENT.equals(propDef.getDataType().getName()))
{
// found a valid cm:content property that is not initialised
String mimetype = null;
String fileName = (String)get("cm:name");
if (fileName != null)
{
mimetype = this.services.getMimetypeService().guessMimetype(fileName);
}
ContentData cdata = new ContentData(null, mimetype, 0L, "UTF-8");
// create the JavaScript API object we need
value = factory.new ScriptContentData(cdata, ContentModel.PROP_CONTENT);
// and store it so it is available to the API user
put(name, value);
}
}
return value;
}
}

View File

@@ -32,6 +32,7 @@ import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionDefinition; import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ParameterDefinition; import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Wrapper; import org.mozilla.javascript.Wrapper;
@@ -154,6 +155,31 @@ public final class ScriptAction implements Serializable, Scopeable
node.reset(); node.reset();
} }
/**
* Execute action
*
* @param nodeRef
* the node to execute action upon
*/
@SuppressWarnings("synthetic-access")
public void execute(NodeRef nodeRef)
{
if (this.parameters != null && this.parameters.isModified())
{
Map<String, Serializable> actionParams = action.getParameterValues();
actionParams.clear();
for (Map.Entry<String, Serializable> entry : this.parameters.entrySet())
{
// perform the conversion from script wrapper object to repo serializable values
String name = entry.getKey();
Serializable value = converter.convertActionParamForRepo(name, entry.getValue());
actionParams.put(name, value);
}
}
services.getActionService().executeAction(action, nodeRef);
}
/** /**
* Value converter with specific knowledge of action parameters * Value converter with specific knowledge of action parameters
* *

View File

@@ -534,7 +534,9 @@ public class ScriptNode implements Serializable, Scopeable
if (this.properties == null) if (this.properties == null)
{ {
// this Map implements the Scriptable interface for native JS syntax property access // this Map implements the Scriptable interface for native JS syntax property access
this.properties = new ScriptableQNameMap<String, Serializable>(this.services.getNamespaceService()); // this impl of the QNameMap is capable of creating ScriptContentData on demand for 'cm:content'
// properties that have not been initialised - see AR-1673.
this.properties = new ContentAwareScriptableQNameMap<String, Serializable>(this, this.services);
Map<QName, Serializable> props = this.nodeService.getProperties(this.nodeRef); Map<QName, Serializable> props = this.nodeService.getProperties(this.nodeRef);
for (QName qname : props.keySet()) for (QName qname : props.keySet())
@@ -542,7 +544,6 @@ public class ScriptNode implements Serializable, Scopeable
Serializable propValue = props.get(qname); Serializable propValue = props.get(qname);
// perform the conversion to a script safe value and store // perform the conversion to a script safe value and store
this.properties.put(qname.toString(), getValueConverter().convertValueForScript(qname, propValue)); this.properties.put(qname.toString(), getValueConverter().convertValueForScript(qname, propValue));
} }
} }
@@ -796,16 +797,11 @@ public class ScriptNode implements Serializable, Scopeable
public void setContent(String content) public void setContent(String content)
{ {
ScriptContentData contentData = (ScriptContentData)getProperties().get(ContentModel.PROP_CONTENT); ScriptContentData contentData = (ScriptContentData)getProperties().get(ContentModel.PROP_CONTENT);
if (contentData == null) if (contentData != null)
{ {
// guess a mimetype based on the filename
String mimetype = this.services.getMimetypeService().guessMimetype(getName());
ContentData cdata = new ContentData(null, mimetype, 0L, "UTF-8");
contentData = new ScriptContentData(cdata, ContentModel.PROP_CONTENT);
getProperties().put(ContentModel.PROP_CONTENT.toString(), contentData);
}
contentData.setContent(content); contentData.setContent(content);
} }
}
public void jsSet_content(String content) public void jsSet_content(String content)
{ {

View File

@@ -35,6 +35,9 @@ import org.apache.commons.logging.LogFactory;
/** /**
* Track and update when snapshots are created and indexed in a cluster * Track and update when snapshots are created and indexed in a cluster
*
* @author Andy Hind
* @since 2.1.0
*/ */
public class AVMRemoteSnapshotTracker extends AbstractReindexComponent public class AVMRemoteSnapshotTracker extends AbstractReindexComponent
{ {

View File

@@ -589,10 +589,7 @@ public abstract class AlfrescoTransactionSupport
} }
// These are still considered part of the transaction so are executed here // These are still considered part of the transaction so are executed here
for (TransactionListener listener : getListenersIterable()) doBeforeCommit(readOnly);
{
listener.beforeCommit(readOnly);
}
// Check integrity // Check integrity
for (IntegrityChecker integrityChecker : integrityCheckers) for (IntegrityChecker integrityChecker : integrityCheckers)
@@ -607,6 +604,39 @@ public abstract class AlfrescoTransactionSupport
} }
} }
/**
* Execute the beforeCommit event handlers for the registered listeners
*
* @param readOnly is read only
*/
private void doBeforeCommit(boolean readOnly)
{
doBeforeCommit(new HashSet<TransactionListener>(listeners.size()), readOnly);
}
/**
* Executes the beforeCommit event handlers for the outstanding listeners
*
* @param visitedListeners a set containing the already visited listeners
* @param readOnly is read only
*/
private void doBeforeCommit(Set<TransactionListener> visitedListeners, boolean readOnly)
{
Set<TransactionListener> pendingListeners = new HashSet<TransactionListener>(listeners);
pendingListeners.removeAll(visitedListeners);
if (pendingListeners.size() != 0)
{
for (TransactionListener listener : pendingListeners)
{
listener.beforeCommit(readOnly);
visitedListeners.add(listener);
}
doBeforeCommit(visitedListeners, readOnly);
}
}
@Override @Override
public void beforeCompletion() public void beforeCompletion()
{ {

View File

@@ -29,6 +29,7 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
@@ -42,6 +43,7 @@ import org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicy;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.MLText;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -107,6 +109,9 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
protected static final String MULTI_VALUE_1 = "multi1"; protected static final String MULTI_VALUE_1 = "multi1";
protected static final String MULTI_VALUE_2 = "multi2"; protected static final String MULTI_VALUE_2 = "multi2";
protected MLText mlText;
protected static final QName MLTEXT_PROP = QName.createQName(TEST_NAMESPACE, "propMl");
/** /**
* Test content * Test content
*/ */
@@ -172,6 +177,11 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
this.nodeProperties.put(MULTI_PROP, (Serializable)multiValue); this.nodeProperties.put(MULTI_PROP, (Serializable)multiValue);
this.nodeProperties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8")); this.nodeProperties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8"));
// Add mlText property
this.mlText = new MLText(Locale.UK, "UK value");
this.mlText.addValue(Locale.US, "Y'all US value");
this.nodeProperties.put(MLTEXT_PROP, this.mlText);
// Create a workspace that contains the 'live' nodes // Create a workspace that contains the 'live' nodes
this.testStoreRef = this.dbNodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.testStoreRef = this.dbNodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());

View File

@@ -146,6 +146,9 @@ public class NodeServiceImplTest extends BaseVersionStoreTest
PROP_1); PROP_1);
assertEquals(VALUE_1, value1); assertEquals(VALUE_1, value1);
// Check the mlText property
// TODO
// Check the multi values property specifically // Check the multi values property specifically
Collection<String> multiValue = (Collection<String>)this.lightWeightVersionStoreNodeService.getProperty(version.getFrozenStateNodeRef(), MULTI_PROP); Collection<String> multiValue = (Collection<String>)this.lightWeightVersionStoreNodeService.getProperty(version.getFrozenStateNodeRef(), MULTI_PROP);
assertNotNull(multiValue); assertNotNull(multiValue);

View File

@@ -37,6 +37,11 @@
<protected>false</protected> <protected>false</protected>
<default></default> <default></default>
</property> </property>
<property name="test:propMl">
<type>d:mltext</type>
<protected>false</protected>
<default></default>
</property>
<property name="test:multiProp"> <property name="test:multiProp">
<type>d:text</type> <type>d:text</type>
<multiple>true</multiple> <multiple>true</multiple>

View File

@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.repo.node.MLPropertyInterceptor;
import org.alfresco.repo.policy.ClassPolicyDelegate; import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.PolicyScope; import org.alfresco.repo.policy.PolicyScope;
@@ -230,6 +231,9 @@ public abstract class AbstractVersionServiceImpl
{ {
ClassDefinition classDefinition = this.dictionaryService.getClass(classRef); ClassDefinition classDefinition = this.dictionaryService.getClass(classRef);
if (classDefinition != null) if (classDefinition != null)
{
boolean wasMLAware = MLPropertyInterceptor.setMLAware(true);
try
{ {
// Copy the properties // Copy the properties
Map<QName,PropertyDefinition> propertyDefinitions = classDefinition.getProperties(); Map<QName,PropertyDefinition> propertyDefinitions = classDefinition.getProperties();
@@ -238,6 +242,11 @@ public abstract class AbstractVersionServiceImpl
Serializable propValue = this.nodeService.getProperty(nodeRef, propertyName); Serializable propValue = this.nodeService.getProperty(nodeRef, propertyName);
nodeDetails.addProperty(classRef, propertyName, propValue); nodeDetails.addProperty(classRef, propertyName, propValue);
} }
}
finally
{
MLPropertyInterceptor.setMLAware(wasMLAware);
}
// Version the associations (child and target) // Version the associations (child and target)
Map<QName, AssociationDefinition> assocDefs = classDefinition.getAssociations(); Map<QName, AssociationDefinition> assocDefs = classDefinition.getAssociations();

View File

@@ -324,8 +324,6 @@ public interface AVMService
*/ */
public OutputStream createFile(String path, String name); public OutputStream createFile(String path, String name);
/** /**
* Create a new "plain" (non-layered) file. * Create a new "plain" (non-layered) file.
* Guarantees that the entire contents of the * Guarantees that the entire contents of the
@@ -342,6 +340,23 @@ public interface AVMService
public void createFile(String path, String name, InputStream in); public void createFile(String path, String name, InputStream in);
/**
* Create a new "plain" (non-layered) file.
* Guarantees that the entire contents of the
* input stream will be loaded atomically.
* The directory identified by <code>path</code> must already exist.
*
* @param path The path of the directory containing the created file.
* @param name The name of the new file
* @param in An input stream with data for the file.
* @param aspect A list of aspects to give the file.
* @param properties A map of properties to give the file.
* @throws AVMNotFound
* @throws AVMExists
* @throws AVMWrongType
*/
public void createFile(String path, String name, InputStream in, List<QName> aspects, Map<QName, PropertyValue> properties);
/** /**
* Create a new directory. * Create a new directory.
* If <code>path</code> is within a layer, the new directory will be a layered directory; * If <code>path</code> is within a layer, the new directory will be a layered directory;
@@ -355,6 +370,20 @@ public interface AVMService
*/ */
public void createDirectory(String path, String name); public void createDirectory(String path, String name);
/**
* Create a new directory.
* If <code>path</code> is within a layer, the new directory will be a layered directory;
* otherwise, the new directory will be a plain directory.
*
* @param path The simple absolute path to the parent.
* @param name The name to give the directory.
* @param aspects A list of aspects to add.
* @param properties A Map of properties to add.
* @throws AVMNotFound
* @throws AVMExists
* @throws AVMWrongType
*/
public void createDirectory(String path, String name, List<QName> aspects, Map<QName, PropertyValue> properties);
/** /**
* Create a new layered file. * Create a new layered file.