svn merge -r 2570:2595 svn://www.alfresco.org/alfresco/BRANCHES/V1.2.0/root HEAD/root

svn merge -r 2597:2649 svn://www.alfresco.org/alfresco/BRANCHES/V1.2.0/root HEAD/root


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2650 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-04-12 14:58:21 +00:00
parent c3adde8ac4
commit 776314da72
17 changed files with 469 additions and 63 deletions

View File

@@ -277,7 +277,7 @@ public abstract class AbstractPatch implements Patch
{
if (value == null)
{
throw new PatchException(ERR_PROPERTY_NOT_SET, "bootstrapView", this);
throw new PatchException(ERR_PROPERTY_NOT_SET, name, this);
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.admin.patch.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
/**
* Apply Version Edition to Repository Descriptor
*
* @author David Caruana
*/
public class DescriptorUpdatePatch extends AbstractPatch
{
private static final String MSG_SUCCESS = "patch.descriptorUpdate.result";
private ImporterBootstrap systemBootstrap;
public void setSystemBootstrap(ImporterBootstrap systemBootstrap)
{
this.systemBootstrap = systemBootstrap;
}
@Override
protected String applyInternal() throws Exception
{
checkPropertyNotNull(systemBootstrap, "systemBootstrap");
// retrieve system descriptor location
StoreRef storeRef = systemBootstrap.getStoreRef();
Properties systemProperties = systemBootstrap.getConfiguration();
// check for the store
if (nodeService.exists(storeRef))
{
// get the current descriptor
String path = systemProperties.getProperty("system.descriptor.current.childname");
String searchPath = "/" + path;
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
List<NodeRef> nodeRefs = searchService.selectNodes(rootNodeRef, searchPath, null, namespaceService, false);
if (nodeRefs.size() > 0)
{
NodeRef descriptorNodeRef = nodeRefs.get(0);
// set version edition
Serializable value = nodeService.getProperty(descriptorNodeRef, ContentModel.PROP_SYS_VERSION_EDITION);
if (value == null)
{
String edition = systemProperties.getProperty("version.edition");
Collection<String> editions = new ArrayList<String>();
editions.add(edition);
nodeService.setProperty(descriptorNodeRef, ContentModel.PROP_SYS_VERSION_EDITION, (Serializable)editions);
}
}
}
// done
String msg = I18NUtil.getMessage(MSG_SUCCESS);
return msg;
}
}

View File

@@ -18,6 +18,7 @@ package org.alfresco.repo.coci;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
@@ -27,6 +28,7 @@ import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
@@ -282,6 +284,32 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest
this.cociService.checkin(workingCopy2, new HashMap<String, Serializable>(), null, true);
}
public void testCheckOutCheckInWithTranslatableAspect()
{
// Create a node to be used as the translation
NodeRef translationNodeRef = this.nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}translation"),
ContentModel.TYPE_CONTENT).getChildRef();
this.nodeService.addAspect(this.nodeRef, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "translatable"), null);
this.nodeService.createAssociation(this.nodeRef, translationNodeRef, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "translations"));
// Check it out
NodeRef workingCopy = this.cociService.checkout(
this.nodeRef,
this.rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}workingCopy"));
// Check it back in again
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>();
versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");
this.cociService.checkin(workingCopy, versionProperties);
}
/**
* Test when the aspect is not set when check-in is performed
*/
@@ -399,8 +427,8 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest
});
//NodeRef wk3 = this.cociService.getWorkingCopy(this.nodeRef);
//assertNull(wk3);
NodeRef wk3 = this.cociService.getWorkingCopy(this.nodeRef);
assertNull(wk3);
}
}

View File

@@ -240,9 +240,7 @@ public class RoutingContentService implements ContentService
private ContentReader getReader(NodeRef nodeRef, QName propertyQName, boolean fireContentReadPolicy)
{
// get the property value
ContentData contentData = null;
Serializable propValue = nodeService.getProperty(nodeRef, propertyQName);
if (propValue instanceof Collection)
{
@@ -252,6 +250,7 @@ public class RoutingContentService implements ContentService
propValue = (Serializable)colPropValue.iterator().next();
}
}
if (propValue instanceof ContentData)
{
contentData = (ContentData)propValue;
@@ -272,7 +271,7 @@ public class RoutingContentService implements ContentService
propertyQName);
}
}
// check that the URL is available
if (contentData == null || contentData.getContentUrl() == null)
{
@@ -315,9 +314,10 @@ public class RoutingContentService implements ContentService
ContentWriter writer = store.getWriter(existingContentReader, null);
// set extra data on the reader if the property is pre-existing
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, propertyQName);
if (contentData != null)
Serializable contentValue = nodeService.getProperty(nodeRef, propertyQName);
if (contentValue != null && contentValue instanceof ContentData)
{
ContentData contentData = (ContentData)contentValue;
writer.setMimetype(contentData.getMimetype());
writer.setEncoding(contentData.getEncoding());
}

View File

@@ -607,9 +607,23 @@ public class CopyServiceImpl implements CopyService
{
for (AssociationRef assocRef : nodeAssocRefs)
{
// Add the association
NodeRef targetRef = assocRef.getTargetRef();
this.nodeService.createAssociation(destinationNodeRef, targetRef, assocRef.getTypeQName());
boolean exists = false;
for (AssociationRef assocRef2 : this.nodeService.getTargetAssocs(destinationNodeRef, assocRef.getTypeQName()))
{
if (targetRef.equals(assocRef2.getTargetRef()) == true)
{
exists = true;
break;
}
}
if (exists == false)
{
// Add the association
this.nodeService.createAssociation(destinationNodeRef, targetRef, assocRef.getTypeQName());
}
}
}
}

View File

@@ -20,7 +20,6 @@ import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -239,33 +238,6 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
}
}
/**
* Create current repository descriptor
*
* @return descriptor
*/
private Descriptor createCurrentRepositoryDescriptor()
{
// retrieve system descriptor location
StoreRef storeRef = systemBootstrap.getStoreRef();
Properties systemProperties = systemBootstrap.getConfiguration();
String path = systemProperties.getProperty("system.descriptor.current.childname");
// retrieve system descriptor
NodeRef descriptorNodeRef = getDescriptorNodeRef(storeRef, path, false);
// create appropriate descriptor
if (descriptorNodeRef != null)
{
Map<QName, Serializable> properties = nodeService.getProperties(descriptorNodeRef);
return new RepositoryDescriptor(properties);
}
else
{
// descriptor cannot be found
return new UnknownDescriptor();
}
}
/**
* Push the current server descriptor properties into persistence.
*
@@ -286,13 +258,12 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
return;
}
// set the properties
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(17);
properties.put(ContentModel.PROP_SYS_VERSION_MAJOR, serverDescriptor.getVersionMajor());
properties.put(ContentModel.PROP_SYS_VERSION_MINOR, serverDescriptor.getVersionMinor());
properties.put(ContentModel.PROP_SYS_VERSION_REVISION, serverDescriptor.getVersionRevision());
properties.put(ContentModel.PROP_SYS_VERSION_LABEL, serverDescriptor.getVersionLabel());
properties.put(ContentModel.PROP_SYS_VERSION_SCHEMA, serverDescriptor.getSchema());
nodeService.setProperties(currentDescriptorNodeRef, properties);
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MAJOR, serverDescriptor.getVersionMajor());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MINOR, serverDescriptor.getVersionMinor());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_REVISION, serverDescriptor.getVersionRevision());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_LABEL, serverDescriptor.getVersionLabel());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_SCHEMA, serverDescriptor.getSchema());
// done
if (logger.isDebugEnabled())
{
@@ -377,8 +348,8 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
// NOTE: We could tie in the License Component via Spring configuration, but then it could
// be declaratively taken out in an installed environment.
Class licenseComponentClass = Class.forName("org.alfresco.license.LicenseComponent");
Constructor constructor = licenseComponentClass.getConstructor(new Class[] { ApplicationContext.class, Descriptor.class} );
licenseService = (LicenseService)constructor.newInstance(new Object[] { applicationContext, createCurrentRepositoryDescriptor() } );
Constructor constructor = licenseComponentClass.getConstructor(new Class[] { ApplicationContext.class} );
licenseService = (LicenseService)constructor.newInstance(new Object[] { applicationContext });
}
catch (ClassNotFoundException e)
{
@@ -415,13 +386,6 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
*/
private class NOOPLicenseService implements LicenseService
{
/* (non-Javadoc)
* @see org.alfresco.service.license.LicenseService#install()
*/
public void installLicense() throws LicenseException
{
}
/* (non-Javadoc)
* @see org.alfresco.service.license.LicenseService#verify()
*/

View File

@@ -16,6 +16,7 @@
*/
package org.alfresco.repo.descriptor;
import java.security.Principal;
import java.util.Date;
import java.util.Map;
@@ -88,6 +89,11 @@ public class DescriptorStartupLog implements ApplicationListener
{
String subject = license.getSubject();
String msg = "Alfresco license: " + subject;
String holder = getHolderOrganisation(license.getHolder());
if (holder != null)
{
msg += " granted to " + holder;
}
Date validUntil = license.getValidUntil();
if (validUntil != null)
{
@@ -100,6 +106,8 @@ public class DescriptorStartupLog implements ApplicationListener
{
msg += " (does not expire)";
}
logger.info(msg);
}
@@ -119,4 +127,34 @@ public class DescriptorStartupLog implements ApplicationListener
}
}
/**
* Get Organisation from Principal
*
* @param holderPrincipal
* @return organisation
*/
private String getHolderOrganisation(Principal holderPrincipal)
{
String holder = null;
if (holderPrincipal != null)
{
holder = holderPrincipal.getName();
if (holder != null)
{
String[] properties = holder.split(",");
for (String property : properties)
{
String[] parts = property.split("=");
if (parts[0].equals("O"))
{
holder = parts[1];
}
}
}
}
return holder;
}
}

View File

@@ -22,6 +22,8 @@ import java.util.List;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.dictionary.DictionaryException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
@@ -40,6 +42,10 @@ public class DictionaryBootstrap
// Dictionary DAO
private DictionaryDAO dictionaryDAO = null;
// Logger
private static Log logger = LogFactory.getLog(DictionaryDAO.class);
/**
* Sets the Dictionary DAO
@@ -86,6 +92,9 @@ public class DictionaryBootstrap
}
try
{
if (logger.isInfoEnabled())
logger.info("Loading model from " + bootstrapModel);
M2Model model = M2Model.createModel(modelStream);
dictionaryDAO.putModel(model);
}

View File

@@ -31,6 +31,8 @@ import org.alfresco.service.cmr.dictionary.ModelDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
@@ -56,6 +58,9 @@ public class DictionaryDAOImpl implements DictionaryDAO
// Map of model name to compiled model
private Map<QName,CompiledModel> compiledModels = new HashMap<QName,CompiledModel>();
// Logger
private static Log logger = LogFactory.getLog(DictionaryDAO.class);
/**
* Construct
@@ -99,6 +104,15 @@ public class DictionaryDAOImpl implements DictionaryDAO
// Publish new Model Definition
compiledModels.put(modelName, compiledModel);
if (logger.isInfoEnabled())
{
logger.info("Registered model " + modelName.toPrefixString(namespaceDAO));
for (M2Namespace namespace : model.getNamespaces())
{
logger.info("Registered namespace '" + namespace.getUri() + "' (prefix '" + namespace.getPrefix() + "')");
}
}
}
/**