Merged V3.1 to HEAD

13853: Merged V3.0 to V3.1
      13008: Merged V2.2 to V3.0
         12824: (record only) Change admin access to the web project staging store to be read-only in the virtualization view - ETWOTWO-933
      13031: (Record only) AMP fix for ETWOTWO-968: Space rules are not run when saving from MS Word
      13040: Merged V2.2 to V3.0
         12824: (record-only) - already done via r13005 (ETWOTWO-933)
      13145: Merged V2.2 to V3.0:
         13089: (record-only) Fix "Read-Write transaction started within read-only transaction" exception. ETWOTWO-1055.
         13091: (record-only) Fix for NFS server "Read-Write transaction started within read-only transaction" exception. ETWOTWO-1054.
      13508: ETHREEOH-1548 - allow config to reset (even if null/cache)
      13514: ETHREEOH-1548 (follow-on fix) - to allow config to reset (even if null/cache) and also reduce 5 caches to 1
      13848: Merged V2.2 to V3.0
         13188: *RECORD ONLY* Using correct ooo startup context - does not work for *nix.  Fixed in 3.0sp1
         13212: *RECORD ONLY* AMP for ETWOTWO-984
         13342: *RECORD ONLY* Merge info stuff
         13435: Merged V2.1 to V2.2
            12307: Merged DEV/V2.1SP7 to 2.1
               11927: ETWOONE-396
               12112: ETWOONE-396
         13442: *RECORD ONLY* Updated version to 2.2.4dev
         13468: *RECORD ONLY* Removed svn:mergeinfo crud
         13470: I18NUtil doesn't cause NPE if message key doesn't exist
         13471: Fixed ETWOTWO-1133: Incorrect CRC32 Values for non-ASCII names
         13475: Test fix: I18NUtil.getMessage() no longer returns null, leading to NPEs if message bundle is missing
         13476: Reverted back to null return values.  Will save for fixing on HEAD.
         13749: Fixed ALFCOM-2655: MLTranslationInterceptor doesn't handle getType method
         13803: ETWOTWO-710
         13819: *RECORD ONLY* ACT-6420 - Office 2003 "Install for all users" - DO NOT MERGE
         13827: ETWOTWO-1172 - authority exists now checks nodeRef result
   ___________________________________________________________________
   Modified: svn:mergeinfo
      Merged /alfresco/BRANCHES/V3.0:r12824,13008,13031,13040,13089,13091,13145,13848
      Merged /alfresco/BRANCHES/V2.2:r12824,13188,13212,13342,13442,13468,13470-13471,13475-13476,13749,13803,13827
      Merged /alfresco/BRANCHES/V3.1:r13853


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14763 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-06-17 12:28:56 +00:00
parent e3df62325d
commit 3a5c120bbe
19 changed files with 608 additions and 30 deletions

View File

@@ -278,3 +278,6 @@ patch.authorityMigration.result=Migrated {0} authorities to the spaces store.
patch.authorityDefaultZonesPatch.description=Adds groups and people to the appropriate zones for wcm, share and everything else. patch.authorityDefaultZonesPatch.description=Adds groups and people to the appropriate zones for wcm, share and everything else.
patch.authorityDefaultZonesPatch.result=Unzoned groups and people added to the default zones. patch.authorityDefaultZonesPatch.result=Unzoned groups and people added to the default zones.
patch.fixNameCrcValues.description=Fixes name CRC32 values to match UTF-8 encoding.
patch.fixNameCrcValues.result=Fixed {0} name CRC32 values for UTF-8 encoding. See file {1} for details.
patch.fixNameCrcValues.fixed=Updated CRC32 value for node ID {0}, name ''{1}'': {2} -> {3}.

View File

@@ -1646,8 +1646,8 @@
<ref bean="versionCounterService" /> <ref bean="versionCounterService" />
</property> </property>
</bean> </bean>
<bean id="patch.db-V2.2-Person-2" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch"> <bean id="patch.db-V2.2-Person-2" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V2.2-Person-2</value></property> <property name="id"><value>patch.db-V2.2-Person-2</value></property>
<property name="description"><value>patch.schemaUpgradeScript.description</value></property> <property name="description"><value>patch.schemaUpgradeScript.description</value></property>
<property name="fixesFromSchema"><value>0</value></property> <property name="fixesFromSchema"><value>0</value></property>
@@ -1833,4 +1833,28 @@
</property> </property>
</bean> </bean>
<bean id="patch.fixNameCrcValues" class="org.alfresco.repo.admin.patch.impl.FixNameCrcValuesPatch" parent="basePatch" >
<property name="id"><value>patch.fixNameCrcValues</value></property>
<property name="description"><value>patch.fixNameCrcValues.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>2014</value></property>
<property name="targetSchema"><value>2015</value></property>
<property name="dependsOn" >
<list>
<ref bean="patch.uniqueChildName" />
<ref bean="patch.InvalidNameEnding" />
</list>
</property>
<!-- helper beans -->
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
<property name="nodeDaoService">
<ref bean="nodeDaoService" />
</property>
<property name="qnameDAO">
<ref bean="qnameDAO" />
</property>
</bean>
</beans> </beans>

View File

@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number # Schema number
version.schema=2014 version.schema=2015

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -29,6 +29,7 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.jcr.RepositoryException; import javax.jcr.RepositoryException;
import javax.jcr.Value; import javax.jcr.Value;
@@ -376,7 +377,15 @@ public class JCRDocumentXMLExporter implements Exporter
public void endReference(NodeRef nodeRef) public void endReference(NodeRef nodeRef)
{ {
} }
public void endValueMLText(NodeRef nodeRef)
{
}
public void startValueMLText(NodeRef nodeRef, Locale locale)
{
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String) * @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -26,6 +26,7 @@ package org.alfresco.jcr.exporter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Locale;
import javax.jcr.PropertyType; import javax.jcr.PropertyType;
import javax.jcr.RepositoryException; import javax.jcr.RepositoryException;
@@ -436,7 +437,15 @@ public class JCRSystemXMLExporter implements Exporter
public void endReference(NodeRef nodeRef) public void endReference(NodeRef nodeRef)
{ {
} }
public void endValueMLText(NodeRef nodeRef)
{
}
public void startValueMLText(NodeRef nodeRef, Locale locale)
{
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String) * @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
*/ */

View File

@@ -0,0 +1,293 @@
/*
* Copyright (C) 2005-2009 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.admin.patch.impl;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.zip.CRC32;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.domain.ChildAssoc;
import org.alfresco.repo.domain.Node;
import org.alfresco.repo.domain.QNameDAO;
import org.alfresco.repo.domain.hibernate.ChildAssocImpl;
import org.alfresco.repo.node.db.NodeDaoService;
import org.alfresco.service.cmr.admin.PatchException;
import org.hibernate.SQLQuery;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.type.LongType;
import org.hibernate.type.StringType;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Fixes <a href=https://issues.alfresco.com/jira/browse/ETWOTWO-1133>ETWOTWO-1133</a>.
* Checks all CRC values for <b>alf_child_assoc.child_node_name_crc</b>.
*
* @author Derek Hulley
* @since V2.2SP4
*/
public class FixNameCrcValuesPatch extends AbstractPatch
{
private static final String MSG_SUCCESS = "patch.fixNameCrcValues.result";
private static final String MSG_REWRITTEN = "patch.fixNameCrcValues.fixed";
private SessionFactory sessionFactory;
private NodeDaoService nodeDaoService;
private QNameDAO qnameDAO;
public FixNameCrcValuesPatch()
{
}
public void setSessionFactory(SessionFactory sessionFactory)
{
this.sessionFactory = sessionFactory;
}
/**
* @param nodeDaoService The service that generates the CRC values
*/
public void setNodeDaoService(NodeDaoService nodeDaoService)
{
this.nodeDaoService = nodeDaoService;
}
/**
* @param qnameDAO resolved QNames
*/
public void setQnameDAO(QNameDAO qnameDAO)
{
this.qnameDAO = qnameDAO;
}
@Override
protected void checkProperties()
{
super.checkProperties();
checkPropertyNotNull(sessionFactory, "sessionFactory");
checkPropertyNotNull(nodeDaoService, "nodeDaoService");
checkPropertyNotNull(qnameDAO, "qnameDAO");
}
@Override
protected String applyInternal() throws Exception
{
// initialise the helper
HibernateHelper helper = new HibernateHelper();
helper.setSessionFactory(sessionFactory);
try
{
String msg = helper.fixCrcValues();
// done
return msg;
}
finally
{
helper.closeWriter();
}
}
private class HibernateHelper extends HibernateDaoSupport
{
private File logFile;
private FileChannel channel;
private HibernateHelper() throws IOException
{
logFile = new File("./FixNameCrcValuesPatch.log");
// open the file for appending
RandomAccessFile outputFile = new RandomAccessFile(logFile, "rw");
channel = outputFile.getChannel();
// move to the end of the file
channel.position(channel.size());
// add a newline and it's ready
writeLine("").writeLine("");
writeLine("FixNameCrcValuesPatch executing on " + new Date());
}
private HibernateHelper write(Object obj) throws IOException
{
channel.write(ByteBuffer.wrap(obj.toString().getBytes("UTF-8")));
return this;
}
private HibernateHelper writeLine(Object obj) throws IOException
{
write(obj);
write("\n");
return this;
}
private void closeWriter()
{
try { channel.close(); } catch (Throwable e) {}
}
public String fixCrcValues() throws Exception
{
// get the association types to check
@SuppressWarnings("unused")
List<Long> childAssocIds = findMismatchedCrcs();
int updated = 0;
for (Long childAssocId : childAssocIds)
{
ChildAssoc assoc = (ChildAssoc) getHibernateTemplate().get(ChildAssocImpl.class, childAssocId);
if (assoc == null)
{
// Missing now ...
continue;
}
// Get the old CRC
long oldCrc = assoc.getChildNodeNameCrc();
// Get the child node
Node childNode = assoc.getChild();
// Get the name
String childName = (String) nodeDaoService.getNodeProperty(childNode.getId(), ContentModel.PROP_NAME);
if (childName == null)
{
childName = childNode.getUuid();
}
// Update the CRC
long crc = getCrc(childName);
// Update the assoc
assoc.setChildNodeNameCrc(crc);
// Persist
updated++;
getSession().flush();
getSession().clear();
// Record
writeLine(I18NUtil.getMessage(MSG_REWRITTEN, childNode.getId(), childName, oldCrc, crc));
}
String msg = I18NUtil.getMessage(MSG_SUCCESS, updated, logFile);
return msg;
}
@SuppressWarnings("unchecked")
private List<Long> findMismatchedCrcs() throws Exception
{
final Long qnameId = qnameDAO.getOrCreateQName(ContentModel.PROP_NAME).getFirst();
final List<Long> childAssocIds = new ArrayList<Long>(1000);
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
SQLQuery query = session
.createSQLQuery(
" SELECT " +
" ca.id AS child_assoc_id," +
" ca.child_node_name_crc AS child_assoc_crc," +
" np.string_value AS node_name," +
" n.uuid as node_uuid" +
" FROM" +
" alf_child_assoc ca" +
" JOIN alf_node n ON (ca.child_node_id = n.id AND ca.child_node_name_crc > 0)" +
" JOIN alf_node_properties np on (np.node_id = n.id AND np.qname_id = :qnameId)" +
"");
query.setLong("qnameId", qnameId);
query.addScalar("child_assoc_id", new LongType());
query.addScalar("child_assoc_crc", new LongType());
query.addScalar("node_name", new StringType());
query.addScalar("node_uuid", new StringType());
return query.scroll(ScrollMode.FORWARD_ONLY);
}
};
ScrollableResults rs = null;
try
{
rs = (ScrollableResults) getHibernateTemplate().execute(callback);
while (rs.next())
{
Long assocId = (Long) rs.get(0);
Long dbCrc = (Long) rs.get(1);
String name = (String) rs.get(2);
String uuid = (String) rs.get(3);
long utf8Crc = -1L;
if (name != null)
{
utf8Crc = getCrc(name);
}
else
{
utf8Crc = getCrc(uuid);
}
// Check
if (dbCrc != null && utf8Crc == dbCrc.longValue())
{
// It is a match, so ignore
continue;
}
childAssocIds.add(assocId);
}
}
catch (Throwable e)
{
logger.error("Failed to query for child name CRCs", e);
writeLine("Failed to query for child name CRCs: " + e.getMessage());
throw new PatchException("Failed to query for child name CRCs", e);
}
finally
{
if (rs != null)
{
try { rs.close(); } catch (Throwable e) { writeLine("Failed to close resultset: " + e.getMessage()); }
}
}
return childAssocIds;
}
/**
* @param str the name that will be converted to lowercase
* @return the CRC32 calcualted on the lowercase version of the string
*/
private long getCrc(String str)
{
CRC32 crc = new CRC32();
try
{
crc.update(str.toLowerCase().getBytes("UTF-8")); // https://issues.alfresco.com/jira/browse/ALFCOM-1335
}
catch (UnsupportedEncodingException e)
{
throw new RuntimeException("UTF-8 encoding is not supported");
}
return crc.getValue();
}
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -27,6 +27,7 @@ package org.alfresco.repo.exporter;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -350,7 +351,23 @@ import org.alfresco.service.namespace.QName;
exporter.endReference(nodeRef); exporter.endReference(nodeRef);
} }
} }
public void startValueMLText(NodeRef nodeRef, Locale locale)
{
for (Exporter exporter : exporters)
{
exporter.startValueMLText(nodeRef, locale);
}
}
public void endValueMLText(NodeRef nodeRef)
{
for (Exporter exporter : exporters)
{
exporter.endValueMLText(nodeRef);
}
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String) * @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -34,10 +34,12 @@ import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.MLPropertyInterceptor;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.PropertyDefinition;
@@ -46,6 +48,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
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.Path; import org.alfresco.service.cmr.repository.Path;
@@ -427,7 +430,9 @@ public class ExporterComponent
// Export node properties // Export node properties
exporter.startProperties(nodeRef); exporter.startProperties(nodeRef);
boolean aware = MLPropertyInterceptor.setMLAware(true);
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef); Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
MLPropertyInterceptor.setMLAware(aware);
for (QName property : properties.keySet()) for (QName property : properties.keySet())
{ {
// filter out properties whose namespace is excluded // filter out properties whose namespace is excluded
@@ -459,7 +464,27 @@ public class ExporterComponent
} }
else else
{ {
walkProperty(nodeRef, property, value, -1, parameters, exporter); if (value instanceof MLText)
{
MLText valueMLT = (MLText) value;
Set<Locale> locales = valueMLT.getLocales();
for (Locale locale : locales)
{
String localeValue = valueMLT.getValue(locale);
if (localeValue == null)
{
walkProperty(nodeRef, property, localeValue, -1, parameters, exporter);
continue;
}
exporter.startValueMLText(nodeRef, locale);
walkProperty(nodeRef, property, localeValue, -1, parameters, exporter);
exporter.endValueMLText(nodeRef);
}
}
else
{
walkProperty(nodeRef, property, value, -1, parameters, exporter);
}
} }
// end export of property // end export of property

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -28,7 +28,9 @@ import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Locale;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
@@ -96,7 +98,10 @@ public class ExporterComponentTest extends BaseSpringTest
InputStream test = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml"); InputStream test = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml");
InputStreamReader testReader = new InputStreamReader(test, "UTF-8"); InputStreamReader testReader = new InputStreamReader(test, "UTF-8");
importerService.importView(testReader, location, null, null); importerService.importView(testReader, location, null, null);
System.out.println(NodeStoreInspector.dumpNodeStore((NodeService)applicationContext.getBean("NodeService"), storeRef));
dumpNodeStore(Locale.ENGLISH);
dumpNodeStore(Locale.FRENCH);
dumpNodeStore(Locale.GERMAN);
// now export // now export
location.setPath("/system"); location.setPath("/system");
@@ -108,6 +113,13 @@ public class ExporterComponentTest extends BaseSpringTest
output.close(); output.close();
} }
private void dumpNodeStore(Locale locale)
{
System.out.println(locale.getDisplayLanguage() + " LOCALE: ");
I18NUtil.setLocale(locale);
System.out.println(NodeStoreInspector.dumpNodeStore((NodeService) applicationContext.getBean("NodeService"), storeRef));
}
private static class TestProgress private static class TestProgress
implements Exporter implements Exporter
@@ -253,6 +265,16 @@ public class ExporterComponentTest extends BaseSpringTest
// System.out.println("TestProgress: endReference: " + nodeRef); // System.out.println("TestProgress: endReference: " + nodeRef);
} }
public void endValueMLText(NodeRef nodeRef)
{
System.out.println("TestProgress: end MLValue.");
}
public void startValueMLText(NodeRef nodeRef, Locale locale)
{
System.out.println("TestProgress: start MLValue for locale: " + locale);
}
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -25,6 +25,7 @@
package org.alfresco.repo.exporter; package org.alfresco.repo.exporter;
import java.io.InputStream; import java.io.InputStream;
import java.util.Locale;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -276,6 +277,16 @@ import org.alfresco.util.ParameterCheck;
exporter.endReference(nodeRef); exporter.endReference(nodeRef);
} }
public void startValueMLText(NodeRef nodeRef, Locale locale)
{
exporter.startValueMLText(nodeRef, locale);
}
public void endValueMLText(NodeRef nodeRef)
{
exporter.endValueMLText(nodeRef);
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String) * @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -26,6 +26,7 @@ package org.alfresco.repo.exporter;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.Locale;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
@@ -74,6 +75,8 @@ import org.xml.sax.helpers.AttributesImpl;
private static final String EXPORTEDDATE_LOCALNAME = "exportDate"; private static final String EXPORTEDDATE_LOCALNAME = "exportDate";
private static final String EXPORTERVERSION_LOCALNAME = "exporterVersion"; private static final String EXPORTERVERSION_LOCALNAME = "exporterVersion";
private static final String EXPORTOF_LOCALNAME = "exportOf"; private static final String EXPORTOF_LOCALNAME = "exportOf";
private static final String MLVALUE_LOCALNAME = "mlvalue";
private static final String LOCALE_LOCALNAME = "locale";
private static final String ACL_LOCALNAME = "acl"; private static final String ACL_LOCALNAME = "acl";
private static final String ACE_LOCALNAME = "ace"; private static final String ACE_LOCALNAME = "ace";
private static final String ACCESS_LOCALNAME = "access"; private static final String ACCESS_LOCALNAME = "access";
@@ -106,6 +109,8 @@ import org.xml.sax.helpers.AttributesImpl;
private static QName REFERENCE_QNAME; private static QName REFERENCE_QNAME;
private static QName PATHREF_QNAME; private static QName PATHREF_QNAME;
private static QName NODEREF_QNAME; private static QName NODEREF_QNAME;
private static QName LOCALE_QNAME;
private static QName MLVALUE_QNAME;
private static final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl(); private static final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl();
// Service dependencies // Service dependencies
@@ -164,6 +169,9 @@ import org.xml.sax.helpers.AttributesImpl;
REFERENCE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, REFERENCE_LOCALNAME, namespaceService); REFERENCE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, REFERENCE_LOCALNAME, namespaceService);
PATHREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PATHREF_LOCALNAME, namespaceService); PATHREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PATHREF_LOCALNAME, namespaceService);
NODEREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, NODEREF_LOCALNAME, namespaceService); NODEREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, NODEREF_LOCALNAME, namespaceService);
LOCALE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, LOCALE_LOCALNAME, namespaceService);
MLVALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, MLVALUE_LOCALNAME, namespaceService);
} }
@@ -718,7 +726,34 @@ import org.xml.sax.helpers.AttributesImpl;
throw new ExporterException("Failed to process end reference", e); throw new ExporterException("Failed to process end reference", e);
} }
} }
public void startValueMLText(NodeRef nodeRef, Locale locale)
{
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute(NamespaceService.REPOSITORY_VIEW_PREFIX, LOCALE_LOCALNAME, LOCALE_QNAME.toPrefixString(), null, locale.toString());
try
{
contentHandler.startElement(NamespaceService.REPOSITORY_VIEW_PREFIX, MLVALUE_LOCALNAME, MLVALUE_QNAME.toPrefixString(), attrs);
}
catch (SAXException e)
{
throw new ExporterException("Failed to process start mlvalue", e);
}
}
public void endValueMLText(NodeRef nodeRef)
{
try
{
contentHandler.endElement(NamespaceService.REPOSITORY_VIEW_PREFIX, MLVALUE_LOCALNAME, MLVALUE_QNAME.toPrefixString());
}
catch (SAXException e)
{
throw new ExporterException("Failed to process end mltext", e);
}
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String) * @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -945,7 +945,7 @@ public class ImporterComponent
if (value instanceof Collection) if (value instanceof Collection)
{ {
List<Serializable> boundCollection = new ArrayList<Serializable>(); List<Serializable> boundCollection = new ArrayList<Serializable>();
for (String collectionValue : (Collection<String>)value) for (Serializable collectionValue : (Collection<Serializable>)value)
{ {
Serializable objValue = bindValue(context, property, valueDataType, collectionValue); Serializable objValue = bindValue(context, property, valueDataType, collectionValue);
boundCollection.add(objValue); boundCollection.add(objValue);
@@ -954,7 +954,7 @@ public class ImporterComponent
} }
else else
{ {
value = bindValue(context, property, valueDataType, (String)value); value = bindValue(context, property, valueDataType, value);
} }
// choose to provide property on node creation or at end of import for lazy binding // choose to provide property on node creation or at end of import for lazy binding
@@ -1002,19 +1002,22 @@ public class ImporterComponent
* @param value string form of value * @param value string form of value
* @return the bound value * @return the bound value
*/ */
private Serializable bindValue(ImportNode context, QName property, DataTypeDefinition valueType, String value) private Serializable bindValue(ImportNode context, QName property, DataTypeDefinition valueType, Serializable value)
{ {
Serializable objValue = null; Serializable objValue = null;
if (value != null && valueType != null) if (value != null && valueType != null)
{ {
String strValue = bindPlaceHolder(value, binding); if (value instanceof String)
{
value = bindPlaceHolder(value.toString(), binding);
}
if ((valueType.getName().equals(DataTypeDefinition.NODE_REF) || valueType.getName().equals(DataTypeDefinition.CATEGORY))) if ((valueType.getName().equals(DataTypeDefinition.NODE_REF) || valueType.getName().equals(DataTypeDefinition.CATEGORY)))
{ {
objValue = strValue; objValue = value;
} }
else else
{ {
objValue = (Serializable)DefaultTypeConverter.INSTANCE.convert(valueType, strValue); objValue = (Serializable) DefaultTypeConverter.INSTANCE.convert(valueType, value);
} }
} }

View File

@@ -77,11 +77,32 @@
<cm:name>Some content</cm:name> <cm:name>Some content</cm:name>
<cm:content>contentUrl=classpath:org/alfresco/repo/importer/importercomponent_testfile.txt|mimetype=text|size=|encoding=</cm:content> <cm:content>contentUrl=classpath:org/alfresco/repo/importer/importercomponent_testfile.txt|mimetype=text|size=|encoding=</cm:content>
</cm:content> </cm:content>
<cm:folder view:id="ML Text">
<view:aspects>
<cm:auditable/>
</view:aspects>
<view:properties>
<cm:name>ML Text</cm:name>
<cm:title>
<view:mlvalue view:locale="fr_FR">FR_TITLE</view:mlvalue>
<view:mlvalue view:locale="de_DE">GE_TITLE</view:mlvalue>
<view:mlvalue view:locale="en_US">ENG_TITLE</view:mlvalue>
</cm:title>
<cm:description>
<view:mlvalue view:locale="fr_FR">FR_DESCRIPTION</view:mlvalue>
<view:mlvalue view:locale="de_DE">GE_DESCRIPTION</view:mlvalue>
<view:mlvalue view:locale="en_US">ENG_DESCRIPTION</view:mlvalue>
</cm:description>
</view:properties>
</cm:folder>
<view:reference view:idref="the root system folder"> <view:reference view:idref="the root system folder">
<view:associations> <view:associations>
<cm:contains> <cm:contains>
<view:reference view:idref="some content" view:childName="link to some content"/> <view:reference view:idref="some content" view:childName="link to some content"/>
<view:reference view:idref="ML Text" view:childName="link to ML Text"/>
</cm:contains> </cm:contains>
</view:associations> </view:associations>
</view:reference> </view:reference>

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -247,7 +247,7 @@ public class NodeContext extends ElementContext
* @param property the property name * @param property the property name
* @param value the property value * @param value the property value
*/ */
public void addProperty(QName property, String value) public void addProperty(QName property, Serializable value)
{ {
// Process "special" properties // Process "special" properties
// TODO: Make this configurable... // TODO: Make this configurable...
@@ -256,7 +256,7 @@ public class NodeContext extends ElementContext
// Process Alfresco UUID // Process Alfresco UUID
if (uuid == null && propDef != null && propDef.getName().equals(ContentModel.PROP_NODE_UUID)) if (uuid == null && propDef != null && propDef.getName().equals(ContentModel.PROP_NODE_UUID))
{ {
uuid = value; uuid = value.toString();
} }
// Do not import properties of sys:referenceable or cm:versionable // Do not import properties of sys:referenceable or cm:versionable

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -26,7 +26,9 @@ package org.alfresco.repo.importer.view;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
@@ -35,11 +37,14 @@ import org.alfresco.repo.importer.Importer;
import org.alfresco.repo.importer.Parser; import org.alfresco.repo.importer.Parser;
import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
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.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.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.view.ImporterException; import org.alfresco.service.cmr.view.ImporterException;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
@@ -71,6 +76,7 @@ public class ViewParser implements Parser
private static final String VIEW_IDREF_ATTR = "idref"; private static final String VIEW_IDREF_ATTR = "idref";
private static final String VIEW_PATHREF_ATTR = "pathref"; private static final String VIEW_PATHREF_ATTR = "pathref";
private static final String VIEW_NODEREF_ATTR = "noderef"; private static final String VIEW_NODEREF_ATTR = "noderef";
private static final String VIEW_LOCALE_ATTR = "locale";
private static final QName VIEW_METADATA = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "metadata"); private static final QName VIEW_METADATA = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "metadata");
private static final QName VIEW_VALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "value"); private static final QName VIEW_VALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "value");
private static final QName VIEW_VALUES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "values"); private static final QName VIEW_VALUES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "values");
@@ -82,7 +88,7 @@ public class ViewParser implements Parser
private static final QName VIEW_AUTHORITY = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "authority"); private static final QName VIEW_AUTHORITY = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "authority");
private static final QName VIEW_PERMISSION = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "permission"); private static final QName VIEW_PERMISSION = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "permission");
private static final QName VIEW_REFERENCE = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "reference"); private static final QName VIEW_REFERENCE = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "reference");
private static final QName VIEW_ML_VALUE = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "mlvalue");
// XML Pull Parser Factory // XML Pull Parser Factory
private XmlPullParserFactory factory; private XmlPullParserFactory factory;
@@ -670,6 +676,7 @@ public class ViewParser implements Parser
{ {
// Extract collection, if specified // Extract collection, if specified
boolean isCollection = false; boolean isCollection = false;
boolean isMLProperty = false;
if (eventType == XmlPullParser.START_TAG) if (eventType == XmlPullParser.START_TAG)
{ {
QName name = getName(xpp); QName name = getName(xpp);
@@ -683,6 +690,66 @@ public class ViewParser implements Parser
eventType = xpp.next(); eventType = xpp.next();
} }
} }
else if (name.equals(VIEW_ML_VALUE))
{
isMLProperty = true;
}
}
// Extract ML value
if (isMLProperty)
{
if (logger.isDebugEnabled())
{
logger.debug("Start parsing MLValue for property: " + propertyName);
}
value = "";
String locale = "";
node.addDatatype(propertyName, dictionaryService.getDataType(DataTypeDefinition.MLTEXT));
MLText mlText = new MLText();
while (isMLProperty)
{
isMLProperty = false;
locale = xpp.getAttributeValue(NamespaceService.REPOSITORY_VIEW_1_0_URI, VIEW_LOCALE_ATTR);
eventType = xpp.next();
if (eventType == XmlPullParser.TEXT)
{
value = xpp.getText();
eventType = xpp.next();
}
if (eventType == XmlPullParser.END_TAG)
{
if (logger.isDebugEnabled())
{
logger.debug("Found ML entry: " + locale + "=" + value);
}
mlText.addValue(DefaultTypeConverter.INSTANCE.convert(Locale.class, locale), value);
eventType = xpp.next();
if (eventType == XmlPullParser.TEXT)
{
eventType = xpp.next();
}
}
if (eventType == XmlPullParser.START_TAG)
{
QName name = getName(xpp);
if (name.equals(VIEW_ML_VALUE))
{
isMLProperty = true;
}
}
}
if (logger.isDebugEnabled())
{
logger.debug("End parsing MLValue for property: " + propertyName);
}
node.addProperty(propertyName, mlText);
} }
// Extract decorated value // Extract decorated value

View File

@@ -29,12 +29,14 @@ import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.dictionary.DictionaryDAO; import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Model; import org.alfresco.repo.dictionary.M2Model;
@@ -44,6 +46,7 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.model.FileExistsException; import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileFolderServiceType;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException; import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
@@ -651,4 +654,14 @@ public class FileFolderServiceImplTest extends TestCase
assertNotNull("Long filename not found", fileNodeRef); assertNotNull("Long filename not found", fileNodeRef);
assertEquals(fileInfo.getNodeRef(), fileNodeRef); assertEquals(fileInfo.getNodeRef(), fileNodeRef);
} }
/**
* Validates <a href="https://issues.alfresco.com/jira/browse/ALFCOM-2655">ACT-7225</a>
*/
public void testGetType() throws Exception
{
I18NUtil.setContentLocale(Locale.CANADA);
FileFolderServiceType type = fileFolderService.getType(ContentModel.TYPE_FOLDER);
assertEquals("Type incorrect for folder", FileFolderServiceType.FOLDER, type);
}
} }

View File

@@ -91,6 +91,7 @@ public class MLTranslationInterceptor implements MethodInterceptor
METHOD_NAMES_OTHER.add("delete"); METHOD_NAMES_OTHER.add("delete");
METHOD_NAMES_OTHER.add("getReader"); METHOD_NAMES_OTHER.add("getReader");
METHOD_NAMES_OTHER.add("getWriter"); METHOD_NAMES_OTHER.add("getWriter");
METHOD_NAMES_OTHER.add("getType");
} }
private static Log logger = LogFactory.getLog(MLTranslationInterceptor.class); private static Log logger = LogFactory.getLog(MLTranslationInterceptor.class);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -25,6 +25,7 @@
package org.alfresco.service.cmr.view; package org.alfresco.service.cmr.view;
import java.io.InputStream; import java.io.InputStream;
import java.util.Locale;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -178,6 +179,21 @@ public interface Exporter
*/ */
public void startValueCollection(NodeRef nodeRef, QName property); public void startValueCollection(NodeRef nodeRef, QName property);
/**
* Start export MLText
*
* @param nodeRef the node reference
* @param locale
*/
public void startValueMLText(NodeRef nodeRef, Locale locale);
/**
* End export MLText
*
* @param nodeRef
*/
public void endValueMLText(NodeRef nodeRef);
/** /**
* Export property value * Export property value
* *

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -26,6 +26,7 @@ package org.alfresco.tools;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.Locale;
import org.alfresco.repo.exporter.ACPExportPackageHandler; import org.alfresco.repo.exporter.ACPExportPackageHandler;
import org.alfresco.repo.exporter.FileExportPackageHandler; import org.alfresco.repo.exporter.FileExportPackageHandler;
@@ -645,6 +646,14 @@ public final class Export extends Tool
public void endReference(NodeRef nodeRef) public void endReference(NodeRef nodeRef)
{ {
} }
public void endValueMLText(NodeRef nodeRef)
{
}
public void startValueMLText(NodeRef nodeRef, Locale locale)
{
}
} }
} }