mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged V3.0 to HEAD
11375: MT - complete fix for ETHREEOH-189 11378: Supporting changes for license component in 3.0 (but not the license component itself ...) 11380: Fix for transaction error. ETHREEOH-451. 11383: Oracle upgrade and create SQL fixes (Can Entperprise-only later) 11384: Fix truelicense classpath in sdk-projects git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12424 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -106,9 +106,7 @@ public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAw
|
||||
try
|
||||
{
|
||||
licenseService = (LicenseService) ctx.getBean("org.alfresco.license.LicenseComponent");
|
||||
|
||||
// verify license, but only if license component is installed
|
||||
licenseService.verifyLicense();
|
||||
readOnly = !licenseService.isLicenseValid();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e)
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 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
|
||||
@@ -18,7 +18,7 @@
|
||||
* 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
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
@@ -77,7 +77,7 @@ public class PatchExecuter extends AbstractLifecycleBean
|
||||
public void applyOutstandingPatches()
|
||||
{
|
||||
// Avoid read-only systems
|
||||
if (transactionService.isReadOnly())
|
||||
if (!patchService.validatePatches() || transactionService.isReadOnly())
|
||||
{
|
||||
logger.warn(I18NUtil.getMessage(MSG_SYSTEM_READ_ONLY));
|
||||
return;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 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
|
||||
@@ -18,7 +18,7 @@
|
||||
* 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
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
@@ -27,11 +27,12 @@ package org.alfresco.repo.admin.patch;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
/**
|
||||
* Manages patches applied against the repository.
|
||||
* <p>
|
||||
* Patches are injected into this class and any attempted applications are recorded
|
||||
* for later auditing.
|
||||
* Patches are injected into this class and any attempted applications are recorded for later auditing.
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Derek Hulley
|
||||
@@ -41,25 +42,35 @@ public interface PatchService
|
||||
/**
|
||||
* Registers a patch with the service that executes them.
|
||||
*
|
||||
* @param patch the patch to register
|
||||
* @param patch
|
||||
* the patch to register
|
||||
*/
|
||||
public void registerPatch(Patch patch);
|
||||
|
||||
|
||||
/**
|
||||
* Apply all outstanding patches that are relevant to the repo.
|
||||
* If there is a failure, then the patches that were applied will remain so,
|
||||
* but the process will not attempt to apply any further patches.
|
||||
* Does some up-front validation on the patches, specifically to see if they all apply to the current server version
|
||||
* and not some future version. This is to prevent tampering with versioning information attached to a license.
|
||||
*
|
||||
* @return Returns true if all outstanding patches were applied, or false if the process
|
||||
* was termintated before all patches could be applied.
|
||||
* @return true if validation is successful. Outputs errors and returns false otherwise.
|
||||
*/
|
||||
public boolean validatePatches();
|
||||
|
||||
/**
|
||||
* Apply all outstanding patches that are relevant to the repo. If there is a failure, then the patches that were
|
||||
* applied will remain so, but the process will not attempt to apply any further patches.
|
||||
*
|
||||
* @return Returns true if all outstanding patches were applied, or false if the process was termintated before all
|
||||
* patches could be applied.
|
||||
*/
|
||||
public boolean applyOutstandingPatches();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves all applied patches between two specific times.
|
||||
*
|
||||
* @param from the start date of the search, or null to get all patches from the start
|
||||
* @param to the end date of the search, or null to g
|
||||
* @param from
|
||||
* the start date of the search, or null to get all patches from the start
|
||||
* @param to
|
||||
* the end date of the search, or null to g
|
||||
* @return Returns all applied patches (successful or not)
|
||||
*/
|
||||
public List<PatchInfo> getPatches(Date fromDate, Date toDate);
|
||||
|
@@ -34,12 +34,12 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.domain.AppliedPatch;
|
||||
import org.alfresco.repo.transaction.TransactionServiceImpl;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.admin.PatchException;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -58,6 +58,7 @@ public class PatchServiceImpl implements PatchService
|
||||
private static final String MSG_NOT_RELEVANT = "patch.service.not_relevant";
|
||||
private static final String MSG_PRECEEDED_BY_ALTERNATIVE = "patch.service.preceeded_by_alternative";
|
||||
private static final String MSG_APPLYING_PATCH = "patch.service.applying_patch";
|
||||
private static final String MSG_VALIDATION_FAILED = "patch.validation.failed";
|
||||
|
||||
private static final Date ZERO_DATE = new Date(0L);
|
||||
private static final Date INFINITE_DATE = new Date(Long.MAX_VALUE);
|
||||
@@ -65,7 +66,7 @@ public class PatchServiceImpl implements PatchService
|
||||
private static Log logger = LogFactory.getLog(PatchExecuter.class);
|
||||
|
||||
private DescriptorService descriptorService;
|
||||
private TransactionService transactionService;
|
||||
private TransactionServiceImpl transactionService;
|
||||
private RuleService ruleService;
|
||||
private PatchDaoService patchDaoService;
|
||||
private List<Patch> patches;
|
||||
@@ -80,7 +81,7 @@ public class PatchServiceImpl implements PatchService
|
||||
this.descriptorService = descriptorService;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
public void setTransactionService(TransactionServiceImpl transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
@@ -100,6 +101,27 @@ public class PatchServiceImpl implements PatchService
|
||||
patches.add(patch);
|
||||
}
|
||||
|
||||
public boolean validatePatches()
|
||||
{
|
||||
boolean success = true;
|
||||
int serverSchemaVersion = descriptorService.getServerDescriptor().getSchema();
|
||||
for (Patch patch : patches)
|
||||
{
|
||||
if (patch.getFixesToSchema() > serverSchemaVersion)
|
||||
{
|
||||
logger.error(I18NUtil.getMessage(MSG_VALIDATION_FAILED, patch.getId(), serverSchemaVersion, patch
|
||||
.getFixesToSchema(), patch.getTargetSchema()));
|
||||
success = false;
|
||||
}
|
||||
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
this.transactionService.setAllowWrite(false);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public boolean applyOutstandingPatches()
|
||||
{
|
||||
boolean success = true;
|
||||
@@ -114,7 +136,7 @@ public class PatchServiceImpl implements PatchService
|
||||
List<Patch> sortedPatches = new ArrayList<Patch>(patches);
|
||||
Comparator<Patch> comparator = new PatchTargetSchemaComparator();
|
||||
Collections.sort(sortedPatches, comparator);
|
||||
|
||||
|
||||
// construct a list of executed patches by ID (also check the date)
|
||||
Map<String, AppliedPatch> appliedPatchesById = new HashMap<String, AppliedPatch>(23);
|
||||
List<AppliedPatch> appliedPatches = patchDaoService.getAppliedPatches();
|
||||
|
@@ -196,7 +196,11 @@ public class InternalEhCacheManagerFactoryBean implements FactoryBean, CacheProv
|
||||
*/
|
||||
public void stop()
|
||||
{
|
||||
InternalEhCacheManagerFactoryBean.getInstance().shutdown();
|
||||
synchronized (getClass())
|
||||
{
|
||||
InternalEhCacheManagerFactoryBean.getInstance().shutdown();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
68
source/java/org/alfresco/repo/descriptor/DescriptorDAO.java
Normal file
68
source/java/org/alfresco/repo/descriptor/DescriptorDAO.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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 received 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.descriptor;
|
||||
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
|
||||
/**
|
||||
* Abstracts out the mechanism used to persist repository descriptors.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public interface DescriptorDAO
|
||||
{
|
||||
|
||||
/**
|
||||
* Create repository descriptor.
|
||||
*
|
||||
* @return descriptor
|
||||
*/
|
||||
public Descriptor getDescriptor();
|
||||
|
||||
/**
|
||||
* Push the current server descriptor properties into persistence.
|
||||
*
|
||||
* @param serverDescriptor
|
||||
* the current server descriptor
|
||||
* @return the descriptor
|
||||
*/
|
||||
public Descriptor updateDescriptor(Descriptor serverDescriptor);
|
||||
|
||||
/**
|
||||
* Gets the license key.
|
||||
*
|
||||
* @return the license key
|
||||
*/
|
||||
public byte[] getLicenseKey();
|
||||
|
||||
/**
|
||||
* Update license key.
|
||||
*
|
||||
* @param key
|
||||
* the key
|
||||
*/
|
||||
public void updateLicenseKey(final byte[] key);
|
||||
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 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
|
||||
@@ -18,113 +18,97 @@
|
||||
* 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
|
||||
* FLOSS exception. You should have received 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.descriptor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.importer.ImporterBootstrap;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.license.LicenseDescriptor;
|
||||
import org.alfresco.service.license.LicenseException;
|
||||
import org.alfresco.service.license.LicenseService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.AbstractLifecycleBean;
|
||||
import org.alfresco.util.VersionNumber;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Implementation of Descriptor Service
|
||||
* Implementation of Descriptor Service.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class DescriptorServiceImpl extends AbstractLifecycleBean implements DescriptorService, InitializingBean
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class);
|
||||
|
||||
private String repositoryName;
|
||||
private Properties serverProperties;
|
||||
/** The server descriptor DAO. */
|
||||
private DescriptorDAO serverDescriptorDAO;
|
||||
|
||||
private ImporterBootstrap systemBootstrap;
|
||||
/** The current repo descriptor DAO. */
|
||||
private DescriptorDAO currentRepoDescriptorDAO;
|
||||
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private SearchService searchService;
|
||||
/** The installed repo descriptor DAO. */
|
||||
private DescriptorDAO installedRepoDescriptorDAO;
|
||||
|
||||
/** The transaction service. */
|
||||
private TransactionService transactionService;
|
||||
|
||||
/** The license service. */
|
||||
private LicenseService licenseService = null;
|
||||
|
||||
/** The server descriptor. */
|
||||
private Descriptor serverDescriptor;
|
||||
|
||||
/** The current repo descriptor. */
|
||||
private Descriptor currentRepoDescriptor;
|
||||
|
||||
/** The installed repo descriptor. */
|
||||
private Descriptor installedRepoDescriptor;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the repository properties from a resource file
|
||||
* Sets the server descriptor DAO.
|
||||
*
|
||||
* @param repositoryResource resource containing repository properties
|
||||
* @throws IOException
|
||||
* @param serverDescriptorDAO
|
||||
* the new server descriptor DAO
|
||||
*/
|
||||
public void setRepositoryName(String repositoryName)
|
||||
throws IOException
|
||||
public void setServerDescriptorDAO(DescriptorDAO serverDescriptorDAO)
|
||||
{
|
||||
this.repositoryName = repositoryName;
|
||||
this.serverDescriptorDAO = serverDescriptorDAO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the server descriptor from a resource file
|
||||
* Sets the current repo descriptor DAO.
|
||||
*
|
||||
* @param descriptorResource
|
||||
* resource containing server descriptor meta-data
|
||||
* @throws IOException
|
||||
* @param currentRepoDescriptorDAO
|
||||
* the new current repo descriptor DAO
|
||||
*/
|
||||
public void setDescriptor(Resource descriptorResource) throws IOException
|
||||
public void setCurrentRepoDescriptorDAO(DescriptorDAO currentRepoDescriptorDAO)
|
||||
{
|
||||
this.serverProperties = new Properties();
|
||||
this.serverProperties.load(descriptorResource.getInputStream());
|
||||
this.currentRepoDescriptorDAO = currentRepoDescriptorDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param systemBootstrap
|
||||
* system bootstrap
|
||||
* Sets the installed repo descriptor DAO.
|
||||
*
|
||||
* @param installedRepoDescriptorDAO
|
||||
* the new installed repo descriptor DAO
|
||||
*/
|
||||
public void setSystemBootstrap(ImporterBootstrap systemBootstrap)
|
||||
public void setInstalledRepoDescriptorDAO(DescriptorDAO installedRepoDescriptorDAO)
|
||||
{
|
||||
this.systemBootstrap = systemBootstrap;
|
||||
this.installedRepoDescriptorDAO = installedRepoDescriptorDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transaction service.
|
||||
*
|
||||
* @param transactionService
|
||||
* transaction service
|
||||
*/
|
||||
@@ -133,36 +117,8 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
* namespace service
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService
|
||||
* node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchService
|
||||
* search service
|
||||
*/
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.DescriptorService#getDescriptor()
|
||||
*/
|
||||
public Descriptor getServerDescriptor()
|
||||
@@ -172,15 +128,15 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.DescriptorService#getCurrentRepositoryDescriptor()
|
||||
*/
|
||||
public Descriptor getCurrentRepositoryDescriptor()
|
||||
{
|
||||
return currentRepoDescriptor;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.DescriptorService#getRepositoryDescriptor()
|
||||
*/
|
||||
public Descriptor getInstalledRepositoryDescriptor()
|
||||
@@ -190,7 +146,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.DescriptorService#getLicenseDescriptor()
|
||||
*/
|
||||
public LicenseDescriptor getLicenseDescriptor()
|
||||
@@ -198,6 +153,10 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
return (licenseService == null) ? null : licenseService.getLicense();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
@@ -214,15 +173,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
licenseService.verifyLicense();
|
||||
|
||||
// persist the server descriptor values
|
||||
currentRepoDescriptor = updateCurrentRepositoryDescriptor(serverDescriptor);
|
||||
currentRepoDescriptor = DescriptorServiceImpl.this.currentRepoDescriptorDAO
|
||||
.updateDescriptor(serverDescriptor);
|
||||
|
||||
// create the installed descriptor
|
||||
return createInstalledRepositoryDescriptor();
|
||||
Descriptor installed = DescriptorServiceImpl.this.installedRepoDescriptorDAO.getDescriptor();
|
||||
return installed == null ? new UnknownDescriptor() : installed;
|
||||
}
|
||||
};
|
||||
installedRepoDescriptor = transactionService.getRetryingTransactionHelper().doInTransaction(createDescriptorWork, transactionService.isReadOnly(), false);
|
||||
installedRepoDescriptor = transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||
createDescriptorWork, transactionService.isReadOnly(), false);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
@@ -233,158 +199,19 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise Descriptors
|
||||
* Initialise Descriptors.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
// initialise server descriptor
|
||||
serverDescriptor = createServerDescriptor();
|
||||
serverDescriptor = this.serverDescriptorDAO.getDescriptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create server descriptor
|
||||
*
|
||||
* @return descriptor
|
||||
*/
|
||||
private Descriptor createServerDescriptor()
|
||||
{
|
||||
return new ServerDescriptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create repository descriptor
|
||||
*
|
||||
* @return descriptor
|
||||
*/
|
||||
private Descriptor createInstalledRepositoryDescriptor()
|
||||
{
|
||||
// retrieve system descriptor location
|
||||
StoreRef storeRef = systemBootstrap.getStoreRef();
|
||||
Properties systemProperties = systemBootstrap.getConfiguration();
|
||||
String path = systemProperties.getProperty("system.descriptor.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.
|
||||
*
|
||||
* @param serverDescriptor
|
||||
* the current server descriptor
|
||||
*/
|
||||
private Descriptor updateCurrentRepositoryDescriptor(Descriptor serverDescriptor)
|
||||
{
|
||||
// retrieve system descriptor location
|
||||
StoreRef storeRef = systemBootstrap.getStoreRef();
|
||||
Properties systemProperties = systemBootstrap.getConfiguration();
|
||||
String path = systemProperties.getProperty("system.descriptor.current.childname");
|
||||
|
||||
// retrieve system descriptor
|
||||
NodeRef currentDescriptorNodeRef = getDescriptorNodeRef(storeRef, path, true);
|
||||
// if the node is missing but it should have been created
|
||||
if (currentDescriptorNodeRef == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// set the properties
|
||||
if (!transactionService.isReadOnly())
|
||||
{
|
||||
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_NAME, serverDescriptor.getName());
|
||||
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_BUILD, serverDescriptor.getVersionBuild());
|
||||
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_SCHEMA, serverDescriptor.getSchema());
|
||||
Collection<String> editions = new ArrayList<String>();
|
||||
editions.add(serverDescriptor.getEdition());
|
||||
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_EDITION, (Serializable)editions);
|
||||
|
||||
// done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Updated current repository descriptor properties: \n" + " node: " + currentDescriptorNodeRef + "\n" + " descriptor: " + serverDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
Map<QName, Serializable> properties = nodeService.getProperties(currentDescriptorNodeRef);
|
||||
return new RepositoryDescriptor(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeRef
|
||||
* the store to search
|
||||
* @param path
|
||||
* the path below the root node to search
|
||||
* @param create
|
||||
* true if the node must be created if missing. No properties will be set.
|
||||
* @return Returns the node for the path, or null
|
||||
*/
|
||||
private NodeRef getDescriptorNodeRef(StoreRef storeRef, String path, boolean create)
|
||||
{
|
||||
NodeRef descriptorNodeRef = null;
|
||||
String searchPath = "/" + path;
|
||||
|
||||
// check for the store
|
||||
if (nodeService.exists(storeRef))
|
||||
{
|
||||
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(rootNodeRef, searchPath, null, namespaceService, false);
|
||||
if (nodeRefs.size() == 1)
|
||||
{
|
||||
descriptorNodeRef = nodeRefs.get(0);
|
||||
}
|
||||
else if (nodeRefs.size() == 0)
|
||||
{
|
||||
}
|
||||
else if (nodeRefs.size() > 1)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Multiple descriptors: \n" + " store: " + storeRef + "\n" + " path: " + searchPath);
|
||||
}
|
||||
// get the first one
|
||||
descriptorNodeRef = nodeRefs.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptorNodeRef == null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Descriptor not found: \n" + " store: " + storeRef + "\n" + " path: " + searchPath);
|
||||
}
|
||||
|
||||
// create if necessary
|
||||
if (create)
|
||||
{
|
||||
storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
|
||||
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
||||
descriptorNodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(path, namespaceService),
|
||||
QName.createQName("sys:descriptor", namespaceService)).getChildRef();
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Created missing descriptor node: " + descriptorNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
return descriptorNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise License Service
|
||||
* Initialise License Service.
|
||||
*/
|
||||
private void initialiseLicenseService()
|
||||
{
|
||||
@@ -392,9 +219,15 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
{
|
||||
// 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 });
|
||||
licenseService = (LicenseService) constructor.newInstance(new Object[] { getApplicationContext() });
|
||||
Class<?> licenseComponentClass = Class.forName("org.alfresco.license.LicenseComponent");
|
||||
Constructor<?> constructor = licenseComponentClass.getConstructor(new Class[]
|
||||
{
|
||||
ApplicationContext.class
|
||||
});
|
||||
licenseService = (LicenseService) constructor.newInstance(new Object[]
|
||||
{
|
||||
getApplicationContext()
|
||||
});
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
@@ -427,14 +260,14 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy License Service
|
||||
* Dummy License Service.
|
||||
*/
|
||||
private class NOOPLicenseService implements LicenseService
|
||||
{
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.license.LicenseService#verify()
|
||||
* @see org.alfresco.service.license.LicenseService#verifyLicense(org.alfresco.service.descriptor.Descriptor,
|
||||
* org.alfresco.service.descriptor.DescriptorDAO)
|
||||
*/
|
||||
public void verifyLicense() throws LicenseException
|
||||
{
|
||||
@@ -442,7 +275,15 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.license.LicenseService#isLicenseValid()
|
||||
*/
|
||||
public boolean isLicenseValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.license.LicenseService#getLicense()
|
||||
*/
|
||||
public LicenseDescriptor getLicense() throws LicenseException
|
||||
@@ -450,13 +291,18 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.license.LicenseService#shutdown()
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Unknown descriptor
|
||||
* Unknown descriptor.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
@@ -464,7 +310,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
{
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getId()
|
||||
*/
|
||||
public String getId()
|
||||
@@ -472,15 +317,17 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
|
||||
*/
|
||||
public String getVersionMajor()
|
||||
@@ -490,7 +337,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMinor()
|
||||
*/
|
||||
public String getVersionMinor()
|
||||
@@ -500,7 +346,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionRevision()
|
||||
*/
|
||||
public String getVersionRevision()
|
||||
@@ -510,7 +355,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionLabel()
|
||||
*/
|
||||
public String getVersionLabel()
|
||||
@@ -520,7 +364,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
|
||||
*/
|
||||
public String getVersionBuild()
|
||||
@@ -528,6 +371,10 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionNumber()
|
||||
*/
|
||||
public VersionNumber getVersionNumber()
|
||||
{
|
||||
return new VersionNumber("1.0.0");
|
||||
@@ -535,7 +382,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
|
||||
*/
|
||||
public String getVersion()
|
||||
@@ -545,7 +391,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getEdition()
|
||||
*/
|
||||
public String getEdition()
|
||||
@@ -555,7 +400,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getSchema()
|
||||
*/
|
||||
public int getSchema()
|
||||
@@ -565,7 +409,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptorKeys()
|
||||
*/
|
||||
public String[] getDescriptorKeys()
|
||||
@@ -575,7 +418,6 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptor(java.lang.String)
|
||||
*/
|
||||
public String getDescriptor(String key)
|
||||
@@ -589,11 +431,19 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public abstract class BaseDescriptor implements Descriptor
|
||||
public static abstract class BaseDescriptor implements Descriptor
|
||||
{
|
||||
|
||||
/** The version number. */
|
||||
private VersionNumber versionNumber = null;
|
||||
|
||||
/** The number as a string. */
|
||||
private String strVersion = null;
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionNumber()
|
||||
*/
|
||||
public VersionNumber getVersionNumber()
|
||||
{
|
||||
if (this.versionNumber == null)
|
||||
@@ -609,6 +459,10 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
return this.versionNumber;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
if (this.strVersion == null)
|
||||
@@ -618,50 +472,50 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
version.append(getVersionMinor());
|
||||
version.append(".");
|
||||
version.append(getVersionRevision());
|
||||
|
||||
|
||||
String label = getVersionLabel();
|
||||
String build = getVersionBuild();
|
||||
|
||||
|
||||
boolean hasLabel = (label != null && label.length() > 0);
|
||||
boolean hasBuild = (build != null && build.length() > 0);
|
||||
|
||||
|
||||
// add opening bracket if either a label or build number is present
|
||||
if (hasLabel || hasBuild)
|
||||
{
|
||||
version.append(" (");
|
||||
version.append(" (");
|
||||
}
|
||||
|
||||
|
||||
// add label if present
|
||||
if (hasLabel)
|
||||
{
|
||||
version.append(label);
|
||||
version.append(label);
|
||||
}
|
||||
|
||||
|
||||
// add build number is present
|
||||
if (hasBuild)
|
||||
{
|
||||
// if there is also a label we need a separating space
|
||||
if (hasLabel)
|
||||
{
|
||||
version.append(" ");
|
||||
}
|
||||
|
||||
version.append(build);
|
||||
// if there is also a label we need a separating space
|
||||
if (hasLabel)
|
||||
{
|
||||
version.append(" ");
|
||||
}
|
||||
|
||||
version.append(build);
|
||||
}
|
||||
|
||||
|
||||
// add closing bracket if either a label or build number is present
|
||||
if (hasLabel || hasBuild)
|
||||
{
|
||||
version.append(")");
|
||||
version.append(")");
|
||||
}
|
||||
|
||||
|
||||
this.strVersion = version.toString();
|
||||
}
|
||||
return this.strVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the int representation of the given schema string
|
||||
* Returns the int representation of the given schema string.
|
||||
*
|
||||
* @param schemaStr
|
||||
* The schema number as a string
|
||||
@@ -689,263 +543,4 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Repository Descriptor whose meta-data is retrieved from the repository store
|
||||
*/
|
||||
private class RepositoryDescriptor extends BaseDescriptor
|
||||
{
|
||||
private Map<QName, Serializable> properties;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param properties
|
||||
* system descriptor properties
|
||||
*/
|
||||
private RepositoryDescriptor(Map<QName, Serializable> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getId()
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return getDescriptor("sys:node-uuid");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getDescriptor("sys:name");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
|
||||
*/
|
||||
public String getVersionMajor()
|
||||
{
|
||||
return getDescriptor("sys:versionMajor");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMinor()
|
||||
*/
|
||||
public String getVersionMinor()
|
||||
{
|
||||
return getDescriptor("sys:versionMinor");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionRevision()
|
||||
*/
|
||||
public String getVersionRevision()
|
||||
{
|
||||
return getDescriptor("sys:versionRevision");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionLabel()
|
||||
*/
|
||||
public String getVersionLabel()
|
||||
{
|
||||
return getDescriptor("sys:versionLabel");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
|
||||
*/
|
||||
public String getVersionBuild()
|
||||
{
|
||||
return getDescriptor("sys:versionBuild");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getEdition()
|
||||
*/
|
||||
public String getEdition()
|
||||
{
|
||||
return getDescriptor("sys:versionEdition");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getSchema()
|
||||
*/
|
||||
public int getSchema()
|
||||
{
|
||||
return getSchema(getDescriptor("sys:versionSchema"));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptorKeys()
|
||||
*/
|
||||
public String[] getDescriptorKeys()
|
||||
{
|
||||
String[] keys = new String[properties.size()];
|
||||
properties.keySet().toArray(keys);
|
||||
return keys;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptor(java.lang.String)
|
||||
*/
|
||||
public String getDescriptor(String key)
|
||||
{
|
||||
String strValue = null;
|
||||
QName qname = QName.createQName(key, namespaceService);
|
||||
Serializable value = properties.get(qname);
|
||||
if (value != null)
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
Collection coll = (Collection)value;
|
||||
if (coll.size() > 0)
|
||||
{
|
||||
strValue = coll.iterator().next().toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strValue = value.toString();
|
||||
}
|
||||
}
|
||||
return strValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Server Descriptor whose meta-data is retrieved from run-time environment
|
||||
*/
|
||||
private class ServerDescriptor extends BaseDescriptor
|
||||
{
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getId()
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return "<Unknown";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return repositoryName == null ? "<Unknown>" : repositoryName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
|
||||
*/
|
||||
public String getVersionMajor()
|
||||
{
|
||||
return serverProperties.getProperty("version.major");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMinor()
|
||||
*/
|
||||
public String getVersionMinor()
|
||||
{
|
||||
return serverProperties.getProperty("version.minor");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionRevision()
|
||||
*/
|
||||
public String getVersionRevision()
|
||||
{
|
||||
return serverProperties.getProperty("version.revision");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionLabel()
|
||||
*/
|
||||
public String getVersionLabel()
|
||||
{
|
||||
return serverProperties.getProperty("version.label");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
|
||||
*/
|
||||
public String getVersionBuild()
|
||||
{
|
||||
return serverProperties.getProperty("version.build");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getEdition()
|
||||
*/
|
||||
public String getEdition()
|
||||
{
|
||||
return serverProperties.getProperty("version.edition");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getSchema()
|
||||
*/
|
||||
public int getSchema()
|
||||
{
|
||||
return getSchema(serverProperties.getProperty("version.schema"));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptorKeys()
|
||||
*/
|
||||
public String[] getDescriptorKeys()
|
||||
{
|
||||
String[] keys = new String[serverProperties.size()];
|
||||
serverProperties.keySet().toArray(keys);
|
||||
return keys;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptor(java.lang.String)
|
||||
*/
|
||||
public String getDescriptor(String key)
|
||||
{
|
||||
return serverProperties.getProperty(key, "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,509 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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 received 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.descriptor;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.descriptor.DescriptorServiceImpl.BaseDescriptor;
|
||||
import org.alfresco.repo.importer.ImporterBootstrap;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.alfresco.service.license.LicenseException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Manages persistence and retrieval of Descriptors whose meta-data are retrieved from the repository stores.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class RepositoryDescriptorDAOImpl implements DescriptorDAO
|
||||
{
|
||||
|
||||
/** The logger. */
|
||||
private static Log logger = LogFactory.getLog(RepositoryDescriptorDAOImpl.class);
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/** The node service. */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** The content service. */
|
||||
private ContentService contentService;
|
||||
|
||||
/** The search service. */
|
||||
private SearchService searchService;
|
||||
|
||||
/** The namespace service. */
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
/** The system bootstrap. */
|
||||
private ImporterBootstrap systemBootstrap;
|
||||
|
||||
/** The transaction service. */
|
||||
private TransactionService transactionService;
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name
|
||||
* the new name
|
||||
*/
|
||||
public void setName(final String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node service.
|
||||
*
|
||||
* @param nodeService
|
||||
* the new node service
|
||||
*/
|
||||
public void setNodeService(final NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content service.
|
||||
*
|
||||
* @param contentService
|
||||
* the new content service
|
||||
*/
|
||||
public void setContentService(final ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search service.
|
||||
*
|
||||
* @param searchService
|
||||
* the new search service
|
||||
*/
|
||||
public void setSearchService(final SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the namespace service.
|
||||
*
|
||||
* @param namespaceService
|
||||
* the new namespace service
|
||||
*/
|
||||
public void setNamespaceService(final NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the system bootstrap.
|
||||
*
|
||||
* @param systemBootstrap
|
||||
* the new system bootstrap
|
||||
*/
|
||||
public void setSystemBootstrap(final ImporterBootstrap systemBootstrap)
|
||||
{
|
||||
this.systemBootstrap = systemBootstrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transaction service.
|
||||
*
|
||||
* @param transactionService
|
||||
* the new transaction service
|
||||
*/
|
||||
public void setTransactionService(final TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.descriptor.DescriptorPersistence#getDescriptor()
|
||||
*/
|
||||
public Descriptor getDescriptor()
|
||||
{
|
||||
// retrieve system descriptor
|
||||
final NodeRef descriptorNodeRef = getDescriptorNodeRef(false);
|
||||
|
||||
// create appropriate descriptor
|
||||
if (descriptorNodeRef != null)
|
||||
{
|
||||
final Map<QName, Serializable> properties = this.nodeService.getProperties(descriptorNodeRef);
|
||||
return new RepositoryDescriptor(properties);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.repo.descriptor.DescriptorPersistence#updateDescriptor(org.alfresco.service.descriptor.Descriptor)
|
||||
*/
|
||||
public Descriptor updateDescriptor(final Descriptor serverDescriptor)
|
||||
{
|
||||
final NodeRef currentDescriptorNodeRef = getDescriptorNodeRef(true);
|
||||
// if the node is missing but it should have been created
|
||||
if (currentDescriptorNodeRef == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// set the properties
|
||||
if (!this.transactionService.isReadOnly())
|
||||
{
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_NAME, serverDescriptor
|
||||
.getName());
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MAJOR,
|
||||
serverDescriptor.getVersionMajor());
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MINOR,
|
||||
serverDescriptor.getVersionMinor());
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_REVISION,
|
||||
serverDescriptor.getVersionRevision());
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_LABEL,
|
||||
serverDescriptor.getVersionLabel());
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_BUILD,
|
||||
serverDescriptor.getVersionBuild());
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_SCHEMA,
|
||||
serverDescriptor.getSchema());
|
||||
|
||||
// The version edition property may already have been overwritten with a license, so only set the property
|
||||
// if it doesn't already contain ContentData
|
||||
final Serializable value = this.nodeService.getProperty(currentDescriptorNodeRef,
|
||||
ContentModel.PROP_SYS_VERSION_EDITION);
|
||||
if (!(value instanceof Collection) || ((Collection<?>) value).isEmpty()
|
||||
|| ((Collection<?>) value).iterator().next() instanceof String)
|
||||
{
|
||||
final Collection<String> editions = new ArrayList<String>();
|
||||
editions.add(serverDescriptor.getEdition());
|
||||
this.nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_EDITION,
|
||||
(Serializable) editions);
|
||||
}
|
||||
|
||||
// done
|
||||
if (RepositoryDescriptorDAOImpl.logger.isDebugEnabled())
|
||||
{
|
||||
RepositoryDescriptorDAOImpl.logger.debug("Updated current repository descriptor properties: \n"
|
||||
+ " node: " + currentDescriptorNodeRef + "\n" + " descriptor: " + serverDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
final Map<QName, Serializable> properties = this.nodeService.getProperties(currentDescriptorNodeRef);
|
||||
return new RepositoryDescriptor(properties);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.descriptor.DescriptorPersistence#getLicenseKey()
|
||||
*/
|
||||
public byte[] getLicenseKey()
|
||||
{
|
||||
byte[] key = null;
|
||||
|
||||
try
|
||||
{
|
||||
final NodeRef descriptorRef = getDescriptorNodeRef(true);
|
||||
if (descriptorRef == null)
|
||||
{
|
||||
throw new LicenseException("Failed to find system descriptor");
|
||||
}
|
||||
final ContentReader reader = this.contentService.getReader(descriptorRef,
|
||||
ContentModel.PROP_SYS_VERSION_EDITION);
|
||||
if (reader != null && reader.exists())
|
||||
{
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
reader.getContent(os);
|
||||
key = os.toByteArray();
|
||||
}
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new LicenseException("Failed to load license", e);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.descriptor.DescriptorPersistence#updateLicenseKey(byte[])
|
||||
*/
|
||||
public void updateLicenseKey(final byte[] key)
|
||||
{
|
||||
try
|
||||
{
|
||||
final NodeRef descriptorRef = getDescriptorNodeRef(true);
|
||||
if (descriptorRef == null)
|
||||
{
|
||||
throw new LicenseException("Failed to find system descriptor");
|
||||
}
|
||||
if (key == null)
|
||||
{
|
||||
this.nodeService.setProperty(descriptorRef, ContentModel.PROP_SYS_VERSION_EDITION, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
final ContentWriter writer = this.contentService.getWriter(descriptorRef,
|
||||
ContentModel.PROP_SYS_VERSION_EDITION, true);
|
||||
final InputStream is = new ByteArrayInputStream(key);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_BINARY);
|
||||
writer.putContent(is);
|
||||
}
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new LicenseException("Failed to save license", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the descriptor node ref.
|
||||
*
|
||||
* @param create
|
||||
* the create
|
||||
* @return the descriptor node ref
|
||||
*/
|
||||
private NodeRef getDescriptorNodeRef(final boolean create)
|
||||
{
|
||||
// retrieve system descriptor location
|
||||
StoreRef storeRef = this.systemBootstrap.getStoreRef();
|
||||
final Properties systemProperties = this.systemBootstrap.getConfiguration();
|
||||
final String path = systemProperties.getProperty(this.name);
|
||||
|
||||
NodeRef descriptorNodeRef = null;
|
||||
final String searchPath = "/" + path;
|
||||
|
||||
// check for the store
|
||||
if (this.nodeService.exists(storeRef))
|
||||
{
|
||||
final NodeRef rootNodeRef = this.nodeService.getRootNode(storeRef);
|
||||
final List<NodeRef> nodeRefs = this.searchService.selectNodes(rootNodeRef, searchPath, null,
|
||||
this.namespaceService, false);
|
||||
if (nodeRefs.size() == 1)
|
||||
{
|
||||
descriptorNodeRef = nodeRefs.get(0);
|
||||
}
|
||||
else if (nodeRefs.size() == 0)
|
||||
{
|
||||
}
|
||||
else if (nodeRefs.size() > 1)
|
||||
{
|
||||
if (RepositoryDescriptorDAOImpl.logger.isDebugEnabled())
|
||||
{
|
||||
RepositoryDescriptorDAOImpl.logger.debug("Multiple descriptors: \n" + " store: " + storeRef
|
||||
+ "\n" + " path: " + searchPath);
|
||||
}
|
||||
// get the first one
|
||||
descriptorNodeRef = nodeRefs.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptorNodeRef == null)
|
||||
{
|
||||
if (RepositoryDescriptorDAOImpl.logger.isDebugEnabled())
|
||||
{
|
||||
RepositoryDescriptorDAOImpl.logger.debug("Descriptor not found: \n" + " store: " + storeRef + "\n"
|
||||
+ " path: " + searchPath);
|
||||
}
|
||||
|
||||
// create if necessary
|
||||
if (create)
|
||||
{
|
||||
storeRef = this.nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
|
||||
final NodeRef rootNodeRef = this.nodeService.getRootNode(storeRef);
|
||||
descriptorNodeRef = this.nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName(path, this.namespaceService),
|
||||
QName.createQName("sys:descriptor", this.namespaceService)).getChildRef();
|
||||
if (RepositoryDescriptorDAOImpl.logger.isDebugEnabled())
|
||||
{
|
||||
RepositoryDescriptorDAOImpl.logger.debug("Created missing descriptor node: " + descriptorNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
return descriptorNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repository Descriptor whose meta-data is retrieved from the repository store.
|
||||
*/
|
||||
private class RepositoryDescriptor extends BaseDescriptor
|
||||
{
|
||||
|
||||
/** The properties. */
|
||||
private final Map<QName, Serializable> properties;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param properties
|
||||
* system descriptor properties
|
||||
*/
|
||||
private RepositoryDescriptor(final Map<QName, Serializable> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getId()
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return getDescriptor("sys:node-uuid");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getDescriptor("sys:name");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
|
||||
*/
|
||||
public String getVersionMajor()
|
||||
{
|
||||
return getDescriptor("sys:versionMajor");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMinor()
|
||||
*/
|
||||
public String getVersionMinor()
|
||||
{
|
||||
return getDescriptor("sys:versionMinor");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionRevision()
|
||||
*/
|
||||
public String getVersionRevision()
|
||||
{
|
||||
return getDescriptor("sys:versionRevision");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionLabel()
|
||||
*/
|
||||
public String getVersionLabel()
|
||||
{
|
||||
return getDescriptor("sys:versionLabel");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
|
||||
*/
|
||||
public String getVersionBuild()
|
||||
{
|
||||
return getDescriptor("sys:versionBuild");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getEdition()
|
||||
*/
|
||||
public String getEdition()
|
||||
{
|
||||
return getDescriptor("sys:versionEdition");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getSchema()
|
||||
*/
|
||||
public int getSchema()
|
||||
{
|
||||
return getSchema(getDescriptor("sys:versionSchema"));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptorKeys()
|
||||
*/
|
||||
public String[] getDescriptorKeys()
|
||||
{
|
||||
final String[] keys = new String[this.properties.size()];
|
||||
this.properties.keySet().toArray(keys);
|
||||
return keys;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptor(java.lang.String)
|
||||
*/
|
||||
public String getDescriptor(final String key)
|
||||
{
|
||||
String strValue = null;
|
||||
final QName qname = QName.createQName(key, RepositoryDescriptorDAOImpl.this.namespaceService);
|
||||
final Serializable value = this.properties.get(qname);
|
||||
if (value != null)
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
final Collection<?> coll = (Collection<?>) value;
|
||||
if (coll.size() > 0)
|
||||
{
|
||||
strValue = coll.iterator().next().toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strValue = value.toString();
|
||||
}
|
||||
}
|
||||
return strValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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 received 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.descriptor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.alfresco.repo.descriptor.DescriptorServiceImpl.BaseDescriptor;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Manages retrieval of the server Descriptor from a read-only resource file.
|
||||
*/
|
||||
public class ServerDescriptorDAOImpl implements DescriptorDAO
|
||||
{
|
||||
|
||||
/** The repository name. */
|
||||
private String repositoryName;
|
||||
|
||||
/** The server properties. */
|
||||
protected Properties serverProperties;
|
||||
|
||||
/**
|
||||
* Sets the repository properties from a resource file.
|
||||
*
|
||||
* @param repositoryName
|
||||
* the repository name
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public void setRepositoryName(final String repositoryName) throws IOException
|
||||
{
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server descriptor from a resource file.
|
||||
*
|
||||
* @param descriptorResource
|
||||
* resource containing server descriptor meta-data
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public void setResource(final Resource descriptorResource) throws IOException
|
||||
{
|
||||
this.serverProperties = new Properties();
|
||||
this.serverProperties.load(descriptorResource.getInputStream());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.DescriptorPersistence#getDescriptor()
|
||||
*/
|
||||
public Descriptor getDescriptor()
|
||||
{
|
||||
return new ServerDescriptor();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.DescriptorPersistence#getLicenseKey()
|
||||
*/
|
||||
public byte[] getLicenseKey()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.service.descriptor.DescriptorPersistence#updateDescriptor(org.alfresco.service.descriptor.Descriptor
|
||||
* )
|
||||
*/
|
||||
public Descriptor updateDescriptor(final Descriptor serverDescriptor)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.DescriptorPersistence#updateLicenseKey(byte[])
|
||||
*/
|
||||
public void updateLicenseKey(final byte[] key)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Server Descriptor whose meta-data is retrieved from run-time environment.
|
||||
*/
|
||||
private class ServerDescriptor extends BaseDescriptor
|
||||
{
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getId()
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return "<Unknown";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.repositoryName == null ? "<Unknown>"
|
||||
: ServerDescriptorDAOImpl.this.repositoryName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
|
||||
*/
|
||||
public String getVersionMajor()
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.serverProperties.getProperty("version.major");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionMinor()
|
||||
*/
|
||||
public String getVersionMinor()
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.serverProperties.getProperty("version.minor");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionRevision()
|
||||
*/
|
||||
public String getVersionRevision()
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.serverProperties.getProperty("version.revision");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionLabel()
|
||||
*/
|
||||
public String getVersionLabel()
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.serverProperties.getProperty("version.label");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
|
||||
*/
|
||||
public String getVersionBuild()
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.serverProperties.getProperty("version.build");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getEdition()
|
||||
*/
|
||||
public String getEdition()
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.serverProperties.getProperty("version.edition");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getSchema()
|
||||
*/
|
||||
public int getSchema()
|
||||
{
|
||||
return getSchema(ServerDescriptorDAOImpl.this.serverProperties.getProperty("version.schema"));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptorKeys()
|
||||
*/
|
||||
public String[] getDescriptorKeys()
|
||||
{
|
||||
final String[] keys = new String[ServerDescriptorDAOImpl.this.serverProperties.size()];
|
||||
ServerDescriptorDAOImpl.this.serverProperties.keySet().toArray(keys);
|
||||
return keys;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.descriptor.Descriptor#getDescriptor(java.lang.String)
|
||||
*/
|
||||
public String getDescriptor(final String key)
|
||||
{
|
||||
return ServerDescriptorDAOImpl.this.serverProperties.getProperty(key, "");
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,6 +15,6 @@ public class AlfrescoOracle10gDialect extends Oracle10gDialect
|
||||
public AlfrescoOracle10gDialect()
|
||||
{
|
||||
super();
|
||||
registerColumnType( Types.VARCHAR, "blob" );
|
||||
registerColumnType( Types.VARBINARY, "blob" );
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,6 @@ public class AlfrescoOracle9iDialect extends Oracle9iDialect
|
||||
public AlfrescoOracle9iDialect()
|
||||
{
|
||||
super();
|
||||
registerColumnType( Types.VARCHAR, "blob" );
|
||||
registerColumnType( Types.VARBINARY, "blob" );
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -47,6 +48,9 @@ public class BehaviourFilterImpl implements BehaviourFilter
|
||||
// Dictionary Service
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
// Tenant Service
|
||||
private TenantService tenantService;
|
||||
|
||||
/**
|
||||
* @param dictionaryService dictionary service
|
||||
*/
|
||||
@@ -54,6 +58,14 @@ public class BehaviourFilterImpl implements BehaviourFilter
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantService dictionary service
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.policy.BehaviourFilter#disableBehaviour(org.alfresco.service.namespace.QName)
|
||||
@@ -79,6 +91,8 @@ public class BehaviourFilterImpl implements BehaviourFilter
|
||||
*/
|
||||
public boolean disableBehaviour(NodeRef nodeRef, QName className)
|
||||
{
|
||||
nodeRef = tenantService.getName(nodeRef);
|
||||
|
||||
Map<NodeRef,List<QName>> filters = nodeRefFilter.get();
|
||||
if (filters == null)
|
||||
{
|
||||
@@ -116,6 +130,8 @@ public class BehaviourFilterImpl implements BehaviourFilter
|
||||
*/
|
||||
public void enableBehaviour(NodeRef nodeRef, QName className)
|
||||
{
|
||||
nodeRef = tenantService.getName(nodeRef);
|
||||
|
||||
Map<NodeRef,List<QName>> filters = nodeRefFilter.get();
|
||||
if (filters != null)
|
||||
{
|
||||
@@ -136,6 +152,8 @@ public class BehaviourFilterImpl implements BehaviourFilter
|
||||
*/
|
||||
public void enableBehaviours(NodeRef nodeRef)
|
||||
{
|
||||
nodeRef = tenantService.getName(nodeRef);
|
||||
|
||||
Map<NodeRef,List<QName>> filters = nodeRefFilter.get();
|
||||
if (filters != null)
|
||||
{
|
||||
@@ -166,6 +184,8 @@ public class BehaviourFilterImpl implements BehaviourFilter
|
||||
return false;
|
||||
}
|
||||
|
||||
nodeRef = tenantService.getName(nodeRef);
|
||||
|
||||
// check node level filters
|
||||
Map<NodeRef,List<QName>> nodeFilters = nodeRefFilter.get();
|
||||
if (nodeFilters != null)
|
||||
|
@@ -324,8 +324,7 @@ public class MultiTNodeServiceInterceptor extends DelegatingIntroductionIntercep
|
||||
else if (rawValue instanceof ChildAssociationRef)
|
||||
{
|
||||
ChildAssociationRef ref = (ChildAssociationRef) rawValue;
|
||||
// TODO use getBaseName ... fix tenant bootstrap
|
||||
value = tenantService.getName(ref);
|
||||
value = tenantService.getBaseName(ref);
|
||||
}
|
||||
else if (rawValue instanceof AssociationRef)
|
||||
{
|
||||
|
@@ -34,84 +34,93 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springmodules.workflow.jbpm31.JbpmFactoryLocator;
|
||||
|
||||
/**
|
||||
* Implementation of Spring Module's JbpmConfigurationFactoryBean for
|
||||
* Jbpm 3.2.
|
||||
*
|
||||
* Implementation of Spring Module's JbpmConfigurationFactoryBean for Jbpm 3.2.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author davidc
|
||||
*/
|
||||
public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, FactoryBean, BeanFactoryAware, BeanNameAware
|
||||
public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, FactoryBean, BeanFactoryAware,
|
||||
BeanNameAware, DisposableBean
|
||||
{
|
||||
private JbpmConfiguration jbpmConfiguration;
|
||||
private ObjectFactory objectFactory;
|
||||
private Resource configuration;
|
||||
private SessionFactory sessionFactory;
|
||||
private String contextName = JbpmContext.DEFAULT_JBPM_CONTEXT_NAME;
|
||||
|
||||
|
||||
/**
|
||||
* FactoryLocator
|
||||
*/
|
||||
private JbpmFactoryLocator factoryLocator = new JbpmFactoryLocator();
|
||||
private final AlfrescoJbpmFactoryLocator factoryLocator = new AlfrescoJbpmFactoryLocator();
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
|
||||
*/
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
|
||||
public void setBeanFactory(final BeanFactory beanFactory) throws BeansException
|
||||
{
|
||||
factoryLocator.setBeanFactory(beanFactory);
|
||||
this.factoryLocator.setBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setBeanName(String name)
|
||||
public void setBeanName(final String name)
|
||||
{
|
||||
factoryLocator.setBeanName(name);
|
||||
this.factoryLocator.setBeanName(name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
if (configuration == null)
|
||||
if (this.configuration == null)
|
||||
{
|
||||
throw new IllegalArgumentException("configuration or objectFactory property need to be not null");
|
||||
}
|
||||
|
||||
// 1. Construct Jbpm Configuration
|
||||
// NOTE: Jbpm 3.2 adds a JbpmConfiguration value to its context
|
||||
InputStream stream = configuration.getInputStream();
|
||||
jbpmConfiguration = JbpmConfiguration.parseInputStream(stream);
|
||||
final InputStream stream = this.configuration.getInputStream();
|
||||
this.jbpmConfiguration = JbpmConfiguration.parseInputStream(stream);
|
||||
|
||||
// 2. inject the HB session factory if it is the case
|
||||
if (sessionFactory != null)
|
||||
if (this.sessionFactory != null)
|
||||
{
|
||||
JbpmContext context = jbpmConfiguration.createJbpmContext(contextName);
|
||||
final JbpmContext context = this.jbpmConfiguration.createJbpmContext(this.contextName);
|
||||
try
|
||||
{
|
||||
context.setSessionFactory(sessionFactory);
|
||||
} finally
|
||||
context.setSessionFactory(this.sessionFactory);
|
||||
}
|
||||
finally
|
||||
{
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObject()
|
||||
*/
|
||||
public Object getObject() throws Exception
|
||||
{
|
||||
return jbpmConfiguration;
|
||||
return this.jbpmConfiguration;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||
*/
|
||||
public Class getObjectType()
|
||||
@@ -119,7 +128,8 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
||||
return JbpmConfiguration.class;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.FactoryBean#isSingleton()
|
||||
*/
|
||||
public boolean isSingleton()
|
||||
@@ -132,13 +142,14 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
||||
*/
|
||||
public Resource getConfiguration()
|
||||
{
|
||||
return configuration;
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configuration The configuration to set
|
||||
* @param configuration
|
||||
* The configuration to set
|
||||
*/
|
||||
public void setConfiguration(Resource configuration)
|
||||
public void setConfiguration(final Resource configuration)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
}
|
||||
@@ -148,13 +159,14 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
||||
*/
|
||||
public ObjectFactory getObjectFactory()
|
||||
{
|
||||
return objectFactory;
|
||||
return this.objectFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param objectFactory The objectFactory to set
|
||||
* @param objectFactory
|
||||
* The objectFactory to set
|
||||
*/
|
||||
public void setObjectFactory(ObjectFactory objectFactory)
|
||||
public void setObjectFactory(final ObjectFactory objectFactory)
|
||||
{
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
@@ -164,13 +176,14 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
||||
*/
|
||||
public String getContextName()
|
||||
{
|
||||
return contextName;
|
||||
return this.contextName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contextName The contextName to set
|
||||
* @param contextName
|
||||
* The contextName to set
|
||||
*/
|
||||
public void setContextName(String contextName)
|
||||
public void setContextName(final String contextName)
|
||||
{
|
||||
this.contextName = contextName;
|
||||
}
|
||||
@@ -180,15 +193,37 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
||||
*/
|
||||
public SessionFactory getSessionFactory()
|
||||
{
|
||||
return sessionFactory;
|
||||
return this.sessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionFactory The sessionFactory to set
|
||||
* @param sessionFactory
|
||||
* The sessionFactory to set
|
||||
*/
|
||||
public void setSessionFactory(SessionFactory sessionFactory)
|
||||
public void setSessionFactory(final SessionFactory sessionFactory)
|
||||
{
|
||||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||
*/
|
||||
public void destroy() throws Exception
|
||||
{
|
||||
this.factoryLocator.destroy();
|
||||
}
|
||||
|
||||
private static class AlfrescoJbpmFactoryLocator extends JbpmFactoryLocator
|
||||
{
|
||||
public void destroy()
|
||||
{
|
||||
JbpmFactoryLocator.beanFactories.clear();
|
||||
JbpmFactoryLocator.beanFactoriesNames.clear();
|
||||
JbpmFactoryLocator.referenceCounter.clear();
|
||||
JbpmFactoryLocator.canUseDefaultBeanFactory = true;
|
||||
JbpmFactoryLocator.defaultFactory = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -71,5 +71,4 @@ public interface DescriptorService
|
||||
*/
|
||||
@NotAuditable
|
||||
public LicenseDescriptor getLicenseDescriptor();
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 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
|
||||
@@ -18,7 +18,7 @@
|
||||
* 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
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
@@ -27,9 +27,8 @@ package org.alfresco.service.license;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
|
||||
|
||||
/**
|
||||
* Contract for managing licenses
|
||||
* Contract for managing licenses.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
@@ -38,24 +37,33 @@ public interface LicenseService
|
||||
{
|
||||
|
||||
/**
|
||||
* Verify License
|
||||
* Begin the license verification loop. Throws an exception if a new .lic file has been supplied that is invalid.
|
||||
* Will quietly make the repository read only if there is no license and the repository isn't eligible for the free
|
||||
* trial period or the license has expired.
|
||||
*
|
||||
* @throws LicenseException
|
||||
* if an invalid .lic file has been supplied
|
||||
*/
|
||||
@NotAuditable
|
||||
public void verifyLicense() throws LicenseException;
|
||||
|
||||
|
||||
/**
|
||||
* Get description of installed license
|
||||
* Was the license known to be valid the last time it was checked?.
|
||||
*
|
||||
* @return license descriptor (or null, if one is not installed)
|
||||
* @throws LicenseException
|
||||
* @return true if there is a valid license
|
||||
*/
|
||||
public boolean isLicenseValid();
|
||||
|
||||
/**
|
||||
* Get description of installed license.
|
||||
*
|
||||
* @return license descriptor (or null, if no valid license is installed)
|
||||
*/
|
||||
@NotAuditable
|
||||
public LicenseDescriptor getLicense() throws LicenseException;
|
||||
|
||||
public LicenseDescriptor getLicense();
|
||||
|
||||
/**
|
||||
* Informs the service it is being shutdown
|
||||
* Informs the service it is being shutdown.
|
||||
*/
|
||||
@NotAuditable
|
||||
public void shutdown();
|
||||
|
Reference in New Issue
Block a user