mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Yet another merge from head to WCM-DEV2.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3774 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,10 +41,10 @@ public class FTPDate
|
||||
* Pack a date string in Unix format The format is 'Mmm dd hh:mm' if the file is less than six
|
||||
* months old, else the format is 'Mmm dd yyyy'.
|
||||
*
|
||||
* @param buf StringBuffer
|
||||
* @param buf StringBuilder
|
||||
* @param dt Date
|
||||
*/
|
||||
public final static void packUnixDate(StringBuffer buf, Date dt)
|
||||
public final static void packUnixDate(StringBuilder buf, Date dt)
|
||||
{
|
||||
|
||||
// Check if the date is valid
|
||||
|
@@ -1320,11 +1320,10 @@ public class FTPSrvSession extends SrvSession implements Runnable
|
||||
|
||||
// Output the file information to the client
|
||||
|
||||
StringBuffer str = new StringBuffer(256);
|
||||
StringBuilder str = new StringBuilder(256);
|
||||
|
||||
for (FileInfo finfo : files)
|
||||
{
|
||||
|
||||
// Build the output record
|
||||
|
||||
str.setLength(0);
|
||||
|
@@ -180,7 +180,7 @@ public class PassthruAuthenticator extends CifsAuthenticator implements SessionL
|
||||
// using the session that has already been setup.
|
||||
|
||||
AuthenticateSession authSess = passDetails.getAuthenticateSession();
|
||||
authSess.doSessionSetup(client.getUserName(), client.getANSIPassword(), client.getPassword());
|
||||
authSess.doSessionSetup(client.getDomain(), client.getUserName(), null, client.getANSIPassword(), client.getPassword());
|
||||
|
||||
// Check if the user has been logged on as a guest
|
||||
|
||||
|
@@ -113,6 +113,11 @@ public class CheckInOutDesktopAction extends DesktopAction {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Dump the error
|
||||
|
||||
if ( logger.isErrorEnabled())
|
||||
logger.error("Desktop action error", ex);
|
||||
|
||||
// Return an error status and message
|
||||
|
||||
response.setStatus(StsError, "Checkin failed for " + target.getTarget() + ", " + ex.getMessage());
|
||||
@@ -122,6 +127,19 @@ public class CheckInOutDesktopAction extends DesktopAction {
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check if the file is locked
|
||||
|
||||
if ( getNodeService().hasAspect( target.getNode(), ContentModel.ASPECT_LOCKABLE)) {
|
||||
|
||||
// Get the lock type
|
||||
|
||||
String lockTypeStr = (String) getNodeService().getProperty( target.getNode(), ContentModel.PROP_LOCK_TYPE);
|
||||
if ( lockTypeStr != null) {
|
||||
response.setStatus(StsError, "Checkout failed, file is locked");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
// Check out the file
|
||||
|
||||
NodeRef workingCopyNode = getCheckInOutService().checkout( target.getNode());
|
||||
@@ -149,6 +167,11 @@ public class CheckInOutDesktopAction extends DesktopAction {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Dump the error
|
||||
|
||||
if ( logger.isErrorEnabled())
|
||||
logger.error("Desktop action error", ex);
|
||||
|
||||
// Return an error status and message
|
||||
|
||||
response.setStatus(StsError, "Failed to checkout " + target.getTarget() + ", " + ex.getMessage());
|
||||
|
@@ -47,6 +47,6 @@ public class CmdLineDesktopAction extends DesktopAction {
|
||||
|
||||
// Return a URL in the status message
|
||||
|
||||
return new DesktopResponse(StsCommandLine, "C:\\Windows\\notepad.exe");
|
||||
return new DesktopResponse(StsCommandLine, "%SystemRoot%\\notepad.exe");
|
||||
}
|
||||
}
|
||||
|
@@ -1,272 +1,268 @@
|
||||
/*
|
||||
* 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.model;
|
||||
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Content Model Constants
|
||||
*/
|
||||
public interface ContentModel
|
||||
{
|
||||
//
|
||||
// System Model Definitions
|
||||
//
|
||||
|
||||
// base type constants
|
||||
static final QName TYPE_BASE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "base");
|
||||
static final QName ASPECT_REFERENCEABLE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "referenceable");
|
||||
static final QName PROP_STORE_PROTOCOL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-protocol");
|
||||
static final QName PROP_STORE_IDENTIFIER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-identifier");
|
||||
static final QName PROP_NODE_UUID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-uuid");
|
||||
static final QName PROP_NODE_DBID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
|
||||
|
||||
// tag for incomplete nodes
|
||||
static final QName ASPECT_INCOMPLETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "incomplete");
|
||||
|
||||
// tag for temporary nodes
|
||||
static final QName ASPECT_TEMPORARY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "temporary");
|
||||
|
||||
// archived nodes aspect constants
|
||||
static final QName ASPECT_ARCHIVED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived");
|
||||
static final QName PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalParentAssoc");
|
||||
static final QName PROP_ARCHIVED_BY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedBy");
|
||||
static final QName PROP_ARCHIVED_DATE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedDate");
|
||||
static final QName PROP_ARCHIVED_ORIGINAL_OWNER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalOwner");
|
||||
static final QName ASPECT_ARCHIVED_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived-assocs");
|
||||
static final QName PROP_ARCHIVED_PARENT_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedParentAssocs");
|
||||
static final QName PROP_ARCHIVED_CHILD_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedChildAssocs");
|
||||
static final QName PROP_ARCHIVED_SOURCE_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedSourceAssocs");
|
||||
static final QName PROP_ARCHIVED_TARGET_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedTargetAssocs");
|
||||
|
||||
// referenceable aspect constants
|
||||
static final QName TYPE_REFERENCE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "reference");
|
||||
static final QName PROP_REFERENCE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "reference");
|
||||
|
||||
// container type constants
|
||||
static final QName TYPE_CONTAINER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "container");
|
||||
/** child association type supported by {@link #TYPE_CONTAINER} */
|
||||
static final QName ASSOC_CHILDREN =QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "children");
|
||||
|
||||
// roots
|
||||
static final QName ASPECT_ROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "aspect_root");
|
||||
static final QName TYPE_STOREROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store_root");
|
||||
|
||||
// descriptor properties
|
||||
static final QName PROP_SYS_VERSION_MAJOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMajor");
|
||||
static final QName PROP_SYS_VERSION_MINOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMinor");
|
||||
static final QName PROP_SYS_VERSION_REVISION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionRevision");
|
||||
static final QName PROP_SYS_VERSION_LABEL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionLabel");
|
||||
static final QName PROP_SYS_VERSION_BUILD = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionBuild");
|
||||
static final QName PROP_SYS_VERSION_SCHEMA = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionSchema");
|
||||
static final QName PROP_SYS_VERSION_EDITION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionEdition");
|
||||
|
||||
|
||||
//
|
||||
// Content Model Definitions
|
||||
//
|
||||
|
||||
// content management type constants
|
||||
static final QName TYPE_CMOBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "cmobject");
|
||||
static final QName PROP_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "name");
|
||||
|
||||
// copy aspect constants
|
||||
static final QName ASPECT_COPIEDFROM = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copiedfrom");
|
||||
static final QName PROP_COPY_REFERENCE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "source");
|
||||
|
||||
// working copy aspect contants
|
||||
static final QName ASPECT_WORKING_COPY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingcopy");
|
||||
static final QName PROP_WORKING_COPY_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingCopyOwner");
|
||||
|
||||
// content type and aspect constants
|
||||
static final QName TYPE_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content");
|
||||
static final QName PROP_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content");
|
||||
static final QName TYPE_AVM_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmcontent");
|
||||
static final QName TYPE_AVM_PLAIN_CONTENT =
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmplaincontent");
|
||||
static final QName TYPE_AVM_LAYERED_CONTENT =
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmlayeredcontent");
|
||||
static final QName PROP_AVM_FILE_INDIRECTION =
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmfileindirection");
|
||||
|
||||
// title aspect
|
||||
static final QName ASPECT_TITLED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "titled");
|
||||
static final QName PROP_TITLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "title");
|
||||
static final QName PROP_DESCRIPTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "description");
|
||||
|
||||
// auditable aspect
|
||||
static final QName ASPECT_AUDITABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "auditable");
|
||||
static final QName PROP_CREATED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "created");
|
||||
static final QName PROP_CREATOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "creator");
|
||||
static final QName PROP_MODIFIED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modified");
|
||||
static final QName PROP_MODIFIER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modifier");
|
||||
static final QName PROP_ACCESSED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "accessed");
|
||||
|
||||
// author aspect
|
||||
static final QName ASPECT_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "author");
|
||||
static final QName PROP_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "author");
|
||||
|
||||
// categories
|
||||
static final QName TYPE_CATEGORYROOT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "category_root");
|
||||
static final QName ASPECT_CLASSIFIABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "classifiable");
|
||||
//static final QName ASPECT_CATEGORISATION = QName.createQName(NamespaceService.ALFRESCO_URI, "aspect_categorisation");
|
||||
static final QName ASPECT_GEN_CLASSIFIABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "generalclassifiable");
|
||||
static final QName TYPE_CATEGORY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "category");
|
||||
static final QName PROP_CATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categories");
|
||||
static final QName ASSOC_CATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categories");
|
||||
static final QName ASSOC_SUBCATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subcategories");
|
||||
|
||||
// lock aspect
|
||||
public final static QName ASPECT_LOCKABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockable");
|
||||
public final static QName PROP_LOCK_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockOwner");
|
||||
public final static QName PROP_LOCK_TYPE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockType");
|
||||
public final static QName PROP_EXPIRY_DATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "expiryDate");
|
||||
|
||||
// version aspect
|
||||
static final QName ASPECT_VERSIONABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "versionable");
|
||||
static final QName PROP_VERSION_LABEL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "versionLabel");
|
||||
static final QName PROP_INITIAL_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "initialVersion");
|
||||
static final QName PROP_AUTO_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "autoVersion");
|
||||
|
||||
// folders
|
||||
static final QName TYPE_SYSTEM_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "systemfolder");
|
||||
static final QName TYPE_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "folder");
|
||||
/** child association type supported by {@link #TYPE_FOLDER} */
|
||||
static final QName ASSOC_CONTAINS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "contains");
|
||||
static final QName TYPE_AVM_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmfolder");
|
||||
static final QName TYPE_AVM_PLAIN_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmplainfolder");
|
||||
static final QName TYPE_AVM_LAYERED_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmlayeredfolder");
|
||||
static final QName PROP_AVM_DIR_INDIRECTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmdirindirection");
|
||||
|
||||
// person
|
||||
static final QName TYPE_PERSON = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "person");
|
||||
static final QName PROP_USERNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "userName");
|
||||
static final QName PROP_HOMEFOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "homeFolder");
|
||||
static final QName PROP_FIRSTNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "firstName");
|
||||
static final QName PROP_LASTNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lastName");
|
||||
static final QName PROP_EMAIL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "email");
|
||||
static final QName PROP_ORGID = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "organizationId");
|
||||
|
||||
// Ownable aspect
|
||||
static final QName ASPECT_OWNABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ownable");
|
||||
static final QName PROP_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "owner");
|
||||
|
||||
// Templatable aspect
|
||||
static final QName ASPECT_TEMPLATABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "templatable");
|
||||
static final QName PROP_TEMPLATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "template");
|
||||
|
||||
// Dictionary model
|
||||
public static final QName TYPE_DICTIONARY_MODEL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "dictionaryModel");
|
||||
public static final QName PROP_MODEL_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelName");
|
||||
public static final QName PROP_MODEL_DESCRIPTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelDescription");
|
||||
public static final QName PROP_MODEL_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelAuthor");
|
||||
public static final QName PROP_MODEL_PUBLISHED_DATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelPublishedDate");
|
||||
public static final QName PROP_MODEL_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelVersion");
|
||||
public static final QName PROP_MODEL_ACTIVE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelActive");
|
||||
|
||||
// referencing aspect
|
||||
public static final QName ASPECT_REFERENCING = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "referencing");
|
||||
public static final QName ASSOC_REFERENCES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "references");
|
||||
|
||||
// link object
|
||||
public static final QName TYPE_LINK = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "link");
|
||||
public static final QName PROP_LINK_DESTINATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "destination");
|
||||
|
||||
// email aspect
|
||||
public static final QName ASPECT_MAILED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "emailed");
|
||||
public static final QName PROP_SENTDATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "sentdate");
|
||||
public static final QName PROP_ORIGINATOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "originator");
|
||||
public static final QName PROP_ADDRESSEE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressee");
|
||||
public static final QName PROP_ADDRESSEES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressees");
|
||||
public static final QName PROP_SUBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subjectline");
|
||||
|
||||
// mounted aspect
|
||||
public static final QName ASPECT_MOUNTED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mounted");
|
||||
public static final QName PROP_MOUNTPOINT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mountpoint");
|
||||
|
||||
// countable aspect
|
||||
public static final QName ASPECT_COUNTABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "countable");
|
||||
public static final QName PROP_HITS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "hits");
|
||||
public static final QName PROP_COUNTER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "counter");
|
||||
|
||||
|
||||
//
|
||||
// Application Model Definitions
|
||||
//
|
||||
|
||||
// workflow
|
||||
static final QName ASPECT_SIMPLE_WORKFLOW = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "simpleworkflow");
|
||||
static final QName PROP_APPROVE_STEP = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "approveStep");
|
||||
static final QName PROP_APPROVE_FOLDER = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "approveFolder");
|
||||
static final QName PROP_APPROVE_MOVE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "approveMove");
|
||||
static final QName PROP_REJECT_STEP = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "rejectStep");
|
||||
static final QName PROP_REJECT_FOLDER = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "rejectFolder");
|
||||
static final QName PROP_REJECT_MOVE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "rejectMove");
|
||||
|
||||
// ui facets aspect
|
||||
static final QName ASPECT_UIFACETS = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "uifacets");
|
||||
static final QName PROP_ICON = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "icon");
|
||||
|
||||
// inlineeditable aspect
|
||||
static final QName ASPECT_INLINEEDITABLE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "inlineeditable");
|
||||
static final QName PROP_EDITINLINE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "editInline");
|
||||
|
||||
// configurable aspect
|
||||
static final QName ASPECT_CONFIGURABLE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "configurable");
|
||||
static final QName TYPE_CONFIGURATIONS = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "configurations");
|
||||
static final QName ASSOC_CONFIGURATIONS = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "configurations");
|
||||
|
||||
// object links
|
||||
static final QName TYPE_FILELINK = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "filelink");
|
||||
static final QName TYPE_FOLDERLINK = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "folderlink");
|
||||
|
||||
// feed source aspect
|
||||
static final QName ASPECT_FEEDSOURCE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "feedsource");
|
||||
static final QName PROP_FEEDTEMPLATE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "template");
|
||||
|
||||
// AVM web folder
|
||||
static final QName TYPE_AVMWEBFOLDER = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "webfolder");
|
||||
static final QName PROP_AVMSTORE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "avmstore");
|
||||
|
||||
|
||||
//
|
||||
// User Model Definitions
|
||||
//
|
||||
|
||||
static final String USER_MODEL_URI = "http://www.alfresco.org/model/user/1.0";
|
||||
static final String USER_MODEL_PREFIX = "usr";
|
||||
|
||||
static final QName TYPE_USER = QName.createQName(USER_MODEL_URI, "user");
|
||||
static final QName PROP_USER_USERNAME = QName.createQName(USER_MODEL_URI, "username");
|
||||
static final QName PROP_PASSWORD = QName.createQName(USER_MODEL_URI, "password");
|
||||
static final QName PROP_ENABLED = QName.createQName(USER_MODEL_URI, "enabled");
|
||||
static final QName PROP_ACCOUNT_EXPIRES = QName.createQName(USER_MODEL_URI, "accountExpires");
|
||||
static final QName PROP_ACCOUNT_EXPIRY_DATE = QName.createQName(USER_MODEL_URI, "accountExpiryDate");
|
||||
static final QName PROP_CREDENTIALS_EXPIRE = QName.createQName(USER_MODEL_URI, "credentialsExpire");
|
||||
static final QName PROP_CREDENTIALS_EXPIRY_DATE = QName.createQName(USER_MODEL_URI, "credentialsExpiryDate");
|
||||
static final QName PROP_ACCOUNT_LOCKED = QName.createQName(USER_MODEL_URI, "accountLocked");
|
||||
static final QName PROP_SALT = QName.createQName(USER_MODEL_URI, "salt");
|
||||
|
||||
static final QName TYPE_AUTHORITY = QName.createQName(USER_MODEL_URI, "authority");
|
||||
|
||||
static final QName TYPE_AUTHORITY_CONTAINER = QName.createQName(USER_MODEL_URI, "authorityContainer");
|
||||
static final QName PROP_AUTHORITY_NAME = QName.createQName(USER_MODEL_URI, "authorityName");
|
||||
static final QName ASSOC_MEMBER = QName.createQName(USER_MODEL_URI, "member");
|
||||
static final QName PROP_MEMBERS = QName.createQName(USER_MODEL_URI, "members");
|
||||
}
|
||||
/*
|
||||
* 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.model;
|
||||
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Content Model Constants
|
||||
*/
|
||||
public interface ContentModel
|
||||
{
|
||||
//
|
||||
// System Model Definitions
|
||||
//
|
||||
|
||||
// base type constants
|
||||
static final QName TYPE_BASE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "base");
|
||||
static final QName ASPECT_REFERENCEABLE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "referenceable");
|
||||
static final QName PROP_STORE_PROTOCOL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-protocol");
|
||||
static final QName PROP_STORE_IDENTIFIER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-identifier");
|
||||
static final QName PROP_NODE_UUID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-uuid");
|
||||
static final QName PROP_NODE_DBID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
|
||||
|
||||
// tag for incomplete nodes
|
||||
static final QName ASPECT_INCOMPLETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "incomplete");
|
||||
|
||||
// tag for temporary nodes
|
||||
static final QName ASPECT_TEMPORARY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "temporary");
|
||||
|
||||
// archived nodes aspect constants
|
||||
static final QName ASPECT_ARCHIVED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived");
|
||||
static final QName PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalParentAssoc");
|
||||
static final QName PROP_ARCHIVED_BY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedBy");
|
||||
static final QName PROP_ARCHIVED_DATE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedDate");
|
||||
static final QName PROP_ARCHIVED_ORIGINAL_OWNER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalOwner");
|
||||
static final QName ASPECT_ARCHIVED_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived-assocs");
|
||||
static final QName PROP_ARCHIVED_PARENT_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedParentAssocs");
|
||||
static final QName PROP_ARCHIVED_CHILD_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedChildAssocs");
|
||||
static final QName PROP_ARCHIVED_SOURCE_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedSourceAssocs");
|
||||
static final QName PROP_ARCHIVED_TARGET_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedTargetAssocs");
|
||||
|
||||
// referenceable aspect constants
|
||||
static final QName TYPE_REFERENCE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "reference");
|
||||
static final QName PROP_REFERENCE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "reference");
|
||||
|
||||
// container type constants
|
||||
static final QName TYPE_CONTAINER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "container");
|
||||
/** child association type supported by {@link #TYPE_CONTAINER} */
|
||||
static final QName ASSOC_CHILDREN =QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "children");
|
||||
|
||||
// roots
|
||||
static final QName ASPECT_ROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "aspect_root");
|
||||
static final QName TYPE_STOREROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store_root");
|
||||
|
||||
// descriptor properties
|
||||
static final QName PROP_SYS_VERSION_MAJOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMajor");
|
||||
static final QName PROP_SYS_VERSION_MINOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMinor");
|
||||
static final QName PROP_SYS_VERSION_REVISION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionRevision");
|
||||
static final QName PROP_SYS_VERSION_LABEL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionLabel");
|
||||
static final QName PROP_SYS_VERSION_BUILD = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionBuild");
|
||||
static final QName PROP_SYS_VERSION_SCHEMA = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionSchema");
|
||||
static final QName PROP_SYS_VERSION_EDITION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionEdition");
|
||||
|
||||
|
||||
//
|
||||
// Content Model Definitions
|
||||
//
|
||||
|
||||
// content management type constants
|
||||
static final QName TYPE_CMOBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "cmobject");
|
||||
static final QName PROP_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "name");
|
||||
|
||||
// copy aspect constants
|
||||
static final QName ASPECT_COPIEDFROM = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copiedfrom");
|
||||
static final QName PROP_COPY_REFERENCE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "source");
|
||||
|
||||
// working copy aspect contants
|
||||
static final QName ASPECT_WORKING_COPY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingcopy");
|
||||
static final QName PROP_WORKING_COPY_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "workingCopyOwner");
|
||||
|
||||
// content type and aspect constants
|
||||
static final QName TYPE_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content");
|
||||
static final QName PROP_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content");
|
||||
static final QName TYPE_AVM_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmcontent");
|
||||
static final QName TYPE_AVM_PLAIN_CONTENT =
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmplaincontent");
|
||||
static final QName TYPE_AVM_LAYERED_CONTENT =
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmlayeredcontent");
|
||||
static final QName PROP_AVM_FILE_INDIRECTION =
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmfileindirection");
|
||||
|
||||
// title aspect
|
||||
static final QName ASPECT_TITLED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "titled");
|
||||
static final QName PROP_TITLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "title");
|
||||
static final QName PROP_DESCRIPTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "description");
|
||||
|
||||
// auditable aspect
|
||||
static final QName ASPECT_AUDITABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "auditable");
|
||||
static final QName PROP_CREATED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "created");
|
||||
static final QName PROP_CREATOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "creator");
|
||||
static final QName PROP_MODIFIED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modified");
|
||||
static final QName PROP_MODIFIER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modifier");
|
||||
static final QName PROP_ACCESSED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "accessed");
|
||||
|
||||
// author aspect
|
||||
static final QName ASPECT_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "author");
|
||||
static final QName PROP_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "author");
|
||||
|
||||
// categories
|
||||
static final QName TYPE_CATEGORYROOT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "category_root");
|
||||
static final QName ASPECT_CLASSIFIABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "classifiable");
|
||||
//static final QName ASPECT_CATEGORISATION = QName.createQName(NamespaceService.ALFRESCO_URI, "aspect_categorisation");
|
||||
static final QName ASPECT_GEN_CLASSIFIABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "generalclassifiable");
|
||||
static final QName TYPE_CATEGORY = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "category");
|
||||
static final QName PROP_CATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categories");
|
||||
static final QName ASSOC_CATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categories");
|
||||
static final QName ASSOC_SUBCATEGORIES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subcategories");
|
||||
|
||||
// lock aspect
|
||||
public final static QName ASPECT_LOCKABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockable");
|
||||
public final static QName PROP_LOCK_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockOwner");
|
||||
public final static QName PROP_LOCK_TYPE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lockType");
|
||||
public final static QName PROP_EXPIRY_DATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "expiryDate");
|
||||
|
||||
// version aspect
|
||||
static final QName ASPECT_VERSIONABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "versionable");
|
||||
static final QName PROP_VERSION_LABEL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "versionLabel");
|
||||
static final QName PROP_INITIAL_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "initialVersion");
|
||||
static final QName PROP_AUTO_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "autoVersion");
|
||||
|
||||
// folders
|
||||
static final QName TYPE_SYSTEM_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "systemfolder");
|
||||
static final QName TYPE_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "folder");
|
||||
/** child association type supported by {@link #TYPE_FOLDER} */
|
||||
static final QName ASSOC_CONTAINS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "contains");
|
||||
static final QName TYPE_AVM_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmfolder");
|
||||
static final QName TYPE_AVM_PLAIN_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmplainfolder");
|
||||
static final QName TYPE_AVM_LAYERED_FOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmlayeredfolder");
|
||||
static final QName PROP_AVM_DIR_INDIRECTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "avmdirindirection");
|
||||
|
||||
// person
|
||||
static final QName TYPE_PERSON = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "person");
|
||||
static final QName PROP_USERNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "userName");
|
||||
static final QName PROP_HOMEFOLDER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "homeFolder");
|
||||
static final QName PROP_FIRSTNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "firstName");
|
||||
static final QName PROP_LASTNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "lastName");
|
||||
static final QName PROP_EMAIL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "email");
|
||||
static final QName PROP_ORGID = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "organizationId");
|
||||
|
||||
// Ownable aspect
|
||||
static final QName ASPECT_OWNABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ownable");
|
||||
static final QName PROP_OWNER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "owner");
|
||||
|
||||
// Templatable aspect
|
||||
static final QName ASPECT_TEMPLATABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "templatable");
|
||||
static final QName PROP_TEMPLATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "template");
|
||||
|
||||
// Dictionary model
|
||||
public static final QName TYPE_DICTIONARY_MODEL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "dictionaryModel");
|
||||
public static final QName PROP_MODEL_NAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelName");
|
||||
public static final QName PROP_MODEL_DESCRIPTION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelDescription");
|
||||
public static final QName PROP_MODEL_AUTHOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelAuthor");
|
||||
public static final QName PROP_MODEL_PUBLISHED_DATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelPublishedDate");
|
||||
public static final QName PROP_MODEL_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelVersion");
|
||||
public static final QName PROP_MODEL_ACTIVE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "modelActive");
|
||||
|
||||
// referencing aspect
|
||||
public static final QName ASPECT_REFERENCING = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "referencing");
|
||||
public static final QName ASSOC_REFERENCES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "references");
|
||||
|
||||
// link object
|
||||
public static final QName TYPE_LINK = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "link");
|
||||
public static final QName PROP_LINK_DESTINATION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "destination");
|
||||
|
||||
// email aspect
|
||||
public static final QName ASPECT_MAILED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "emailed");
|
||||
public static final QName PROP_SENTDATE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "sentdate");
|
||||
public static final QName PROP_ORIGINATOR = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "originator");
|
||||
public static final QName PROP_ADDRESSEE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressee");
|
||||
public static final QName PROP_ADDRESSEES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressees");
|
||||
public static final QName PROP_SUBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subjectline");
|
||||
|
||||
// countable aspect
|
||||
public static final QName ASPECT_COUNTABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "countable");
|
||||
public static final QName PROP_HITS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "hits");
|
||||
public static final QName PROP_COUNTER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "counter");
|
||||
|
||||
|
||||
//
|
||||
// Application Model Definitions
|
||||
//
|
||||
|
||||
// workflow
|
||||
static final QName ASPECT_SIMPLE_WORKFLOW = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "simpleworkflow");
|
||||
static final QName PROP_APPROVE_STEP = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "approveStep");
|
||||
static final QName PROP_APPROVE_FOLDER = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "approveFolder");
|
||||
static final QName PROP_APPROVE_MOVE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "approveMove");
|
||||
static final QName PROP_REJECT_STEP = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "rejectStep");
|
||||
static final QName PROP_REJECT_FOLDER = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "rejectFolder");
|
||||
static final QName PROP_REJECT_MOVE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "rejectMove");
|
||||
|
||||
// ui facets aspect
|
||||
static final QName ASPECT_UIFACETS = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "uifacets");
|
||||
static final QName PROP_ICON = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "icon");
|
||||
|
||||
// inlineeditable aspect
|
||||
static final QName ASPECT_INLINEEDITABLE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "inlineeditable");
|
||||
static final QName PROP_EDITINLINE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "editInline");
|
||||
|
||||
// configurable aspect
|
||||
static final QName ASPECT_CONFIGURABLE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "configurable");
|
||||
static final QName TYPE_CONFIGURATIONS = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "configurations");
|
||||
static final QName ASSOC_CONFIGURATIONS = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "configurations");
|
||||
|
||||
// object links
|
||||
static final QName TYPE_FILELINK = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "filelink");
|
||||
static final QName TYPE_FOLDERLINK = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "folderlink");
|
||||
|
||||
// feed source aspect
|
||||
static final QName ASPECT_FEEDSOURCE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "feedsource");
|
||||
static final QName PROP_FEEDTEMPLATE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "template");
|
||||
|
||||
// AVM web folder
|
||||
static final QName TYPE_AVMWEBFOLDER = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "webfolder");
|
||||
static final QName PROP_AVMSTORE = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "avmstore");
|
||||
|
||||
|
||||
//
|
||||
// User Model Definitions
|
||||
//
|
||||
|
||||
static final String USER_MODEL_URI = "http://www.alfresco.org/model/user/1.0";
|
||||
static final String USER_MODEL_PREFIX = "usr";
|
||||
|
||||
static final QName TYPE_USER = QName.createQName(USER_MODEL_URI, "user");
|
||||
static final QName PROP_USER_USERNAME = QName.createQName(USER_MODEL_URI, "username");
|
||||
static final QName PROP_PASSWORD = QName.createQName(USER_MODEL_URI, "password");
|
||||
static final QName PROP_ENABLED = QName.createQName(USER_MODEL_URI, "enabled");
|
||||
static final QName PROP_ACCOUNT_EXPIRES = QName.createQName(USER_MODEL_URI, "accountExpires");
|
||||
static final QName PROP_ACCOUNT_EXPIRY_DATE = QName.createQName(USER_MODEL_URI, "accountExpiryDate");
|
||||
static final QName PROP_CREDENTIALS_EXPIRE = QName.createQName(USER_MODEL_URI, "credentialsExpire");
|
||||
static final QName PROP_CREDENTIALS_EXPIRY_DATE = QName.createQName(USER_MODEL_URI, "credentialsExpiryDate");
|
||||
static final QName PROP_ACCOUNT_LOCKED = QName.createQName(USER_MODEL_URI, "accountLocked");
|
||||
static final QName PROP_SALT = QName.createQName(USER_MODEL_URI, "salt");
|
||||
|
||||
static final QName TYPE_AUTHORITY = QName.createQName(USER_MODEL_URI, "authority");
|
||||
|
||||
static final QName TYPE_AUTHORITY_CONTAINER = QName.createQName(USER_MODEL_URI, "authorityContainer");
|
||||
static final QName PROP_AUTHORITY_NAME = QName.createQName(USER_MODEL_URI, "authorityName");
|
||||
static final QName ASSOC_MEMBER = QName.createQName(USER_MODEL_URI, "member");
|
||||
static final QName PROP_MEMBERS = QName.createQName(USER_MODEL_URI, "members");
|
||||
}
|
||||
|
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
@@ -47,6 +50,14 @@ public interface AuditComponent
|
||||
* an arbitrary list of parameters
|
||||
*/
|
||||
public void audit(String source, String description, NodeRef key, Object... args);
|
||||
|
||||
/**
|
||||
* Get the audit trail for a node.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -21,12 +21,15 @@ import java.lang.reflect.Method;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.Auditable;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -181,7 +184,7 @@ public class AuditComponentImpl implements AuditComponent
|
||||
*/
|
||||
public Object auditImpl(MethodInvocation mi) throws Throwable
|
||||
{
|
||||
AuditInfo auditInfo = new AuditInfo(auditConfiguration);
|
||||
AuditState auditInfo = new AuditState(auditConfiguration);
|
||||
// RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||
AuditMode auditMode = AuditMode.UNSET;
|
||||
try
|
||||
@@ -221,7 +224,7 @@ public class AuditComponentImpl implements AuditComponent
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
private AuditMode onError(AuditMode auditMode, AuditInfo auditInfo, MethodInvocation mi, Throwable t)
|
||||
private AuditMode onError(AuditMode auditMode, AuditState auditInfo, MethodInvocation mi, Throwable t)
|
||||
{
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||
{
|
||||
@@ -241,7 +244,7 @@ public class AuditComponentImpl implements AuditComponent
|
||||
* @param returnObject
|
||||
* @return
|
||||
*/
|
||||
private AuditMode postInvocation(AuditMode auditMode, AuditInfo auditInfo, MethodInvocation mi, Object returnObject)
|
||||
private AuditMode postInvocation(AuditMode auditMode, AuditState auditInfo, MethodInvocation mi, Object returnObject)
|
||||
{
|
||||
if (returnObject == null)
|
||||
{
|
||||
@@ -255,6 +258,33 @@ public class AuditComponentImpl implements AuditComponent
|
||||
{
|
||||
auditInfo.setReturnObject(returnObject.toString());
|
||||
}
|
||||
|
||||
Auditable auditable = mi.getMethod().getAnnotation(Auditable.class);
|
||||
if (auditable.key() == Auditable.Key.RETURN)
|
||||
{
|
||||
if (returnObject != null)
|
||||
{
|
||||
if (returnObject instanceof NodeRef)
|
||||
{
|
||||
NodeRef key = (NodeRef) returnObject;
|
||||
auditInfo.setKeyStore(key.getStoreRef());
|
||||
auditInfo.setKeyGUID(key.getId());
|
||||
}
|
||||
else if (returnObject instanceof StoreRef)
|
||||
{
|
||||
auditInfo.setKeyStore((StoreRef)returnObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user name is not set, try and set it after the method call.
|
||||
// This covers authentication when the user is only known after the call.
|
||||
|
||||
if (auditInfo.getUserIdentifier() == null)
|
||||
{
|
||||
auditInfo.setUserIdentifier(AuthenticationUtil.getCurrentUserName());
|
||||
}
|
||||
|
||||
return auditMode;
|
||||
}
|
||||
|
||||
@@ -266,7 +296,7 @@ public class AuditComponentImpl implements AuditComponent
|
||||
* @param mi
|
||||
* @return
|
||||
*/
|
||||
private AuditMode beforeInvocation(AuditMode auditMode, AuditInfo auditInfo, MethodInvocation mi)
|
||||
private AuditMode beforeInvocation(AuditMode auditMode, AuditState auditInfo, MethodInvocation mi)
|
||||
{
|
||||
AuditMode effectiveAuditMode = auditModel.beforeExecution(auditMode, mi);
|
||||
|
||||
@@ -283,27 +313,83 @@ public class AuditComponentImpl implements AuditComponent
|
||||
auditInfo.setFail(false);
|
||||
auditInfo.setFiltered(false);
|
||||
auditInfo.setHostAddress(auditHost);
|
||||
auditInfo.setKeyGUID(null);
|
||||
Auditable auditable = mi.getMethod().getAnnotation(Auditable.class);
|
||||
Object key = null;
|
||||
switch (auditable.key())
|
||||
{
|
||||
case ARG_0:
|
||||
key = mi.getArguments()[0];
|
||||
break;
|
||||
case ARG_1:
|
||||
key = mi.getArguments()[1];
|
||||
break;
|
||||
case ARG_2:
|
||||
key = mi.getArguments()[2];
|
||||
break;
|
||||
case ARG_3:
|
||||
key = mi.getArguments()[3];
|
||||
break;
|
||||
case ARG_4:
|
||||
key = mi.getArguments()[4];
|
||||
break;
|
||||
case ARG_5:
|
||||
key = mi.getArguments()[5];
|
||||
break;
|
||||
case ARG_6:
|
||||
key = mi.getArguments()[6];
|
||||
break;
|
||||
case ARG_7:
|
||||
key = mi.getArguments()[7];
|
||||
break;
|
||||
case ARG_8:
|
||||
key = mi.getArguments()[8];
|
||||
break;
|
||||
case ARG_9:
|
||||
key = mi.getArguments()[9];
|
||||
break;
|
||||
case NO_KEY:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (key != null)
|
||||
{
|
||||
if (key instanceof NodeRef)
|
||||
{
|
||||
auditInfo.setKeyStore(((NodeRef) key).getStoreRef());
|
||||
auditInfo.setKeyGUID(((NodeRef) key).getId());
|
||||
}
|
||||
else if (key instanceof StoreRef)
|
||||
{
|
||||
auditInfo.setKeyStore((StoreRef) key);
|
||||
}
|
||||
}
|
||||
auditInfo.setKeyPropertiesAfter(null);
|
||||
auditInfo.setKeyPropertiesBefore(null);
|
||||
auditInfo.setKeyStore(null);
|
||||
auditInfo.setMessage(null);
|
||||
if (mi.getArguments() != null)
|
||||
{
|
||||
Serializable[] serArgs = new Serializable[mi.getArguments().length];
|
||||
for (int i = 0; i < mi.getArguments().length; i++)
|
||||
{
|
||||
if (mi.getArguments()[i] == null)
|
||||
if ((auditable.recordable() == null)
|
||||
|| (auditable.recordable().length <= i) || auditable.recordable()[i])
|
||||
{
|
||||
serArgs[i] = null;
|
||||
}
|
||||
else if (mi.getArguments()[i] instanceof Serializable)
|
||||
{
|
||||
serArgs[i] = (Serializable) mi.getArguments()[i];
|
||||
if (mi.getArguments()[i] == null)
|
||||
{
|
||||
serArgs[i] = null;
|
||||
}
|
||||
else if (mi.getArguments()[i] instanceof Serializable)
|
||||
{
|
||||
serArgs[i] = (Serializable) mi.getArguments()[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
serArgs[i] = mi.getArguments()[i].toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
serArgs[i] = mi.getArguments()[i].toString();
|
||||
serArgs[i] = "********";
|
||||
}
|
||||
}
|
||||
auditInfo.setMethodArguments(serArgs);
|
||||
@@ -322,9 +408,9 @@ public class AuditComponentImpl implements AuditComponent
|
||||
/**
|
||||
* A simple audit entry Currently we ignore filtering here.
|
||||
*/
|
||||
public void audit(String source, String description, NodeRef key, Object... args)
|
||||
public void audit(String source, String description, NodeRef key, Object... args)
|
||||
{
|
||||
AuditInfo auditInfo = new AuditInfo(auditConfiguration);
|
||||
AuditState auditInfo = new AuditState(auditConfiguration);
|
||||
// RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||
AuditMode auditMode = AuditMode.UNSET;
|
||||
try
|
||||
@@ -353,18 +439,23 @@ public class AuditComponentImpl implements AuditComponent
|
||||
}
|
||||
}
|
||||
|
||||
private AuditMode onApplicationAudit(AuditMode auditMode, AuditInfo auditInfo, String source, String description,
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
return auditDAO.getAuditTrail(nodeRef);
|
||||
}
|
||||
|
||||
private AuditMode onApplicationAudit(AuditMode auditMode, AuditState auditInfo, String source, String description,
|
||||
NodeRef key, Object... args)
|
||||
{
|
||||
AuditMode effectiveAuditMode = auditModel.beforeExecution(auditMode, source, description, key, args);
|
||||
|
||||
if (auditMode != AuditMode.NONE)
|
||||
{
|
||||
if(source.equals(SYSTEM_APPLICATION))
|
||||
if (source.equals(SYSTEM_APPLICATION))
|
||||
{
|
||||
throw new AuditException("Application audit can not use the reserved identifier "+SYSTEM_APPLICATION);
|
||||
throw new AuditException("Application audit can not use the reserved identifier " + SYSTEM_APPLICATION);
|
||||
}
|
||||
|
||||
|
||||
auditInfo.setAuditApplication(source);
|
||||
auditInfo.setAuditConfiguration(auditConfiguration);
|
||||
auditInfo.setAuditMethod(null);
|
||||
@@ -374,10 +465,13 @@ public class AuditComponentImpl implements AuditComponent
|
||||
auditInfo.setFail(false);
|
||||
auditInfo.setFiltered(false);
|
||||
auditInfo.setHostAddress(auditHost);
|
||||
auditInfo.setKeyGUID(null);
|
||||
if (key != null)
|
||||
{
|
||||
auditInfo.setKeyStore(key.getStoreRef());
|
||||
auditInfo.setKeyGUID(key.getId());
|
||||
}
|
||||
auditInfo.setKeyPropertiesAfter(null);
|
||||
auditInfo.setKeyPropertiesBefore(null);
|
||||
auditInfo.setKeyStore(null);
|
||||
auditInfo.setMessage(description);
|
||||
if (args != null)
|
||||
{
|
||||
@@ -409,9 +503,9 @@ public class AuditComponentImpl implements AuditComponent
|
||||
|
||||
return effectiveAuditMode;
|
||||
}
|
||||
|
||||
private AuditMode onError(AuditMode auditMode, AuditInfo auditInfo, Throwable t, String source, String description,
|
||||
NodeRef key, Object... args)
|
||||
|
||||
private AuditMode onError(AuditMode auditMode, AuditState auditInfo, Throwable t, String source,
|
||||
String description, NodeRef key, Object... args)
|
||||
{
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||
{
|
||||
|
@@ -16,6 +16,11 @@
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* The interface to persist audit information.
|
||||
*
|
||||
@@ -28,5 +33,13 @@ public interface AuditDAO
|
||||
*
|
||||
* @param auditInfo
|
||||
*/
|
||||
public void audit(AuditInfo auditInfo);
|
||||
public void audit(AuditState auditInfo);
|
||||
|
||||
/**
|
||||
* Get the audit trail for a node.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef);
|
||||
}
|
||||
|
@@ -16,8 +16,12 @@
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -64,24 +68,49 @@ public class AuditServiceImpl implements AuditService
|
||||
auditComponent.audit(source, description, key, args);
|
||||
}
|
||||
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
return auditComponent.getAuditTrail(nodeRef);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
|
||||
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
AuditService as = (AuditService) ctx.getBean("AuditService");
|
||||
|
||||
TransactionService txs = (TransactionService) ctx.getBean("transactionComponent");
|
||||
UserTransaction tx = txs.getUserTransaction();
|
||||
tx.begin();
|
||||
as.audit("AuditedApp", "First");
|
||||
as.audit("AuditedApp", "Second", new NodeRef(new StoreRef("test", "audit"), "id"));
|
||||
as.audit("AuditedApp", "Third", new Object[]{"one", "two", "three"});
|
||||
as.audit("AuditedApp", "Fourth", new NodeRef(new StoreRef("test", "audit"), "id"), new Object[]{"one", "two", "three"});
|
||||
|
||||
as.audit("UnAuditedApp", "First");
|
||||
as.audit("UnAuditedApp", "Second", new NodeRef(new StoreRef("test", "audit"), "id"));
|
||||
as.audit("UnAuditedApp", "Third", new Object[]{"one", "two", "three"});
|
||||
as.audit("UnAuditedApp", "Fourth", new NodeRef(new StoreRef("test", "audit"), "id"), new Object[]{"one", "two", "three"});
|
||||
|
||||
AuthenticationUtil.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
|
||||
NodeRef nodeRef = new NodeRef(new StoreRef("test", "audit"), "id");
|
||||
as.audit("AuditedApp", "First");
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("AuditedApp", "Second", nodeRef);
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("AuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("AuditedApp", "Fourth",nodeRef, new Object[] { "one",
|
||||
"two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "First");
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "Second", nodeRef);
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "Fourth", nodeRef, new Object[] { "one",
|
||||
"two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
tx.commit();
|
||||
|
||||
}
|
||||
|
291
source/java/org/alfresco/repo/audit/AuditServiceTest.java
Normal file
291
source/java/org/alfresco/repo/audit/AuditServiceTest.java
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* 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.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.audit.model.AuditEntry;
|
||||
import org.alfresco.repo.audit.model.TrueFalseUnset;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.repo.security.permissions.PermissionServiceSPI;
|
||||
import org.alfresco.repo.security.permissions.impl.ModelDAO;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
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.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
|
||||
public class AuditServiceTest extends BaseSpringTest
|
||||
{
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
private PermissionServiceSPI permissionService;
|
||||
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
private ModelDAO permissionModelDAO;
|
||||
|
||||
private PersonService personService;
|
||||
|
||||
private AuthorityService authorityService;
|
||||
|
||||
private MutableAuthenticationDao authenticationDAO;
|
||||
|
||||
private NodeRef rootNodeRef;
|
||||
|
||||
private NodeRef systemNodeRef;
|
||||
|
||||
private AuditService auditService;
|
||||
|
||||
private AuditEntry auditEntry;
|
||||
|
||||
private NodeRef typesNodeRef;
|
||||
|
||||
private QName children;
|
||||
|
||||
private QName system;
|
||||
|
||||
private QName container;
|
||||
|
||||
private QName types;
|
||||
|
||||
public AuditServiceTest()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
protected void onSetUpInTransaction() throws Exception
|
||||
{
|
||||
nodeService = (NodeService) applicationContext.getBean("nodeService");
|
||||
dictionaryService = (DictionaryService) applicationContext.getBean(ServiceRegistry.DICTIONARY_SERVICE
|
||||
.getLocalName());
|
||||
permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService");
|
||||
namespacePrefixResolver = (NamespacePrefixResolver) applicationContext
|
||||
.getBean(ServiceRegistry.NAMESPACE_SERVICE.getLocalName());
|
||||
authenticationService = (AuthenticationService) applicationContext.getBean("authenticationService");
|
||||
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
||||
serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||
permissionModelDAO = (ModelDAO) applicationContext.getBean("permissionsModelDAO");
|
||||
personService = (PersonService) applicationContext.getBean("personService");
|
||||
authorityService = (AuthorityService) applicationContext.getBean("authorityService");
|
||||
|
||||
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||
authenticationDAO = (MutableAuthenticationDao) applicationContext.getBean("alfDaoImpl");
|
||||
|
||||
auditService = (AuditService) applicationContext.getBean("AuditService");
|
||||
auditEntry = (AuditEntry) applicationContext.getBean("auditModel");
|
||||
|
||||
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime());
|
||||
rootNodeRef = nodeService.getRootNode(storeRef);
|
||||
|
||||
children = ContentModel.ASSOC_CHILDREN;
|
||||
system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system");
|
||||
container = ContentModel.TYPE_CONTAINER;
|
||||
types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people");
|
||||
|
||||
systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef();
|
||||
typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef();
|
||||
Map<QName, Serializable> props = createPersonProperties("andy");
|
||||
nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef();
|
||||
props = createPersonProperties("lemur");
|
||||
nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef();
|
||||
|
||||
// create an authentication object e.g. the user
|
||||
if (authenticationDAO.userExists("andy"))
|
||||
{
|
||||
authenticationService.deleteAuthentication("andy");
|
||||
}
|
||||
authenticationService.createAuthentication("andy", "andy".toCharArray());
|
||||
|
||||
if (authenticationDAO.userExists("lemur"))
|
||||
{
|
||||
authenticationService.deleteAuthentication("lemur");
|
||||
}
|
||||
authenticationService.createAuthentication("lemur", "lemur".toCharArray());
|
||||
|
||||
if (authenticationDAO.userExists("admin"))
|
||||
{
|
||||
authenticationService.deleteAuthentication("admin");
|
||||
}
|
||||
authenticationService.createAuthentication("admin", "admin".toCharArray());
|
||||
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
|
||||
public void testApplicationAudit()
|
||||
{
|
||||
AuthenticationUtil.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
|
||||
NodeRef nodeRef = new NodeRef(new StoreRef("test", "audit"), "id");
|
||||
int start = auditService.getAuditTrail(nodeRef).size();
|
||||
int increment = auditEntry.getEnabled() == TrueFalseUnset.TRUE ? 1 : 0;
|
||||
auditService.audit("AuditedApp", "First");
|
||||
assertEquals(start, auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("AuditedApp", "Second", nodeRef);
|
||||
assertEquals(start + (1 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("AuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (1 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("AuditedApp", "Fourth", nodeRef, new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (2 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "First");
|
||||
assertEquals(start + (2 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "Second", nodeRef);
|
||||
assertEquals(start + (3 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (3 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "Fourth", nodeRef, new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (4 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
public void testNodeServiceAudit()
|
||||
{
|
||||
AuthenticationUtil.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
int start = auditService.getAuditTrail(typesNodeRef).size();
|
||||
int increment = auditEntry.getEnabled() == TrueFalseUnset.TRUE ? 1 : 0;
|
||||
|
||||
// Create
|
||||
|
||||
Map<QName, Serializable> props = createPersonProperties("woof");
|
||||
NodeRef created = serviceRegistry.getNodeService().createNode(typesNodeRef, children,
|
||||
ContentModel.TYPE_PERSON, container, props).getChildRef();
|
||||
assertEquals(start + (1 * increment), auditService.getAuditTrail(typesNodeRef).size());
|
||||
List<AuditInfo> list = auditService.getAuditTrail(typesNodeRef);
|
||||
assertEquals((1 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
// Update
|
||||
|
||||
serviceRegistry.getNodeService().setProperty(created, ContentModel.PROP_FIRSTNAME, "New First Name");
|
||||
assertEquals((2 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
// Update
|
||||
|
||||
serviceRegistry.getNodeService().setProperty(created, ContentModel.PROP_FIRSTNAME, "Next First Name");
|
||||
assertEquals((3 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
// Delete
|
||||
|
||||
serviceRegistry.getNodeService().deleteNode(created);
|
||||
assertEquals((4 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
list = auditService.getAuditTrail(created);
|
||||
assertNotNull(list);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
public void xtestCreateStore()
|
||||
{
|
||||
|
||||
AuthenticationUtil.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
serviceRegistry.getNodeService()
|
||||
.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_Audit_" + System.nanoTime());
|
||||
// Should have a query to support this - check direct in the DB
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
setComplete();
|
||||
}
|
||||
|
||||
public void xtestAuthenticartionDoesNotReportPasswords()
|
||||
{
|
||||
// Should have a query to support this - check direct in the DB
|
||||
AuthenticationUtil.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
serviceRegistry.getAuthenticationService().createAuthentication("cabbage", "cabbage".toCharArray());
|
||||
serviceRegistry.getAuthenticationService().updateAuthentication("cabbage", "cabbage".toCharArray(),
|
||||
"red".toCharArray());
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
serviceRegistry.getAuthenticationService().authenticate("cabbage", "red".toCharArray());
|
||||
}
|
||||
finally
|
||||
{
|
||||
serviceRegistry.getAuthenticationService().clearCurrentSecurityContext();
|
||||
}
|
||||
setComplete();
|
||||
}
|
||||
|
||||
public void xtestAuthenticartionFailure()
|
||||
{
|
||||
// Should have a query to support this - check direct in the DB
|
||||
AuthenticationUtil.setSystemUserAsCurrentUser();
|
||||
|
||||
serviceRegistry.getAuthenticationService().createAuthentication("woof", "cabbage".toCharArray());
|
||||
serviceRegistry.getAuthenticationService().authenticate("woof", "red".toCharArray());
|
||||
|
||||
}
|
||||
|
||||
public void testThereIsAnAuditService()
|
||||
{
|
||||
assertNotNull(serviceRegistry.getAuditService());
|
||||
}
|
||||
|
||||
private Map<QName, Serializable> createPersonProperties(String userName)
|
||||
{
|
||||
HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
properties.put(ContentModel.PROP_USERNAME, userName);
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
385
source/java/org/alfresco/repo/audit/AuditState.java
Normal file
385
source/java/org/alfresco/repo/audit/AuditState.java
Normal file
@@ -0,0 +1,385 @@
|
||||
/*
|
||||
* 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.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A class to encapsulate audit information supplied to the DAO layer.
|
||||
*
|
||||
* Null entries should be stored.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class AuditState
|
||||
{
|
||||
private static Logger s_logger = Logger.getLogger(AuditState.class);
|
||||
|
||||
/**
|
||||
* The user identifier for the person who caused this audit entry
|
||||
*/
|
||||
private String userIdentifier;
|
||||
|
||||
/**
|
||||
* The date for this audit entry
|
||||
*/
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* The transaction id in which this entry was made
|
||||
*/
|
||||
private String txId;
|
||||
|
||||
/**
|
||||
* The session is for this action
|
||||
*/
|
||||
private String sessionId;
|
||||
|
||||
/**
|
||||
* The store in which the action occured.
|
||||
*/
|
||||
private StoreRef keyStore;
|
||||
|
||||
/**
|
||||
* For a node ref, the node for the action.
|
||||
*/
|
||||
private String keyGUID;
|
||||
|
||||
/**
|
||||
* The path of the key
|
||||
*/
|
||||
private String keyPath;
|
||||
|
||||
/**
|
||||
* The audit application
|
||||
* Internal uses the "System" key and will only audit method information.
|
||||
*/
|
||||
private String auditApplication;
|
||||
|
||||
/**
|
||||
* The service holding the audited method.
|
||||
*/
|
||||
private String auditService;
|
||||
|
||||
/**
|
||||
* The name of the audited method.
|
||||
*/
|
||||
private String auditMethod;
|
||||
|
||||
/**
|
||||
* Did this entry passa filter?
|
||||
* If false - all entries were being recorded.
|
||||
*/
|
||||
private boolean filtered;
|
||||
|
||||
/**
|
||||
* The audit configuration in use at the time.
|
||||
*/
|
||||
private AuditConfiguration auditConfiguration;
|
||||
|
||||
/**
|
||||
* The object returned by the audited method.
|
||||
*/
|
||||
private Serializable returnObject;
|
||||
|
||||
/**
|
||||
* The arguments to the audited method.
|
||||
*/
|
||||
private Serializable[] methodArguments;
|
||||
|
||||
/**
|
||||
* Any Exception thrown by the audited method.
|
||||
*/
|
||||
private Throwable throwable;
|
||||
|
||||
/**
|
||||
* Did the audited method throw an exception?
|
||||
*/
|
||||
private boolean fail;
|
||||
|
||||
/**
|
||||
* The host address for where the audit was generated.
|
||||
*/
|
||||
private InetAddress hostAddress;
|
||||
|
||||
private static InetAddress s_hostAddress;
|
||||
|
||||
/**
|
||||
* The client address causing the audit
|
||||
*/
|
||||
private InetAddress clientAddress;
|
||||
|
||||
/**
|
||||
* The properties of the key node before the method execution.
|
||||
*/
|
||||
private Map<QName, Serializable> keyPropertiesBefore;
|
||||
|
||||
/**
|
||||
* The properties of the key node after the method execution.
|
||||
*/
|
||||
private Map<QName, Serializable> keyPropertiesAfter;
|
||||
|
||||
/**
|
||||
* For general auditing - the audit message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
s_hostAddress = InetAddress.getLocalHost();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
s_logger.error(e);
|
||||
s_hostAddress = null;
|
||||
}
|
||||
}
|
||||
|
||||
public AuditState(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
super();
|
||||
// Add default information
|
||||
userIdentifier = AuthenticationUtil.getCurrentUserName();
|
||||
date = new Date();
|
||||
txId = AlfrescoTransactionSupport.getTransactionId();
|
||||
sessionId = "Unavailable";
|
||||
hostAddress = s_hostAddress;
|
||||
}
|
||||
|
||||
public String getAuditApplication()
|
||||
{
|
||||
return auditApplication;
|
||||
}
|
||||
|
||||
public void setAuditApplication(String auditApplication)
|
||||
{
|
||||
this.auditApplication = auditApplication;
|
||||
}
|
||||
|
||||
public AuditConfiguration getAuditConfiguration()
|
||||
{
|
||||
return auditConfiguration;
|
||||
}
|
||||
|
||||
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
this.auditConfiguration = auditConfiguration;
|
||||
}
|
||||
|
||||
public String getAuditMethod()
|
||||
{
|
||||
return auditMethod;
|
||||
}
|
||||
|
||||
public void setAuditMethod(String auditMethod)
|
||||
{
|
||||
this.auditMethod = auditMethod;
|
||||
}
|
||||
|
||||
public String getAuditService()
|
||||
{
|
||||
return auditService;
|
||||
}
|
||||
|
||||
public void setAuditService(String auditService)
|
||||
{
|
||||
this.auditService = auditService;
|
||||
}
|
||||
|
||||
public InetAddress getClientAddress()
|
||||
{
|
||||
return clientAddress;
|
||||
}
|
||||
|
||||
public void setClientAddress(InetAddress clientAddress)
|
||||
{
|
||||
this.clientAddress = clientAddress;
|
||||
}
|
||||
|
||||
public Date getDate()
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date)
|
||||
{
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public boolean isFail()
|
||||
{
|
||||
return fail;
|
||||
}
|
||||
|
||||
public void setFail(boolean fail)
|
||||
{
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
public boolean isFiltered()
|
||||
{
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public void setFiltered(boolean filtered)
|
||||
{
|
||||
this.filtered = filtered;
|
||||
}
|
||||
|
||||
public InetAddress getHostAddress()
|
||||
{
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
public void setHostAddress(InetAddress hostAddress)
|
||||
{
|
||||
this.hostAddress = hostAddress;
|
||||
}
|
||||
|
||||
public String getKeyGUID()
|
||||
{
|
||||
return keyGUID;
|
||||
}
|
||||
|
||||
public void setKeyGUID(String keyGUID)
|
||||
{
|
||||
this.keyGUID = keyGUID;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesAfter()
|
||||
{
|
||||
return keyPropertiesAfter;
|
||||
}
|
||||
|
||||
public void setKeyPropertiesAfter(Map<QName, Serializable> keyPropertiesAfter)
|
||||
{
|
||||
this.keyPropertiesAfter = keyPropertiesAfter;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesBefore()
|
||||
{
|
||||
return keyPropertiesBefore;
|
||||
}
|
||||
|
||||
public void setKeyPropertiesBefore(Map<QName, Serializable> keyPropertiesBefore)
|
||||
{
|
||||
this.keyPropertiesBefore = keyPropertiesBefore;
|
||||
}
|
||||
|
||||
public StoreRef getKeyStore()
|
||||
{
|
||||
return keyStore;
|
||||
}
|
||||
|
||||
public void setKeyStore(StoreRef keyStore)
|
||||
{
|
||||
this.keyStore = keyStore;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Serializable[] getMethodArguments()
|
||||
{
|
||||
return methodArguments;
|
||||
}
|
||||
|
||||
public void setMethodArguments(Serializable[] methodArguments)
|
||||
{
|
||||
this.methodArguments = methodArguments;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return keyPath;
|
||||
}
|
||||
|
||||
public void setPath(String keyPath)
|
||||
{
|
||||
this.keyPath = keyPath;
|
||||
}
|
||||
|
||||
public Serializable getReturnObject()
|
||||
{
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
public void setReturnObject(Serializable returnObject)
|
||||
{
|
||||
this.returnObject = returnObject;
|
||||
}
|
||||
|
||||
public String getSessionId()
|
||||
{
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(String sessionId)
|
||||
{
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public Throwable getThrowable()
|
||||
{
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public void setThrowable(Throwable throwable)
|
||||
{
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public String getTxId()
|
||||
{
|
||||
return txId;
|
||||
}
|
||||
|
||||
public void setTxId(String txId)
|
||||
{
|
||||
this.txId = txId;
|
||||
}
|
||||
|
||||
public String getUserIdentifier()
|
||||
{
|
||||
return userIdentifier;
|
||||
}
|
||||
|
||||
public void setUserIdentifier(String userIdentifier)
|
||||
{
|
||||
this.userIdentifier = userIdentifier;
|
||||
}
|
||||
|
||||
}
|
@@ -109,9 +109,9 @@
|
||||
<!-- The app_source_idx index is used to find the app source -->
|
||||
<!-- The look up is always the tripple, the service and method or just the method may be null -->
|
||||
|
||||
<property name="application" column="application" type="string" length="256" not-null="true" index="app_source_idx"/>
|
||||
<property name="service" column="service" type="string" length="256" not-null="false" index="app_source_idx"/>
|
||||
<property name="method" column="method" type="string" length="256" not-null="false" index="app_source_idx"/>
|
||||
<property name="application" column="application" type="string" length="255" not-null="true" index="app_source_app_idx"/>
|
||||
<property name="service" column="service" type="string" length="255" not-null="false" index="app_source_ser_idx"/>
|
||||
<property name="method" column="method" type="string" length="255" not-null="false" index="app_source_met_idx"/>
|
||||
|
||||
</class>
|
||||
|
||||
@@ -155,4 +155,30 @@
|
||||
audit_store.method = :method
|
||||
</query>
|
||||
|
||||
<query name="audit.GetAuditTrailForNode">
|
||||
select
|
||||
audit_fact
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditFactImpl as audit_fact
|
||||
where
|
||||
(audit_fact.storeProtocol = :protocol and
|
||||
audit_fact.storeId = :store_id and
|
||||
audit_fact.nodeUUID = :node_id)
|
||||
or
|
||||
arg1 like :nodeRef
|
||||
or
|
||||
arg2 like :nodeRef
|
||||
or
|
||||
arg3 like :nodeRef
|
||||
or
|
||||
arg4 like :nodeRef
|
||||
or
|
||||
arg5 like :nodeRef
|
||||
or
|
||||
returnValue like :nodeRef
|
||||
order by
|
||||
audit_fact.date asc
|
||||
</query>
|
||||
|
||||
|
||||
</hibernate-mapping>
|
@@ -87,10 +87,10 @@ public class AuditConfigImpl implements AuditConfig, InitializingBean
|
||||
/**
|
||||
* Helper method to get the latest audit config
|
||||
*/
|
||||
public static AuditConfigImpl getLatestConfig(Session session)
|
||||
public static AuditConfig getLatestConfig(Session session)
|
||||
{
|
||||
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_LAST_AUDIT_CONFIG);
|
||||
return (AuditConfigImpl) query.uniqueResult();
|
||||
return (AuditConfig) query.uniqueResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -280,10 +280,10 @@ public class AuditDateImpl implements AuditDate
|
||||
/**
|
||||
* Helper method to get the latest audit date
|
||||
*/
|
||||
public static AuditDateImpl getLatestDate(Session session)
|
||||
public static AuditDate getLatestDate(Session session)
|
||||
{
|
||||
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_LAST_AUDIT_DATE);
|
||||
return (AuditDateImpl) query.uniqueResult();
|
||||
return (AuditDate) query.uniqueResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,6 +17,11 @@
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
|
||||
/**
|
||||
* An Audit fact Rely on standard equals and hash code as they should all be unique.
|
||||
@@ -575,4 +580,17 @@ public class AuditFactImpl implements AuditFact
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get all the audit entries for a node.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<AuditFact> getAuditTrail(Session session, NodeRef nodeRef)
|
||||
{
|
||||
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_AUDIT_TRAIL);
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_PROTOCOL, nodeRef.getStoreRef().getProtocol());
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_STORE_ID, nodeRef.getStoreRef().getIdentifier());
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_NODE_ID, nodeRef.getId());
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_NODE_REF, "%"+nodeRef.toString()+"%");
|
||||
return (List<AuditFact>) query.list();
|
||||
}
|
||||
}
|
||||
|
231
source/java/org/alfresco/repo/audit/hibernate/AuditInfoImpl.java
Normal file
231
source/java/org/alfresco/repo/audit/hibernate/AuditInfoImpl.java
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* 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.audit.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
public class AuditInfoImpl implements AuditInfo
|
||||
{
|
||||
private String auditApplication;
|
||||
|
||||
private String auditMethod;
|
||||
|
||||
private String auditService;
|
||||
|
||||
private String clientAddress;
|
||||
|
||||
private Date date;
|
||||
|
||||
private boolean fail;
|
||||
|
||||
private boolean filtered;
|
||||
|
||||
private String hostAddress;
|
||||
|
||||
private String keyGUID;
|
||||
|
||||
private Map<QName, Serializable> keyPropertiesAfter;
|
||||
|
||||
private Map<QName, Serializable> keyPropertiesBefore;
|
||||
|
||||
private StoreRef keyStore;
|
||||
|
||||
private String message;
|
||||
|
||||
private Serializable[] methodArguments;
|
||||
|
||||
private String[] methodArgumentsAsStrings;
|
||||
|
||||
private String path;
|
||||
|
||||
private Serializable returnObject;
|
||||
|
||||
private String returnObjectAsString;
|
||||
|
||||
private String sessionId;
|
||||
|
||||
private Throwable throwable;
|
||||
|
||||
private String throwableAsString;
|
||||
|
||||
private String txId;
|
||||
|
||||
private String userIdentifier;
|
||||
|
||||
public AuditInfoImpl(AuditFact auditFact)
|
||||
{
|
||||
super();
|
||||
this.auditApplication = auditFact.getAuditSource().getApplication();
|
||||
this.auditMethod = auditFact.getAuditSource().getMethod();
|
||||
this.auditService = auditFact.getAuditSource().getService();
|
||||
this.clientAddress = auditFact.getClientInetAddress();
|
||||
this.date = auditFact.getDate();
|
||||
this.fail = auditFact.isFail();
|
||||
this.filtered = auditFact.isFiltered();
|
||||
this.hostAddress= auditFact.getHostInetAddress();
|
||||
this.keyGUID = auditFact.getNodeUUID();
|
||||
this.keyPropertiesAfter = null;
|
||||
this.keyPropertiesBefore = null;
|
||||
if((auditFact.getStoreProtocol() != null) && (auditFact.getStoreId() != null))
|
||||
{
|
||||
this.keyStore = new StoreRef(auditFact.getStoreProtocol(), auditFact.getStoreId());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.keyStore = null;
|
||||
}
|
||||
this.message = auditFact.getMessage();
|
||||
this.methodArguments = null;
|
||||
this.methodArgumentsAsStrings = new String[5];
|
||||
this.methodArgumentsAsStrings[0] = auditFact.getArg1();
|
||||
this.methodArgumentsAsStrings[1] = auditFact.getArg2();
|
||||
this.methodArgumentsAsStrings[2] = auditFact.getArg3();
|
||||
this.methodArgumentsAsStrings[3] = auditFact.getArg4();
|
||||
this.methodArgumentsAsStrings[4] = auditFact.getArg5();
|
||||
this.path = auditFact.getPath();
|
||||
this.returnObject = null;
|
||||
this.returnObjectAsString = auditFact.getReturnValue();
|
||||
this.sessionId = auditFact.getSessionId();
|
||||
this.throwable = null;
|
||||
this.throwableAsString = auditFact.getException();
|
||||
this.txId = auditFact.getTransactionId();
|
||||
this.userIdentifier = auditFact.getUserId();
|
||||
}
|
||||
|
||||
public String getAuditApplication()
|
||||
{
|
||||
return auditApplication;
|
||||
}
|
||||
|
||||
public String getAuditMethod()
|
||||
{
|
||||
return auditMethod;
|
||||
}
|
||||
|
||||
public String getAuditService()
|
||||
{
|
||||
return auditService;
|
||||
}
|
||||
|
||||
public String getClientAddress()
|
||||
{
|
||||
return clientAddress;
|
||||
}
|
||||
|
||||
public Date getDate()
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
public boolean isFail()
|
||||
{
|
||||
return fail;
|
||||
}
|
||||
|
||||
public boolean isFiltered()
|
||||
{
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public String getHostAddress()
|
||||
{
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
public String getKeyGUID()
|
||||
{
|
||||
return keyGUID;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesAfter()
|
||||
{
|
||||
return keyPropertiesAfter;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesBefore()
|
||||
{
|
||||
return keyPropertiesBefore;
|
||||
}
|
||||
|
||||
public StoreRef getKeyStore()
|
||||
{
|
||||
return keyStore;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public Serializable[] getMethodArguments()
|
||||
{
|
||||
return methodArguments;
|
||||
}
|
||||
|
||||
public String[] getMethodArgumentsAsStrings()
|
||||
{
|
||||
return methodArgumentsAsStrings;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public Serializable getReturnObject()
|
||||
{
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
public String getReturnObjectAsString()
|
||||
{
|
||||
return returnObjectAsString;
|
||||
}
|
||||
|
||||
public String getSessionId()
|
||||
{
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public Throwable getThrowable()
|
||||
{
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public String getThrowableAsString()
|
||||
{
|
||||
return throwableAsString;
|
||||
}
|
||||
|
||||
public String getTxId()
|
||||
{
|
||||
return txId;
|
||||
}
|
||||
|
||||
public String getUserIdentifier()
|
||||
{
|
||||
return userIdentifier;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -26,4 +26,10 @@ public interface AuditSource
|
||||
|
||||
public String getService();
|
||||
|
||||
void setApplication(String auditApplication);
|
||||
|
||||
void setService(String auditService);
|
||||
|
||||
void setMethod(String auditMethod);
|
||||
|
||||
}
|
@@ -87,21 +87,21 @@ public class AuditSourceImpl implements AuditSource
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public static AuditSourceImpl getApplicationSource(Session session, String application)
|
||||
public static AuditSource getApplicationSource(Session session, String application)
|
||||
{
|
||||
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE);
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_APP, application);
|
||||
return (AuditSourceImpl) query.uniqueResult();
|
||||
return (AuditSource) query.uniqueResult();
|
||||
}
|
||||
|
||||
public static AuditSourceImpl getApplicationSource(Session session, String application, String service,
|
||||
public static AuditSource getApplicationSource(Session session, String application, String service,
|
||||
String method)
|
||||
{
|
||||
Query query = session.getNamedQuery(HibernateAuditDAO.QUERY_AUDIT_METHOD_SOURCE);
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_APP, application);
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_SER, service);
|
||||
query.setParameter(HibernateAuditDAO.QUERY_AUDIT_APP_SOURCE_MET, method);
|
||||
return (AuditSourceImpl) query.uniqueResult();
|
||||
return (AuditSource) query.uniqueResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -20,21 +20,28 @@ import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.audit.AuditConfiguration;
|
||||
import org.alfresco.repo.audit.AuditDAO;
|
||||
import org.alfresco.repo.audit.AuditInfo;
|
||||
import org.alfresco.repo.audit.AuditException;
|
||||
import org.alfresco.repo.audit.AuditState;
|
||||
import org.alfresco.repo.content.AbstractContentStore;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.TransactionalDao;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.Duration;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.GUID;
|
||||
@@ -63,6 +70,16 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
|
||||
public static final String QUERY_AUDIT_APP_SOURCE_MET = "method";
|
||||
|
||||
public static final String QUERY_AUDIT_TRAIL = "audit.GetAuditTrailForNode";
|
||||
|
||||
public static final String QUERY_AUDIT_PROTOCOL = "protocol";
|
||||
|
||||
public static final String QUERY_AUDIT_STORE_ID = "store_id";
|
||||
|
||||
public static final String QUERY_AUDIT_NODE_ID = "node_id";
|
||||
|
||||
public static final String QUERY_AUDIT_NODE_REF = "nodeRef";
|
||||
|
||||
/** a uuid identifying this unique instance */
|
||||
private String uuid;
|
||||
|
||||
@@ -92,16 +109,40 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
this.contentStore = contentStore;
|
||||
}
|
||||
|
||||
public void audit(AuditInfo auditInfo)
|
||||
public void audit(AuditState auditInfo)
|
||||
{
|
||||
if(auditInfo.getUserIdentifier() == null)
|
||||
{
|
||||
auditInfo.setUserIdentifier(AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
if(AuthenticationUtil.getCurrentUserName() == null)
|
||||
{
|
||||
AuthenticationUtil.setSystemUserAsCurrentUser();
|
||||
try
|
||||
{
|
||||
audit0(auditInfo);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
audit0(auditInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void audit0(AuditState auditInfo)
|
||||
{
|
||||
// Find/Build the configuraton entry
|
||||
AuditConfigImpl auditConfig = getAuditConfig(auditInfo);
|
||||
AuditConfig auditConfig = getAuditConfig(auditInfo);
|
||||
|
||||
// Find/Build any dates
|
||||
AuditDateImpl auditDate = getAuditDate(auditInfo);
|
||||
AuditDate auditDate = getAuditDate(auditInfo);
|
||||
|
||||
// Find/Build the source
|
||||
AuditSourceImpl auditSource = getAuditSource(auditInfo);
|
||||
AuditSource auditSource = getAuditSource(auditInfo);
|
||||
|
||||
// Build the new audit fact information
|
||||
AuditFactImpl auditFact = new AuditFactImpl();
|
||||
@@ -170,9 +211,9 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
}
|
||||
}
|
||||
|
||||
private AuditSourceImpl getAuditSource(AuditInfo auditInfo)
|
||||
private AuditSource getAuditSource(AuditState auditInfo)
|
||||
{
|
||||
AuditSourceImpl auditSourceImpl;
|
||||
AuditSource auditSourceImpl;
|
||||
|
||||
SourceKey sourceKey = new SourceKey(auditInfo.getAuditApplication(), auditInfo.getAuditService(), auditInfo.getAuditMethod());
|
||||
if(sourceIds.get() == null)
|
||||
@@ -182,7 +223,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
Long id = sourceIds.get().get(sourceKey);
|
||||
if(id != null)
|
||||
{
|
||||
auditSourceImpl = (AuditSourceImpl) getSession().get(AuditSourceImpl.class, id.longValue());
|
||||
auditSourceImpl = (AuditSource) getSession().get(AuditSourceImpl.class, id.longValue());
|
||||
if(auditSourceImpl != null)
|
||||
{
|
||||
return auditSourceImpl;
|
||||
@@ -218,7 +259,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
return auditSourceImpl;
|
||||
}
|
||||
|
||||
private AuditDateImpl getAuditDate(AuditInfo auditInfo)
|
||||
private AuditDate getAuditDate(AuditState auditInfo)
|
||||
{
|
||||
Calendar cal = GregorianCalendar.getInstance();
|
||||
cal.setTime(auditInfo.getDate());
|
||||
@@ -228,7 +269,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
Date required = cal.getTime();
|
||||
|
||||
AuditDateImpl auditDate;
|
||||
AuditDate auditDate;
|
||||
if (auditDateImplId.get() == null)
|
||||
{
|
||||
auditDate = AuditDateImpl.getLatestDate(getSession());
|
||||
@@ -242,7 +283,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
}
|
||||
else
|
||||
{
|
||||
auditDate = (AuditDateImpl) getSession().get(AuditDateImpl.class, auditDateImplId.get().longValue());
|
||||
auditDate = (AuditDate) getSession().get(AuditDateImpl.class, auditDateImplId.get().longValue());
|
||||
if ((auditDate == null) || (!required.equals(auditDate.getDate())))
|
||||
{
|
||||
auditDate = AuditDateImpl.getLatestDate(getSession());
|
||||
@@ -265,9 +306,9 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
return auditDate;
|
||||
}
|
||||
|
||||
private AuditConfigImpl getAuditConfig(AuditInfo auditInfo)
|
||||
private AuditConfig getAuditConfig(AuditState auditInfo)
|
||||
{
|
||||
AuditConfigImpl auditConfig;
|
||||
AuditConfig auditConfig;
|
||||
if ((auditConfiguration.get() == null) || (auditConfiguration.get() != auditInfo.getAuditConfiguration()))
|
||||
{
|
||||
auditConfig = AuditConfigImpl.getLatestConfig(getSession());
|
||||
@@ -313,7 +354,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
}
|
||||
else
|
||||
{
|
||||
auditConfig = (AuditConfigImpl) getSession()
|
||||
auditConfig = (AuditConfig) getSession()
|
||||
.get(AuditConfigImpl.class, auditConfigImplId.get().longValue());
|
||||
if (auditConfig == null)
|
||||
{
|
||||
@@ -323,7 +364,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
return auditConfig;
|
||||
}
|
||||
|
||||
private AuditConfigImpl createNewAuditConfigImpl(AuditInfo auditInfo)
|
||||
private AuditConfigImpl createNewAuditConfigImpl(AuditState auditInfo)
|
||||
{
|
||||
AuditConfigImpl auditConfig = new AuditConfigImpl();
|
||||
InputStream is = new BufferedInputStream(auditInfo.getAuditConfiguration().getInputStream());
|
||||
@@ -436,4 +477,23 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO,
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
if(nodeRef == null)
|
||||
{
|
||||
return Collections.<AuditInfo>emptyList();
|
||||
}
|
||||
List<? extends AuditFact> internalTrail = AuditFactImpl.getAuditTrail(getSession(), nodeRef);
|
||||
|
||||
ArrayList<AuditInfo> answer = new ArrayList<AuditInfo>(internalTrail.size());
|
||||
for(AuditFact auditFact : internalTrail)
|
||||
{
|
||||
AuditInfo info = new AuditInfoImpl(auditFact);
|
||||
answer.add(info);
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -117,7 +117,7 @@ public abstract class AbstractAuditEntry
|
||||
return auditMode;
|
||||
}
|
||||
|
||||
/* package */TrueFalseUnset getEnabled()
|
||||
public TrueFalseUnset getEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.alfresco.repo.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -193,17 +193,17 @@ public class CopyServiceImpl implements CopyService
|
||||
*/
|
||||
public NodeRef copy(
|
||||
NodeRef sourceNodeRef,
|
||||
NodeRef destinationParent,
|
||||
NodeRef destinationParentRef,
|
||||
QName destinationAssocTypeQName,
|
||||
QName destinationQName,
|
||||
boolean copyChildren)
|
||||
{
|
||||
// Check that all the passed values are not null
|
||||
ParameterCheck.mandatory("Source Node", sourceNodeRef);
|
||||
ParameterCheck.mandatory("Destination Parent", destinationParent);
|
||||
ParameterCheck.mandatory("Destination Parent", destinationParentRef);
|
||||
ParameterCheck.mandatory("Destination Association Name", destinationQName);
|
||||
|
||||
if (sourceNodeRef.getStoreRef().equals(destinationParent.getStoreRef()) == false)
|
||||
if (sourceNodeRef.getStoreRef().equals(destinationParentRef.getStoreRef()) == false)
|
||||
{
|
||||
// TODO We need to create a new node in the other store with the same id as the source
|
||||
|
||||
@@ -211,9 +211,19 @@ public class CopyServiceImpl implements CopyService
|
||||
throw new UnsupportedOperationException("Copying nodes across stores is not currently supported.");
|
||||
}
|
||||
|
||||
// Get the original parent reference
|
||||
NodeRef sourceParentRef = nodeService.getPrimaryParent(sourceNodeRef).getParentRef();
|
||||
// Recursively copy node
|
||||
Map<NodeRef, NodeRef> copiedChildren = new HashMap<NodeRef, NodeRef>();
|
||||
NodeRef copy = recursiveCopy(sourceNodeRef, destinationParent, destinationAssocTypeQName, destinationQName, copyChildren, copiedChildren);
|
||||
NodeRef copy = recursiveCopy(
|
||||
sourceNodeRef,
|
||||
sourceParentRef,
|
||||
destinationParentRef,
|
||||
destinationAssocTypeQName,
|
||||
destinationQName,
|
||||
copyChildren,
|
||||
true, // top-level copy drops the name, if the parent is different
|
||||
copiedChildren);
|
||||
|
||||
// Foreach of the newly created copies call the copy complete policy
|
||||
for (Map.Entry<NodeRef, NodeRef> entry : copiedChildren.entrySet())
|
||||
@@ -360,20 +370,16 @@ public class CopyServiceImpl implements CopyService
|
||||
/**
|
||||
* Recursive copy algorithm
|
||||
*
|
||||
* @param sourceNodeRef
|
||||
* @param destinationParent
|
||||
* @param destinationAssocTypeQName
|
||||
* @param destinationQName
|
||||
* @param copyChildren
|
||||
* @param copiedChildren
|
||||
* @return
|
||||
* @param dropName drop the name property when associations don't allow duplicately named children
|
||||
*/
|
||||
private NodeRef recursiveCopy(
|
||||
NodeRef sourceNodeRef,
|
||||
NodeRef destinationParent,
|
||||
NodeRef sourceParentRef,
|
||||
NodeRef destinationParentRef,
|
||||
QName destinationAssocTypeQName,
|
||||
QName destinationQName,
|
||||
boolean copyChildren,
|
||||
boolean dropName,
|
||||
Map<NodeRef, NodeRef> copiedChildren)
|
||||
{
|
||||
// Extract Type Definition
|
||||
@@ -385,7 +391,7 @@ public class CopyServiceImpl implements CopyService
|
||||
}
|
||||
|
||||
// Establish the scope of the copy
|
||||
PolicyScope copyDetails = getCopyDetails(sourceNodeRef, destinationParent.getStoreRef(), true);
|
||||
PolicyScope copyDetails = getCopyDetails(sourceNodeRef, destinationParentRef.getStoreRef(), true);
|
||||
|
||||
// Create collection of properties for type and mandatory aspects
|
||||
Map<QName, Serializable> typeProps = copyDetails.getProperties();
|
||||
@@ -403,8 +409,8 @@ public class CopyServiceImpl implements CopyService
|
||||
}
|
||||
}
|
||||
|
||||
// if the parent node is the same, then remove the name property - it will have to
|
||||
// be changed by the client code
|
||||
// Drop the name property, if required. This prevents duplicate names and leaves it up to the client
|
||||
// to assign a new name.
|
||||
AssociationDefinition assocDef = dictionaryService.getAssociation(destinationAssocTypeQName);
|
||||
if (!assocDef.isChild())
|
||||
{
|
||||
@@ -413,7 +419,7 @@ public class CopyServiceImpl implements CopyService
|
||||
else
|
||||
{
|
||||
ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
|
||||
if (!childAssocDef.getDuplicateChildNamesAllowed())
|
||||
if (dropName && !childAssocDef.getDuplicateChildNamesAllowed())
|
||||
{
|
||||
// duplicate children are not allowed.
|
||||
properties.remove(ContentModel.PROP_NAME);
|
||||
@@ -422,14 +428,14 @@ public class CopyServiceImpl implements CopyService
|
||||
|
||||
// Create the new node
|
||||
ChildAssociationRef destinationChildAssocRef = this.nodeService.createNode(
|
||||
destinationParent,
|
||||
destinationParentRef,
|
||||
destinationAssocTypeQName,
|
||||
destinationQName,
|
||||
sourceTypeRef,
|
||||
properties);
|
||||
NodeRef destinationNodeRef = destinationChildAssocRef.getChildRef();
|
||||
copiedChildren.put(sourceNodeRef, destinationNodeRef);
|
||||
|
||||
|
||||
// Prevent any rules being fired on the new destination node
|
||||
this.ruleService.disableRules(destinationNodeRef);
|
||||
try
|
||||
@@ -736,9 +742,9 @@ public class CopyServiceImpl implements CopyService
|
||||
*/
|
||||
private void copyChildAssociations(
|
||||
QName classRef,
|
||||
NodeRef destinationNodeRef,
|
||||
NodeRef destinationNodeRef,
|
||||
PolicyScope copyDetails,
|
||||
boolean copyChildren,
|
||||
boolean copyChildren,
|
||||
Map<NodeRef, NodeRef> copiedChildren)
|
||||
{
|
||||
List<ChildAssociationRef> childAssocs = copyDetails.getChildAssociations(classRef);
|
||||
@@ -756,11 +762,13 @@ public class CopyServiceImpl implements CopyService
|
||||
{
|
||||
// Copy the child
|
||||
recursiveCopy(
|
||||
childAssoc.getChildRef(),
|
||||
childAssoc.getChildRef(),
|
||||
childAssoc.getParentRef(),
|
||||
destinationNodeRef,
|
||||
childAssoc.getTypeQName(),
|
||||
childAssoc.getQName(),
|
||||
copyChildren,
|
||||
false, // the target and source parents can't be the same
|
||||
copiedChildren);
|
||||
}
|
||||
}
|
||||
@@ -784,11 +792,13 @@ public class CopyServiceImpl implements CopyService
|
||||
{
|
||||
// Always recursivly copy configuration folders
|
||||
recursiveCopy(
|
||||
childRef,
|
||||
childRef,
|
||||
childAssoc.getParentRef(),
|
||||
destinationNodeRef,
|
||||
childAssoc.getTypeQName(),
|
||||
childAssoc.getQName(),
|
||||
true,
|
||||
false, // the target and source parents can't be the same
|
||||
copiedChildren);
|
||||
}
|
||||
}
|
||||
|
@@ -1,83 +1,83 @@
|
||||
/*
|
||||
* 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.domain;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl;
|
||||
|
||||
|
||||
/**
|
||||
* The interface to support persistence of node access control entries in hibernate
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface DbAccessControlList
|
||||
{
|
||||
public long getId();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Returns the access control entries for this access control list
|
||||
*/
|
||||
public Set<DbAccessControlEntry> getEntries();
|
||||
|
||||
/**
|
||||
* Get inheritance behaviour
|
||||
* @return Returns the inheritance status of this list
|
||||
*/
|
||||
public boolean getInherits();
|
||||
|
||||
/**
|
||||
* Set inheritance behaviour
|
||||
* @param inherits true to set the permissions to inherit
|
||||
*/
|
||||
public void setInherits(boolean inherits);
|
||||
|
||||
public int deleteEntriesForAuthority(String authorityKey);
|
||||
|
||||
public int deleteEntriesForPermission(DbPermissionKey permissionKey);
|
||||
|
||||
public int deleteEntry(String authorityKey, DbPermissionKey permissionKey);
|
||||
|
||||
/**
|
||||
* Delete the entries related to this access control list
|
||||
*
|
||||
* @return Returns the number of entries deleted
|
||||
*/
|
||||
public int deleteEntries();
|
||||
|
||||
public DbAccessControlEntry getEntry(String authorityKey, DbPermissionKey permissionKey);
|
||||
|
||||
/**
|
||||
* Factory method to create an entry and wire it up.
|
||||
* Note that the returned value may still be transient. Saving it should be fine, but
|
||||
* is not required.
|
||||
*
|
||||
* @param permission the mandatory permission association with this entry
|
||||
* @param authority the mandatory authority. Must not be transient.
|
||||
* @param allowed allowed or disallowed. Must not be transient.
|
||||
* @return Returns the new entry
|
||||
*/
|
||||
public DbAccessControlEntryImpl newEntry(DbPermission permission, DbAuthority authority, boolean allowed);
|
||||
|
||||
/**
|
||||
* Make a copy of this ACL (persistently)
|
||||
* @return The copy.
|
||||
*/
|
||||
public DbAccessControlList getCopy();
|
||||
}
|
||||
/*
|
||||
* 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.domain;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl;
|
||||
|
||||
|
||||
/**
|
||||
* The interface to support persistence of node access control entries in hibernate
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface DbAccessControlList
|
||||
{
|
||||
public long getId();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Returns the access control entries for this access control list
|
||||
*/
|
||||
public Set<DbAccessControlEntry> getEntries();
|
||||
|
||||
/**
|
||||
* Get inheritance behaviour
|
||||
* @return Returns the inheritance status of this list
|
||||
*/
|
||||
public boolean getInherits();
|
||||
|
||||
/**
|
||||
* Set inheritance behaviour
|
||||
* @param inherits true to set the permissions to inherit
|
||||
*/
|
||||
public void setInherits(boolean inherits);
|
||||
|
||||
public int deleteEntriesForAuthority(String authorityKey);
|
||||
|
||||
public int deleteEntriesForPermission(DbPermissionKey permissionKey);
|
||||
|
||||
public int deleteEntry(String authorityKey, DbPermissionKey permissionKey);
|
||||
|
||||
/**
|
||||
* Delete the entries related to this access control list
|
||||
*
|
||||
* @return Returns the number of entries deleted
|
||||
*/
|
||||
public int deleteEntries();
|
||||
|
||||
public DbAccessControlEntry getEntry(String authorityKey, DbPermissionKey permissionKey);
|
||||
|
||||
/**
|
||||
* Factory method to create an entry and wire it up.
|
||||
* Note that the returned value may still be transient. Saving it should be fine, but
|
||||
* is not required.
|
||||
*
|
||||
* @param permission the mandatory permission association with this entry
|
||||
* @param authority the mandatory authority. Must not be transient.
|
||||
* @param allowed allowed or disallowed. Must not be transient.
|
||||
* @return Returns the new entry
|
||||
*/
|
||||
public DbAccessControlEntryImpl newEntry(DbPermission permission, DbAuthority authority, boolean allowed);
|
||||
|
||||
/**
|
||||
* Make a copy of this ACL (persistently)
|
||||
* @return The copy.
|
||||
*/
|
||||
public DbAccessControlList getCopy();
|
||||
}
|
||||
|
@@ -148,24 +148,12 @@ public class ChildAssocImpl implements ChildAssoc, Serializable
|
||||
return false;
|
||||
}
|
||||
ChildAssoc that = (ChildAssoc) obj;
|
||||
if (EqualsHelper.nullSafeEquals(id, that.getId()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (
|
||||
EqualsHelper.nullSafeEquals(this.getChild().getId(), that.getChild().getId())
|
||||
&& EqualsHelper.nullSafeEquals(this.getQname(), that.getQname())
|
||||
&& EqualsHelper.nullSafeEquals(this.getParent().getId(), that.getParent().getId())
|
||||
&& EqualsHelper.nullSafeEquals(this.getTypeQName(), that.getTypeQName())
|
||||
);
|
||||
}
|
||||
return EqualsHelper.nullSafeEquals(id, that.getId());
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return (qName == null ? 0 : qName.hashCode());
|
||||
return (id == null ? 0 : id.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,250 +1,250 @@
|
||||
/*
|
||||
* 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.domain.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.DbAccessControlEntry;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.DbAuthority;
|
||||
import org.alfresco.repo.domain.DbPermission;
|
||||
import org.alfresco.repo.domain.DbPermissionKey;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.Session;
|
||||
|
||||
/**
|
||||
* The hibernate persisted class for node permission entries.
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class DbAccessControlListImpl extends LifecycleAdapter
|
||||
implements DbAccessControlList, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 3123277428227075648L;
|
||||
|
||||
private static Log logger = LogFactory.getLog(DbAccessControlListImpl.class);
|
||||
|
||||
private long id;
|
||||
private Set<DbAccessControlEntry> entries;
|
||||
private boolean inherits;
|
||||
|
||||
public DbAccessControlListImpl()
|
||||
{
|
||||
entries = new HashSet<DbAccessControlEntry>(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(128);
|
||||
sb.append("DbAccessControlListImpl")
|
||||
.append("[ id=").append(id)
|
||||
.append(", entries=").append(entries.size())
|
||||
.append(", inherits=").append(inherits)
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof DbAccessControlList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
DbAccessControlList other = (DbAccessControlList) o;
|
||||
|
||||
return (this.inherits == other.getInherits());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (inherits == false ? 0 : 17);
|
||||
}
|
||||
|
||||
public long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hibernate use
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Set<DbAccessControlEntry> getEntries()
|
||||
{
|
||||
return entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hibernate use
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void setEntries(Set<DbAccessControlEntry> entries)
|
||||
{
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
public boolean getInherits()
|
||||
{
|
||||
return inherits;
|
||||
}
|
||||
|
||||
public void setInherits(boolean inherits)
|
||||
{
|
||||
this.inherits = inherits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #deleteEntry(String, DbPermissionKey)
|
||||
*/
|
||||
public int deleteEntriesForAuthority(String authority)
|
||||
{
|
||||
return deleteEntry(authority, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #deleteEntry(String, DbPermissionKey)
|
||||
*/
|
||||
public int deleteEntriesForPermission(DbPermissionKey permissionKey)
|
||||
{
|
||||
return deleteEntry(null, permissionKey);
|
||||
}
|
||||
|
||||
public int deleteEntry(String authority, DbPermissionKey permissionKey)
|
||||
{
|
||||
List<DbAccessControlEntry> toDelete = new ArrayList<DbAccessControlEntry>(2);
|
||||
for (DbAccessControlEntry entry : entries)
|
||||
{
|
||||
if (authority != null && !authority.equals(entry.getAuthority().getRecipient()))
|
||||
{
|
||||
// authority is not a match
|
||||
continue;
|
||||
}
|
||||
else if (permissionKey != null && !permissionKey.equals(entry.getPermission().getKey()))
|
||||
{
|
||||
// permission is not a match
|
||||
continue;
|
||||
}
|
||||
toDelete.add(entry);
|
||||
}
|
||||
// delete them
|
||||
for (DbAccessControlEntry entry : toDelete)
|
||||
{
|
||||
// remove from the entry list
|
||||
entry.delete();
|
||||
}
|
||||
// done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Deleted " + toDelete.size() + " access entries: \n" +
|
||||
" access control list: " + id + "\n" +
|
||||
" authority: " + authority + "\n" +
|
||||
" permission: " + permissionKey);
|
||||
}
|
||||
return toDelete.size();
|
||||
}
|
||||
|
||||
public int deleteEntries()
|
||||
{
|
||||
/*
|
||||
* We don't do the full delete-remove-from-set thing here. Just delete each child entity
|
||||
* and then clear the entry set.
|
||||
*/
|
||||
|
||||
Session session = getSession();
|
||||
List<DbAccessControlEntry> toDelete = new ArrayList<DbAccessControlEntry>(entries);
|
||||
// delete each entry
|
||||
for (DbAccessControlEntry entry : toDelete)
|
||||
{
|
||||
session.delete(entry);
|
||||
}
|
||||
// clear the list
|
||||
int count = entries.size();
|
||||
entries.clear();
|
||||
// done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Deleted " + count + " access entries for access control list " + this.id);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public DbAccessControlEntry getEntry(String authority, DbPermissionKey permissionKey)
|
||||
{
|
||||
for (DbAccessControlEntry entry : entries)
|
||||
{
|
||||
DbAuthority authorityEntity = entry.getAuthority();
|
||||
DbPermission permissionEntity = entry.getPermission();
|
||||
// check for a match
|
||||
if (authorityEntity.getRecipient().equals(authority)
|
||||
&& permissionEntity.getKey().equals(permissionKey))
|
||||
{
|
||||
// found it
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public DbAccessControlEntryImpl newEntry(DbPermission permission, DbAuthority authority, boolean allowed)
|
||||
{
|
||||
DbAccessControlEntryImpl accessControlEntry = new DbAccessControlEntryImpl();
|
||||
// fill
|
||||
accessControlEntry.setAccessControlList(this);
|
||||
accessControlEntry.setPermission(permission);
|
||||
accessControlEntry.setAuthority(authority);
|
||||
accessControlEntry.setAllowed(allowed);
|
||||
// save it
|
||||
getSession().save(accessControlEntry);
|
||||
// maintain inverse set on the acl
|
||||
getEntries().add(accessControlEntry);
|
||||
// done
|
||||
return accessControlEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a copy of this ACL.
|
||||
* @return The copy.
|
||||
*/
|
||||
public DbAccessControlList getCopy()
|
||||
{
|
||||
DbAccessControlList newAcl =
|
||||
new DbAccessControlListImpl();
|
||||
getSession().save(newAcl);
|
||||
for (DbAccessControlEntry entry : entries)
|
||||
{
|
||||
newAcl.newEntry(entry.getPermission(), entry.getAuthority(), entry.isAllowed());
|
||||
}
|
||||
return newAcl;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.domain.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.DbAccessControlEntry;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.DbAuthority;
|
||||
import org.alfresco.repo.domain.DbPermission;
|
||||
import org.alfresco.repo.domain.DbPermissionKey;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.Session;
|
||||
|
||||
/**
|
||||
* The hibernate persisted class for node permission entries.
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class DbAccessControlListImpl extends LifecycleAdapter
|
||||
implements DbAccessControlList, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 3123277428227075648L;
|
||||
|
||||
private static Log logger = LogFactory.getLog(DbAccessControlListImpl.class);
|
||||
|
||||
private long id;
|
||||
private Set<DbAccessControlEntry> entries;
|
||||
private boolean inherits;
|
||||
|
||||
public DbAccessControlListImpl()
|
||||
{
|
||||
entries = new HashSet<DbAccessControlEntry>(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(128);
|
||||
sb.append("DbAccessControlListImpl")
|
||||
.append("[ id=").append(id)
|
||||
.append(", entries=").append(entries.size())
|
||||
.append(", inherits=").append(inherits)
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof DbAccessControlList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
DbAccessControlList other = (DbAccessControlList) o;
|
||||
|
||||
return (this.inherits == other.getInherits());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (inherits == false ? 0 : 17);
|
||||
}
|
||||
|
||||
public long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hibernate use
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Set<DbAccessControlEntry> getEntries()
|
||||
{
|
||||
return entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hibernate use
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void setEntries(Set<DbAccessControlEntry> entries)
|
||||
{
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
public boolean getInherits()
|
||||
{
|
||||
return inherits;
|
||||
}
|
||||
|
||||
public void setInherits(boolean inherits)
|
||||
{
|
||||
this.inherits = inherits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #deleteEntry(String, DbPermissionKey)
|
||||
*/
|
||||
public int deleteEntriesForAuthority(String authority)
|
||||
{
|
||||
return deleteEntry(authority, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #deleteEntry(String, DbPermissionKey)
|
||||
*/
|
||||
public int deleteEntriesForPermission(DbPermissionKey permissionKey)
|
||||
{
|
||||
return deleteEntry(null, permissionKey);
|
||||
}
|
||||
|
||||
public int deleteEntry(String authority, DbPermissionKey permissionKey)
|
||||
{
|
||||
List<DbAccessControlEntry> toDelete = new ArrayList<DbAccessControlEntry>(2);
|
||||
for (DbAccessControlEntry entry : entries)
|
||||
{
|
||||
if (authority != null && !authority.equals(entry.getAuthority().getRecipient()))
|
||||
{
|
||||
// authority is not a match
|
||||
continue;
|
||||
}
|
||||
else if (permissionKey != null && !permissionKey.equals(entry.getPermission().getKey()))
|
||||
{
|
||||
// permission is not a match
|
||||
continue;
|
||||
}
|
||||
toDelete.add(entry);
|
||||
}
|
||||
// delete them
|
||||
for (DbAccessControlEntry entry : toDelete)
|
||||
{
|
||||
// remove from the entry list
|
||||
entry.delete();
|
||||
}
|
||||
// done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Deleted " + toDelete.size() + " access entries: \n" +
|
||||
" access control list: " + id + "\n" +
|
||||
" authority: " + authority + "\n" +
|
||||
" permission: " + permissionKey);
|
||||
}
|
||||
return toDelete.size();
|
||||
}
|
||||
|
||||
public int deleteEntries()
|
||||
{
|
||||
/*
|
||||
* We don't do the full delete-remove-from-set thing here. Just delete each child entity
|
||||
* and then clear the entry set.
|
||||
*/
|
||||
|
||||
Session session = getSession();
|
||||
List<DbAccessControlEntry> toDelete = new ArrayList<DbAccessControlEntry>(entries);
|
||||
// delete each entry
|
||||
for (DbAccessControlEntry entry : toDelete)
|
||||
{
|
||||
session.delete(entry);
|
||||
}
|
||||
// clear the list
|
||||
int count = entries.size();
|
||||
entries.clear();
|
||||
// done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Deleted " + count + " access entries for access control list " + this.id);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public DbAccessControlEntry getEntry(String authority, DbPermissionKey permissionKey)
|
||||
{
|
||||
for (DbAccessControlEntry entry : entries)
|
||||
{
|
||||
DbAuthority authorityEntity = entry.getAuthority();
|
||||
DbPermission permissionEntity = entry.getPermission();
|
||||
// check for a match
|
||||
if (authorityEntity.getRecipient().equals(authority)
|
||||
&& permissionEntity.getKey().equals(permissionKey))
|
||||
{
|
||||
// found it
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public DbAccessControlEntryImpl newEntry(DbPermission permission, DbAuthority authority, boolean allowed)
|
||||
{
|
||||
DbAccessControlEntryImpl accessControlEntry = new DbAccessControlEntryImpl();
|
||||
// fill
|
||||
accessControlEntry.setAccessControlList(this);
|
||||
accessControlEntry.setPermission(permission);
|
||||
accessControlEntry.setAuthority(authority);
|
||||
accessControlEntry.setAllowed(allowed);
|
||||
// save it
|
||||
getSession().save(accessControlEntry);
|
||||
// maintain inverse set on the acl
|
||||
getEntries().add(accessControlEntry);
|
||||
// done
|
||||
return accessControlEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a copy of this ACL.
|
||||
* @return The copy.
|
||||
*/
|
||||
public DbAccessControlList getCopy()
|
||||
{
|
||||
DbAccessControlList newAcl =
|
||||
new DbAccessControlListImpl();
|
||||
getSession().save(newAcl);
|
||||
for (DbAccessControlEntry entry : entries)
|
||||
{
|
||||
newAcl.newEntry(entry.getPermission(), entry.getAuthority(), entry.isAllowed());
|
||||
}
|
||||
return newAcl;
|
||||
}
|
||||
}
|
||||
|
@@ -1,456 +1,456 @@
|
||||
/*
|
||||
* 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.domain.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.domain.ChildAssoc;
|
||||
import org.alfresco.repo.domain.Node;
|
||||
import org.alfresco.repo.domain.NodeKey;
|
||||
import org.alfresco.repo.domain.NodeStatus;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.domain.Server;
|
||||
import org.alfresco.repo.domain.Store;
|
||||
import org.alfresco.repo.domain.StoreKey;
|
||||
import org.alfresco.repo.domain.Transaction;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* Test persistence and retrieval of Hibernate-specific implementations of the
|
||||
* {@link org.alfresco.repo.domain.Node} interface
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class HibernateNodeTest extends BaseSpringTest
|
||||
{
|
||||
private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/HibernateNodeTest";
|
||||
private static int i = 0;
|
||||
|
||||
private Store store;
|
||||
private Server server;
|
||||
private Transaction transaction;
|
||||
|
||||
public HibernateNodeTest()
|
||||
{
|
||||
}
|
||||
|
||||
protected void onSetUpInTransaction() throws Exception
|
||||
{
|
||||
store = new StoreImpl();
|
||||
StoreKey storeKey = new StoreKey(StoreRef.PROTOCOL_WORKSPACE,
|
||||
"TestWorkspace@" + System.currentTimeMillis() + " - " + System.nanoTime());
|
||||
store.setKey(storeKey);
|
||||
// persist so that it is present in the hibernate cache
|
||||
getSession().save(store);
|
||||
|
||||
server = (Server) getSession().get(ServerImpl.class, new Long(1));
|
||||
if (server == null)
|
||||
{
|
||||
server = new ServerImpl();
|
||||
server.setIpAddress("" + "i_" + System.currentTimeMillis());
|
||||
getSession().save(server);
|
||||
}
|
||||
transaction = new TransactionImpl();
|
||||
transaction.setServer(server);
|
||||
transaction.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
getSession().save(transaction);
|
||||
}
|
||||
|
||||
protected void onTearDownInTransaction()
|
||||
{
|
||||
// force a flush to ensure that the database updates succeed
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
}
|
||||
|
||||
public void testSetUp() throws Exception
|
||||
{
|
||||
assertNotNull("Workspace not initialised", store);
|
||||
}
|
||||
|
||||
public void testGetStore() throws Exception
|
||||
{
|
||||
// create a new Node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
|
||||
// now it should work
|
||||
Serializable id = getSession().save(node);
|
||||
|
||||
// throw the reference away and get the a new one for the id
|
||||
node = (Node) getSession().load(NodeImpl.class, id);
|
||||
assertNotNull("Node not found", node);
|
||||
// check that the store has been loaded
|
||||
Store loadedStore = node.getStore();
|
||||
assertNotNull("Store not present on node", loadedStore);
|
||||
assertEquals("Incorrect store key", store, loadedStore);
|
||||
}
|
||||
|
||||
public void testNodeStatus()
|
||||
{
|
||||
NodeKey key = new NodeKey(store.getKey(), "AAA");
|
||||
// create the node status
|
||||
NodeStatus nodeStatus = new NodeStatusImpl();
|
||||
nodeStatus.setKey(key);
|
||||
nodeStatus.setTransaction(transaction);
|
||||
getSession().save(nodeStatus);
|
||||
|
||||
// create a new Node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
Serializable nodeId = getSession().save(node);
|
||||
|
||||
// This should all be fine. The node does not HAVE to have a status.
|
||||
flushAndClear();
|
||||
|
||||
// set the node
|
||||
nodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, key);
|
||||
nodeStatus.setNode(node);
|
||||
flushAndClear();
|
||||
|
||||
// is the node retrievable?
|
||||
nodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, key);
|
||||
node = nodeStatus.getNode();
|
||||
assertNotNull("Node was not attached to status", node);
|
||||
// change the values
|
||||
transaction.setChangeTxnId("txn:456");
|
||||
// delete the node
|
||||
getSession().delete(node);
|
||||
|
||||
try
|
||||
{
|
||||
flushAndClear();
|
||||
fail("Node status may not refer to non-existent node");
|
||||
}
|
||||
catch(ConstraintViolationException e)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that properties can be persisted and retrieved
|
||||
*/
|
||||
public void testProperties() throws Exception
|
||||
{
|
||||
// create a new Node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
// give it a property map
|
||||
Map<QName, PropertyValue> propertyMap = new HashMap<QName, PropertyValue>(5);
|
||||
QName propertyQName = QName.createQName("{}A");
|
||||
PropertyValue propertyValue = new PropertyValue(DataTypeDefinition.TEXT, "AAA");
|
||||
propertyMap.put(propertyQName, propertyValue);
|
||||
node.getProperties().putAll(propertyMap);
|
||||
// persist it
|
||||
Serializable id = getSession().save(node);
|
||||
|
||||
// throw the reference away and get the a new one for the id
|
||||
node = (Node) getSession().load(NodeImpl.class, id);
|
||||
assertNotNull("Node not found", node);
|
||||
// extract the Map
|
||||
propertyMap = node.getProperties();
|
||||
assertNotNull("Map not persisted", propertyMap);
|
||||
// ensure that the value is present
|
||||
assertNotNull("Property value not present in map", QName.createQName("{}A"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that aspect qnames can be added and removed from a node and that they
|
||||
* are persisted correctly
|
||||
*/
|
||||
public void testAspects() throws Exception
|
||||
{
|
||||
// make a real node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CMOBJECT);
|
||||
|
||||
// add some aspects
|
||||
QName aspect1 = QName.createQName(TEST_NAMESPACE, "1");
|
||||
QName aspect2 = QName.createQName(TEST_NAMESPACE, "2");
|
||||
QName aspect3 = QName.createQName(TEST_NAMESPACE, "3");
|
||||
QName aspect4 = QName.createQName(TEST_NAMESPACE, "4");
|
||||
Set<QName> aspects = node.getAspects();
|
||||
aspects.add(aspect1);
|
||||
aspects.add(aspect2);
|
||||
aspects.add(aspect3);
|
||||
aspects.add(aspect4);
|
||||
assertFalse("Set did not eliminate duplicate aspect qname", aspects.add(aspect4));
|
||||
|
||||
// persist
|
||||
Serializable id = getSession().save(node);
|
||||
|
||||
// flush and clear
|
||||
flushAndClear();
|
||||
|
||||
// get node and check aspects
|
||||
node = (Node) getSession().get(NodeImpl.class, id);
|
||||
assertNotNull("Node not persisted", node);
|
||||
aspects = node.getAspects();
|
||||
assertEquals("Not all aspects persisted", 4, aspects.size());
|
||||
}
|
||||
|
||||
public void testChildAssoc() throws Exception
|
||||
{
|
||||
// make a content node
|
||||
Node contentNode = new NodeImpl();
|
||||
contentNode.setStore(store);
|
||||
contentNode.setUuid(GUID.generate());
|
||||
contentNode.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
Serializable contentNodeId = getSession().save(contentNode);
|
||||
|
||||
// make a container node
|
||||
Node containerNode = new NodeImpl();
|
||||
containerNode.setStore(store);
|
||||
containerNode.setUuid(GUID.generate());
|
||||
containerNode.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
Serializable containerNodeId = getSession().save(containerNode);
|
||||
// create an association to the content
|
||||
ChildAssoc assoc1 = new ChildAssocImpl();
|
||||
assoc1.setIsPrimary(true);
|
||||
assoc1.setTypeQName(QName.createQName(null, "type1"));
|
||||
assoc1.setQname(QName.createQName(null, "number1"));
|
||||
assoc1.setChildNodeName("number1");
|
||||
assoc1.setChildNodeNameCrc(1);
|
||||
assoc1.buildAssociation(containerNode, contentNode);
|
||||
getSession().save(assoc1);
|
||||
|
||||
// make another association between the same two parent and child nodes
|
||||
ChildAssoc assoc2 = new ChildAssocImpl();
|
||||
assoc2.setIsPrimary(true);
|
||||
assoc2.setTypeQName(QName.createQName(null, "type2"));
|
||||
assoc2.setQname(QName.createQName(null, "number2"));
|
||||
assoc2.setChildNodeName("number2");
|
||||
assoc2.setChildNodeNameCrc(2);
|
||||
assoc2.buildAssociation(containerNode, contentNode);
|
||||
getSession().save(assoc2);
|
||||
|
||||
assertFalse("Hashcode incorrent", assoc2.hashCode() == 0);
|
||||
assertNotSame("Assoc equals failure", assoc1, assoc2);
|
||||
|
||||
// reload the container
|
||||
containerNode = (Node) getSession().get(NodeImpl.class, containerNodeId);
|
||||
assertNotNull("Node not found", containerNode);
|
||||
|
||||
// check that we can traverse the association from the child
|
||||
Collection<ChildAssoc> parentAssocs = contentNode.getParentAssocs();
|
||||
assertEquals("Expected exactly 2 parent assocs", 2, parentAssocs.size());
|
||||
parentAssocs = new HashSet<ChildAssoc>(parentAssocs);
|
||||
for (ChildAssoc assoc : parentAssocs)
|
||||
{
|
||||
// maintain inverse assoc sets
|
||||
assoc.removeAssociation();
|
||||
// remove the assoc
|
||||
getSession().delete(assoc);
|
||||
}
|
||||
|
||||
// check that the child now has zero parents
|
||||
parentAssocs = contentNode.getParentAssocs();
|
||||
assertEquals("Expected exactly 0 parent assocs", 0, parentAssocs.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows tracing of L2 cache
|
||||
*/
|
||||
public void testCaching() throws Exception
|
||||
{
|
||||
// make a node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
Serializable nodeId = getSession().save(node);
|
||||
|
||||
// add some aspects to the node
|
||||
Set<QName> aspects = node.getAspects();
|
||||
aspects.add(ContentModel.ASPECT_AUDITABLE);
|
||||
|
||||
// add some properties
|
||||
Map<QName, PropertyValue> properties = node.getProperties();
|
||||
properties.put(ContentModel.PROP_NAME, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
|
||||
// check that the session hands back the same instance
|
||||
Node checkNode = (Node) getSession().get(NodeImpl.class, nodeId);
|
||||
assertNotNull(checkNode);
|
||||
assertTrue("Node retrieved was not same instance", checkNode == node);
|
||||
|
||||
Set<QName> checkAspects = checkNode.getAspects();
|
||||
assertTrue("Aspect set retrieved was not the same instance", checkAspects == aspects);
|
||||
assertEquals("Incorrect number of aspects", 1, checkAspects.size());
|
||||
QName checkQName = (QName) checkAspects.toArray()[0];
|
||||
assertTrue("QName retrieved was not the same instance", checkQName == ContentModel.ASPECT_AUDITABLE);
|
||||
|
||||
Map<QName, PropertyValue> checkProperties = checkNode.getProperties();
|
||||
assertTrue("Propery map retrieved was not the same instance", checkProperties == properties);
|
||||
assertTrue("Property not found", checkProperties.containsKey(ContentModel.PROP_NAME));
|
||||
|
||||
flushAndClear();
|
||||
// commit the transaction
|
||||
setComplete();
|
||||
endTransaction();
|
||||
|
||||
TransactionService transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
|
||||
UserTransaction txn = transactionService.getUserTransaction();
|
||||
try
|
||||
{
|
||||
txn.begin();
|
||||
|
||||
// check that the L2 cache hands back the same instance
|
||||
checkNode = (Node) getSession().get(NodeImpl.class, nodeId);
|
||||
assertNotNull(checkNode);
|
||||
checkAspects = checkNode.getAspects();
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
txn.rollback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create some simple parent-child relationships and flush them. Then read them back in without
|
||||
* using the L2 cache.
|
||||
*/
|
||||
public void testQueryJoins() throws Exception
|
||||
{
|
||||
getSession().setCacheMode(CacheMode.IGNORE);
|
||||
|
||||
// make a container node
|
||||
Node containerNode = new NodeImpl();
|
||||
containerNode.setStore(store);
|
||||
containerNode.setUuid(GUID.generate());
|
||||
containerNode.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
containerNode.getProperties().put(ContentModel.PROP_AUTHOR, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
containerNode.getProperties().put(ContentModel.PROP_ARCHIVED_BY, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
containerNode.getAspects().add(ContentModel.ASPECT_AUDITABLE);
|
||||
Serializable containerNodeId = getSession().save(containerNode);
|
||||
NodeKey containerNodeKey = new NodeKey(containerNode.getNodeRef());
|
||||
NodeStatus containerNodeStatus = new NodeStatusImpl();
|
||||
containerNodeStatus.setKey(containerNodeKey);
|
||||
containerNodeStatus.setNode(containerNode);
|
||||
containerNodeStatus.setTransaction(transaction);
|
||||
getSession().save(containerNodeStatus);
|
||||
// make content node 1
|
||||
Node contentNode1 = new NodeImpl();
|
||||
contentNode1.setStore(store);
|
||||
contentNode1.setUuid(GUID.generate());
|
||||
contentNode1.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
contentNode1.getProperties().put(ContentModel.PROP_AUTHOR, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode1.getProperties().put(ContentModel.PROP_ARCHIVED_BY, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode1.getAspects().add(ContentModel.ASPECT_AUDITABLE);
|
||||
Serializable contentNode1Id = getSession().save(contentNode1);
|
||||
NodeKey contentNodeKey1 = new NodeKey(contentNode1.getNodeRef());
|
||||
NodeStatus contentNodeStatus1 = new NodeStatusImpl();
|
||||
contentNodeStatus1.setKey(contentNodeKey1);
|
||||
contentNodeStatus1.setNode(contentNode1);
|
||||
contentNodeStatus1.setTransaction(transaction);
|
||||
getSession().save(contentNodeStatus1);
|
||||
// make content node 2
|
||||
Node contentNode2 = new NodeImpl();
|
||||
contentNode2.setStore(store);
|
||||
contentNode2.setUuid(GUID.generate());
|
||||
contentNode2.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
Serializable contentNode2Id = getSession().save(contentNode2);
|
||||
contentNode2.getProperties().put(ContentModel.PROP_AUTHOR, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode2.getProperties().put(ContentModel.PROP_ARCHIVED_BY, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode2.getAspects().add(ContentModel.ASPECT_AUDITABLE);
|
||||
NodeKey contentNodeKey2 = new NodeKey(contentNode2.getNodeRef());
|
||||
NodeStatus contentNodeStatus2 = new NodeStatusImpl();
|
||||
contentNodeStatus2.setKey(contentNodeKey2);
|
||||
contentNodeStatus2.setNode(contentNode2);
|
||||
contentNodeStatus2.setTransaction(transaction);
|
||||
getSession().save(contentNodeStatus2);
|
||||
// create an association to content 1
|
||||
ChildAssoc assoc1 = new ChildAssocImpl();
|
||||
assoc1.setIsPrimary(true);
|
||||
assoc1.setTypeQName(QName.createQName(null, "type1"));
|
||||
assoc1.setQname(QName.createQName(null, "number1"));
|
||||
assoc1.setChildNodeName("number1");
|
||||
assoc1.setChildNodeNameCrc(1);
|
||||
assoc1.buildAssociation(containerNode, contentNode1);
|
||||
getSession().save(assoc1);
|
||||
// create an association to content 2
|
||||
ChildAssoc assoc2 = new ChildAssocImpl();
|
||||
assoc2.setIsPrimary(true);
|
||||
assoc2.setTypeQName(QName.createQName(null, "type2"));
|
||||
assoc2.setQname(QName.createQName(null, "number2"));
|
||||
assoc2.setChildNodeName("number2");
|
||||
assoc2.setChildNodeNameCrc(2);
|
||||
assoc2.buildAssociation(containerNode, contentNode2);
|
||||
getSession().save(assoc2);
|
||||
|
||||
// make sure that there are no entities cached in either L1 or L2
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
|
||||
// now read the structure back in from the container down
|
||||
containerNodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, containerNodeKey);
|
||||
containerNode = containerNodeStatus.getNode();
|
||||
|
||||
// clear out again
|
||||
getSession().clear();
|
||||
|
||||
// expect that just the specific property gets removed in the delete statement
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
|
||||
// Create a second association to content 2
|
||||
// create an association to content 2
|
||||
containerNodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, containerNodeKey);
|
||||
containerNode = containerNodeStatus.getNode();
|
||||
contentNodeStatus2 = (NodeStatus) getSession().get(NodeStatusImpl.class, contentNodeKey2);
|
||||
contentNode2 = contentNodeStatus2.getNode();
|
||||
ChildAssoc assoc3 = new ChildAssocImpl();
|
||||
assoc3.setIsPrimary(false);
|
||||
assoc3.setTypeQName(QName.createQName(null, "type3"));
|
||||
assoc3.setQname(QName.createQName(null, "number3"));
|
||||
assoc3.setChildNodeName("number3");
|
||||
assoc3.setChildNodeNameCrc(2);
|
||||
assoc3.buildAssociation(containerNode, contentNode2); // check whether the children are pulled in for this
|
||||
getSession().save(assoc3);
|
||||
|
||||
// flush it
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.domain.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.domain.ChildAssoc;
|
||||
import org.alfresco.repo.domain.Node;
|
||||
import org.alfresco.repo.domain.NodeKey;
|
||||
import org.alfresco.repo.domain.NodeStatus;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.domain.Server;
|
||||
import org.alfresco.repo.domain.Store;
|
||||
import org.alfresco.repo.domain.StoreKey;
|
||||
import org.alfresco.repo.domain.Transaction;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* Test persistence and retrieval of Hibernate-specific implementations of the
|
||||
* {@link org.alfresco.repo.domain.Node} interface
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class HibernateNodeTest extends BaseSpringTest
|
||||
{
|
||||
private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/HibernateNodeTest";
|
||||
private static int i = 0;
|
||||
|
||||
private Store store;
|
||||
private Server server;
|
||||
private Transaction transaction;
|
||||
|
||||
public HibernateNodeTest()
|
||||
{
|
||||
}
|
||||
|
||||
protected void onSetUpInTransaction() throws Exception
|
||||
{
|
||||
store = new StoreImpl();
|
||||
StoreKey storeKey = new StoreKey(StoreRef.PROTOCOL_WORKSPACE,
|
||||
"TestWorkspace@" + System.currentTimeMillis() + " - " + System.nanoTime());
|
||||
store.setKey(storeKey);
|
||||
// persist so that it is present in the hibernate cache
|
||||
getSession().save(store);
|
||||
|
||||
server = (Server) getSession().get(ServerImpl.class, new Long(1));
|
||||
if (server == null)
|
||||
{
|
||||
server = new ServerImpl();
|
||||
server.setIpAddress("" + "i_" + System.currentTimeMillis());
|
||||
getSession().save(server);
|
||||
}
|
||||
transaction = new TransactionImpl();
|
||||
transaction.setServer(server);
|
||||
transaction.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
getSession().save(transaction);
|
||||
}
|
||||
|
||||
protected void onTearDownInTransaction()
|
||||
{
|
||||
// force a flush to ensure that the database updates succeed
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
}
|
||||
|
||||
public void testSetUp() throws Exception
|
||||
{
|
||||
assertNotNull("Workspace not initialised", store);
|
||||
}
|
||||
|
||||
public void testGetStore() throws Exception
|
||||
{
|
||||
// create a new Node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
|
||||
// now it should work
|
||||
Serializable id = getSession().save(node);
|
||||
|
||||
// throw the reference away and get the a new one for the id
|
||||
node = (Node) getSession().load(NodeImpl.class, id);
|
||||
assertNotNull("Node not found", node);
|
||||
// check that the store has been loaded
|
||||
Store loadedStore = node.getStore();
|
||||
assertNotNull("Store not present on node", loadedStore);
|
||||
assertEquals("Incorrect store key", store, loadedStore);
|
||||
}
|
||||
|
||||
public void testNodeStatus()
|
||||
{
|
||||
NodeKey key = new NodeKey(store.getKey(), "AAA");
|
||||
// create the node status
|
||||
NodeStatus nodeStatus = new NodeStatusImpl();
|
||||
nodeStatus.setKey(key);
|
||||
nodeStatus.setTransaction(transaction);
|
||||
getSession().save(nodeStatus);
|
||||
|
||||
// create a new Node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
Serializable nodeId = getSession().save(node);
|
||||
|
||||
// This should all be fine. The node does not HAVE to have a status.
|
||||
flushAndClear();
|
||||
|
||||
// set the node
|
||||
nodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, key);
|
||||
nodeStatus.setNode(node);
|
||||
flushAndClear();
|
||||
|
||||
// is the node retrievable?
|
||||
nodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, key);
|
||||
node = nodeStatus.getNode();
|
||||
assertNotNull("Node was not attached to status", node);
|
||||
// change the values
|
||||
transaction.setChangeTxnId("txn:456");
|
||||
// delete the node
|
||||
getSession().delete(node);
|
||||
|
||||
try
|
||||
{
|
||||
flushAndClear();
|
||||
fail("Node status may not refer to non-existent node");
|
||||
}
|
||||
catch(ConstraintViolationException e)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that properties can be persisted and retrieved
|
||||
*/
|
||||
public void testProperties() throws Exception
|
||||
{
|
||||
// create a new Node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
// give it a property map
|
||||
Map<QName, PropertyValue> propertyMap = new HashMap<QName, PropertyValue>(5);
|
||||
QName propertyQName = QName.createQName("{}A");
|
||||
PropertyValue propertyValue = new PropertyValue(DataTypeDefinition.TEXT, "AAA");
|
||||
propertyMap.put(propertyQName, propertyValue);
|
||||
node.getProperties().putAll(propertyMap);
|
||||
// persist it
|
||||
Serializable id = getSession().save(node);
|
||||
|
||||
// throw the reference away and get the a new one for the id
|
||||
node = (Node) getSession().load(NodeImpl.class, id);
|
||||
assertNotNull("Node not found", node);
|
||||
// extract the Map
|
||||
propertyMap = node.getProperties();
|
||||
assertNotNull("Map not persisted", propertyMap);
|
||||
// ensure that the value is present
|
||||
assertNotNull("Property value not present in map", QName.createQName("{}A"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that aspect qnames can be added and removed from a node and that they
|
||||
* are persisted correctly
|
||||
*/
|
||||
public void testAspects() throws Exception
|
||||
{
|
||||
// make a real node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CMOBJECT);
|
||||
|
||||
// add some aspects
|
||||
QName aspect1 = QName.createQName(TEST_NAMESPACE, "1");
|
||||
QName aspect2 = QName.createQName(TEST_NAMESPACE, "2");
|
||||
QName aspect3 = QName.createQName(TEST_NAMESPACE, "3");
|
||||
QName aspect4 = QName.createQName(TEST_NAMESPACE, "4");
|
||||
Set<QName> aspects = node.getAspects();
|
||||
aspects.add(aspect1);
|
||||
aspects.add(aspect2);
|
||||
aspects.add(aspect3);
|
||||
aspects.add(aspect4);
|
||||
assertFalse("Set did not eliminate duplicate aspect qname", aspects.add(aspect4));
|
||||
|
||||
// persist
|
||||
Serializable id = getSession().save(node);
|
||||
|
||||
// flush and clear
|
||||
flushAndClear();
|
||||
|
||||
// get node and check aspects
|
||||
node = (Node) getSession().get(NodeImpl.class, id);
|
||||
assertNotNull("Node not persisted", node);
|
||||
aspects = node.getAspects();
|
||||
assertEquals("Not all aspects persisted", 4, aspects.size());
|
||||
}
|
||||
|
||||
public void testChildAssoc() throws Exception
|
||||
{
|
||||
// make a content node
|
||||
Node contentNode = new NodeImpl();
|
||||
contentNode.setStore(store);
|
||||
contentNode.setUuid(GUID.generate());
|
||||
contentNode.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
Serializable contentNodeId = getSession().save(contentNode);
|
||||
|
||||
// make a container node
|
||||
Node containerNode = new NodeImpl();
|
||||
containerNode.setStore(store);
|
||||
containerNode.setUuid(GUID.generate());
|
||||
containerNode.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
Serializable containerNodeId = getSession().save(containerNode);
|
||||
// create an association to the content
|
||||
ChildAssoc assoc1 = new ChildAssocImpl();
|
||||
assoc1.setIsPrimary(true);
|
||||
assoc1.setTypeQName(QName.createQName(null, "type1"));
|
||||
assoc1.setQname(QName.createQName(null, "number1"));
|
||||
assoc1.setChildNodeName("number1");
|
||||
assoc1.setChildNodeNameCrc(1);
|
||||
getSession().save(assoc1);
|
||||
assoc1.buildAssociation(containerNode, contentNode);
|
||||
|
||||
// make another association between the same two parent and child nodes
|
||||
ChildAssoc assoc2 = new ChildAssocImpl();
|
||||
assoc2.setIsPrimary(true);
|
||||
assoc2.setTypeQName(QName.createQName(null, "type2"));
|
||||
assoc2.setQname(QName.createQName(null, "number2"));
|
||||
assoc2.setChildNodeName("number2");
|
||||
assoc2.setChildNodeNameCrc(2);
|
||||
getSession().save(assoc2);
|
||||
assoc2.buildAssociation(containerNode, contentNode);
|
||||
|
||||
assertFalse("Hashcode incorrent", assoc2.hashCode() == 0);
|
||||
assertNotSame("Assoc equals failure", assoc1, assoc2);
|
||||
|
||||
// reload the container
|
||||
containerNode = (Node) getSession().get(NodeImpl.class, containerNodeId);
|
||||
assertNotNull("Node not found", containerNode);
|
||||
|
||||
// check that we can traverse the association from the child
|
||||
Collection<ChildAssoc> parentAssocs = contentNode.getParentAssocs();
|
||||
assertEquals("Expected exactly 2 parent assocs", 2, parentAssocs.size());
|
||||
parentAssocs = new HashSet<ChildAssoc>(parentAssocs);
|
||||
for (ChildAssoc assoc : parentAssocs)
|
||||
{
|
||||
// maintain inverse assoc sets
|
||||
assoc.removeAssociation();
|
||||
// remove the assoc
|
||||
getSession().delete(assoc);
|
||||
}
|
||||
|
||||
// check that the child now has zero parents
|
||||
parentAssocs = contentNode.getParentAssocs();
|
||||
assertEquals("Expected exactly 0 parent assocs", 0, parentAssocs.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows tracing of L2 cache
|
||||
*/
|
||||
public void testCaching() throws Exception
|
||||
{
|
||||
// make a node
|
||||
Node node = new NodeImpl();
|
||||
node.setStore(store);
|
||||
node.setUuid(GUID.generate());
|
||||
node.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
Serializable nodeId = getSession().save(node);
|
||||
|
||||
// add some aspects to the node
|
||||
Set<QName> aspects = node.getAspects();
|
||||
aspects.add(ContentModel.ASPECT_AUDITABLE);
|
||||
|
||||
// add some properties
|
||||
Map<QName, PropertyValue> properties = node.getProperties();
|
||||
properties.put(ContentModel.PROP_NAME, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
|
||||
// check that the session hands back the same instance
|
||||
Node checkNode = (Node) getSession().get(NodeImpl.class, nodeId);
|
||||
assertNotNull(checkNode);
|
||||
assertTrue("Node retrieved was not same instance", checkNode == node);
|
||||
|
||||
Set<QName> checkAspects = checkNode.getAspects();
|
||||
assertTrue("Aspect set retrieved was not the same instance", checkAspects == aspects);
|
||||
assertEquals("Incorrect number of aspects", 1, checkAspects.size());
|
||||
QName checkQName = (QName) checkAspects.toArray()[0];
|
||||
assertTrue("QName retrieved was not the same instance", checkQName == ContentModel.ASPECT_AUDITABLE);
|
||||
|
||||
Map<QName, PropertyValue> checkProperties = checkNode.getProperties();
|
||||
assertTrue("Propery map retrieved was not the same instance", checkProperties == properties);
|
||||
assertTrue("Property not found", checkProperties.containsKey(ContentModel.PROP_NAME));
|
||||
|
||||
flushAndClear();
|
||||
// commit the transaction
|
||||
setComplete();
|
||||
endTransaction();
|
||||
|
||||
TransactionService transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
|
||||
UserTransaction txn = transactionService.getUserTransaction();
|
||||
try
|
||||
{
|
||||
txn.begin();
|
||||
|
||||
// check that the L2 cache hands back the same instance
|
||||
checkNode = (Node) getSession().get(NodeImpl.class, nodeId);
|
||||
assertNotNull(checkNode);
|
||||
checkAspects = checkNode.getAspects();
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
txn.rollback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create some simple parent-child relationships and flush them. Then read them back in without
|
||||
* using the L2 cache.
|
||||
*/
|
||||
public void testQueryJoins() throws Exception
|
||||
{
|
||||
getSession().setCacheMode(CacheMode.IGNORE);
|
||||
|
||||
// make a container node
|
||||
Node containerNode = new NodeImpl();
|
||||
containerNode.setStore(store);
|
||||
containerNode.setUuid(GUID.generate());
|
||||
containerNode.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
containerNode.getProperties().put(ContentModel.PROP_AUTHOR, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
containerNode.getProperties().put(ContentModel.PROP_ARCHIVED_BY, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
containerNode.getAspects().add(ContentModel.ASPECT_AUDITABLE);
|
||||
Serializable containerNodeId = getSession().save(containerNode);
|
||||
NodeKey containerNodeKey = new NodeKey(containerNode.getNodeRef());
|
||||
NodeStatus containerNodeStatus = new NodeStatusImpl();
|
||||
containerNodeStatus.setKey(containerNodeKey);
|
||||
containerNodeStatus.setNode(containerNode);
|
||||
containerNodeStatus.setTransaction(transaction);
|
||||
getSession().save(containerNodeStatus);
|
||||
// make content node 1
|
||||
Node contentNode1 = new NodeImpl();
|
||||
contentNode1.setStore(store);
|
||||
contentNode1.setUuid(GUID.generate());
|
||||
contentNode1.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
contentNode1.getProperties().put(ContentModel.PROP_AUTHOR, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode1.getProperties().put(ContentModel.PROP_ARCHIVED_BY, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode1.getAspects().add(ContentModel.ASPECT_AUDITABLE);
|
||||
Serializable contentNode1Id = getSession().save(contentNode1);
|
||||
NodeKey contentNodeKey1 = new NodeKey(contentNode1.getNodeRef());
|
||||
NodeStatus contentNodeStatus1 = new NodeStatusImpl();
|
||||
contentNodeStatus1.setKey(contentNodeKey1);
|
||||
contentNodeStatus1.setNode(contentNode1);
|
||||
contentNodeStatus1.setTransaction(transaction);
|
||||
getSession().save(contentNodeStatus1);
|
||||
// make content node 2
|
||||
Node contentNode2 = new NodeImpl();
|
||||
contentNode2.setStore(store);
|
||||
contentNode2.setUuid(GUID.generate());
|
||||
contentNode2.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||
Serializable contentNode2Id = getSession().save(contentNode2);
|
||||
contentNode2.getProperties().put(ContentModel.PROP_AUTHOR, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode2.getProperties().put(ContentModel.PROP_ARCHIVED_BY, new PropertyValue(DataTypeDefinition.TEXT, "ABC"));
|
||||
contentNode2.getAspects().add(ContentModel.ASPECT_AUDITABLE);
|
||||
NodeKey contentNodeKey2 = new NodeKey(contentNode2.getNodeRef());
|
||||
NodeStatus contentNodeStatus2 = new NodeStatusImpl();
|
||||
contentNodeStatus2.setKey(contentNodeKey2);
|
||||
contentNodeStatus2.setNode(contentNode2);
|
||||
contentNodeStatus2.setTransaction(transaction);
|
||||
getSession().save(contentNodeStatus2);
|
||||
// create an association to content 1
|
||||
ChildAssoc assoc1 = new ChildAssocImpl();
|
||||
assoc1.setIsPrimary(true);
|
||||
assoc1.setTypeQName(QName.createQName(null, "type1"));
|
||||
assoc1.setQname(QName.createQName(null, "number1"));
|
||||
assoc1.setChildNodeName("number1");
|
||||
assoc1.setChildNodeNameCrc(1);
|
||||
assoc1.buildAssociation(containerNode, contentNode1);
|
||||
getSession().save(assoc1);
|
||||
// create an association to content 2
|
||||
ChildAssoc assoc2 = new ChildAssocImpl();
|
||||
assoc2.setIsPrimary(true);
|
||||
assoc2.setTypeQName(QName.createQName(null, "type2"));
|
||||
assoc2.setQname(QName.createQName(null, "number2"));
|
||||
assoc2.setChildNodeName("number2");
|
||||
assoc2.setChildNodeNameCrc(2);
|
||||
assoc2.buildAssociation(containerNode, contentNode2);
|
||||
getSession().save(assoc2);
|
||||
|
||||
// make sure that there are no entities cached in either L1 or L2
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
|
||||
// now read the structure back in from the container down
|
||||
containerNodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, containerNodeKey);
|
||||
containerNode = containerNodeStatus.getNode();
|
||||
|
||||
// clear out again
|
||||
getSession().clear();
|
||||
|
||||
// expect that just the specific property gets removed in the delete statement
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
|
||||
// Create a second association to content 2
|
||||
// create an association to content 2
|
||||
containerNodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, containerNodeKey);
|
||||
containerNode = containerNodeStatus.getNode();
|
||||
contentNodeStatus2 = (NodeStatus) getSession().get(NodeStatusImpl.class, contentNodeKey2);
|
||||
contentNode2 = contentNodeStatus2.getNode();
|
||||
ChildAssoc assoc3 = new ChildAssocImpl();
|
||||
assoc3.setIsPrimary(false);
|
||||
assoc3.setTypeQName(QName.createQName(null, "type3"));
|
||||
assoc3.setQname(QName.createQName(null, "number3"));
|
||||
assoc3.setChildNodeName("number3");
|
||||
assoc3.setChildNodeNameCrc(2);
|
||||
assoc3.buildAssociation(containerNode, contentNode2); // check whether the children are pulled in for this
|
||||
getSession().save(assoc3);
|
||||
|
||||
// flush it
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,8 @@ import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Writer;
|
||||
import java.sql.Connection;
|
||||
@@ -47,8 +47,10 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
/**
|
||||
* Bootstraps the schema and schema update. The schema is considered missing if the applied patch table
|
||||
@@ -316,7 +318,8 @@ public class SchemaBootstrap implements ApplicationListener
|
||||
// perform a full update using Hibernate-generated statements
|
||||
File tempFile = TempFileProvider.createTempFile("AlfrescoSchemaCreate", ".sql");
|
||||
dumpSchemaCreate(cfg, tempFile);
|
||||
executeScriptFile(cfg, connection, tempFile);
|
||||
FileInputStream tempInputStream = new FileInputStream(tempFile);
|
||||
executeScriptFile(cfg, connection, tempInputStream, tempFile.getPath());
|
||||
// execute post-create scripts (not patches)
|
||||
for (String scriptUrl : this.postCreateScriptUrls)
|
||||
{
|
||||
@@ -357,7 +360,8 @@ public class SchemaBootstrap implements ApplicationListener
|
||||
// execute if there were changes raised by Hibernate
|
||||
if (tempFile != null)
|
||||
{
|
||||
executeScriptFile(cfg, connection, tempFile);
|
||||
InputStream tempInputStream = new FileInputStream(tempFile);
|
||||
executeScriptFile(cfg, connection, tempInputStream, tempFile.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,14 +410,14 @@ public class SchemaBootstrap implements ApplicationListener
|
||||
private void executeScriptUrl(Configuration cfg, Connection connection, String scriptUrl) throws Exception
|
||||
{
|
||||
Dialect dialect = Dialect.getDialect(cfg.getProperties());
|
||||
File scriptFile = getScriptFile(dialect.getClass(), scriptUrl);
|
||||
InputStream scriptInputStream = getScriptInputStream(dialect.getClass(), scriptUrl);
|
||||
// check that it exists
|
||||
if (scriptFile == null)
|
||||
if (scriptInputStream == null)
|
||||
{
|
||||
throw AlfrescoRuntimeException.create(ERR_SCRIPT_NOT_FOUND, scriptUrl);
|
||||
}
|
||||
// now execute it
|
||||
executeScriptFile(cfg, connection, scriptFile);
|
||||
executeScriptFile(cfg, connection, scriptInputStream, scriptUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,45 +425,46 @@ public class SchemaBootstrap implements ApplicationListener
|
||||
* it. If not found, the dialect hierarchy will be walked until a compatible script is
|
||||
* found. This makes it possible to have scripts that are generic to all dialects.
|
||||
*
|
||||
* @return Returns the file if found, otherwise null
|
||||
* @return Returns an input stream onto the script, otherwise null
|
||||
*/
|
||||
private File getScriptFile(Class dialectClazz, String scriptUrl) throws Exception
|
||||
private InputStream getScriptInputStream(Class dialectClazz, String scriptUrl) throws Exception
|
||||
{
|
||||
// replace the dialect placeholder
|
||||
String dialectScriptUrl = scriptUrl.replaceAll(PLACEHOLDER_SCRIPT_DIALECT, dialectClazz.getName());
|
||||
// get a handle on the resource
|
||||
try
|
||||
ResourcePatternResolver rpr = new PathMatchingResourcePatternResolver(this.getClass().getClassLoader());
|
||||
Resource resource = rpr.getResource(dialectScriptUrl);
|
||||
if (!resource.exists())
|
||||
{
|
||||
File scriptFile = ResourceUtils.getFile(dialectScriptUrl);
|
||||
if (scriptFile.exists())
|
||||
// it wasn't found. Get the superclass of the dialect and try again
|
||||
Class superClazz = dialectClazz.getSuperclass();
|
||||
if (Dialect.class.isAssignableFrom(superClazz))
|
||||
{
|
||||
// found a compatible dialect version
|
||||
return scriptFile;
|
||||
// we still have a Dialect - try again
|
||||
return getScriptInputStream(superClazz, scriptUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have exhausted all options
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
// doesn't exist
|
||||
}
|
||||
// it wasn't found. Get the superclass of the dialect and try again
|
||||
Class superClazz = dialectClazz.getSuperclass();
|
||||
if (Dialect.class.isAssignableFrom(superClazz))
|
||||
{
|
||||
// we still have a Dialect - try again
|
||||
return getScriptFile(superClazz, scriptUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have exhausted all options
|
||||
return null;
|
||||
// we have a handle to it
|
||||
return resource.getInputStream();
|
||||
}
|
||||
}
|
||||
|
||||
private void executeScriptFile(Configuration cfg, Connection connection, File scriptFile) throws Exception
|
||||
private void executeScriptFile(
|
||||
Configuration cfg,
|
||||
Connection connection,
|
||||
InputStream scriptInputStream,
|
||||
String scriptUrl) throws Exception
|
||||
{
|
||||
logger.info(I18NUtil.getMessage(MSG_EXECUTING_SCRIPT, scriptFile));
|
||||
logger.info(I18NUtil.getMessage(MSG_EXECUTING_SCRIPT, scriptUrl));
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(scriptFile), "UTF8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(scriptInputStream, "UTF8"));
|
||||
try
|
||||
{
|
||||
int line = 0;
|
||||
@@ -486,7 +491,7 @@ public class SchemaBootstrap implements ApplicationListener
|
||||
if (sb.length() > 0)
|
||||
{
|
||||
// we have an unterminated statement
|
||||
throw AlfrescoRuntimeException.create(ERR_STATEMENT_TERMINATOR, (line - 1), scriptFile);
|
||||
throw AlfrescoRuntimeException.create(ERR_STATEMENT_TERMINATOR, (line - 1), scriptUrl);
|
||||
}
|
||||
// there has not been anything to execute - it's just a comment line
|
||||
continue;
|
||||
@@ -524,6 +529,7 @@ public class SchemaBootstrap implements ApplicationListener
|
||||
finally
|
||||
{
|
||||
try { reader.close(); } catch (Throwable e) {}
|
||||
try { scriptInputStream.close(); } catch (Throwable e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -924,7 +924,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
private boolean checkForCopy(Set<ExecutedRuleData> executedRules, NodeRef actionedUponNodeRef, Rule rule)
|
||||
{
|
||||
boolean result = true;
|
||||
if (this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
||||
if (this.nodeService.exists(actionedUponNodeRef) == true && this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
|
@@ -1,335 +1,344 @@
|
||||
/*
|
||||
* 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.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceDescriptor;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.view.ExporterService;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of a Service Registry based on the definition of
|
||||
* Services contained within a Spring Bean Factory.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class ServiceDescriptorRegistry
|
||||
implements BeanFactoryAware, BeanFactoryPostProcessor, ServiceRegistry
|
||||
{
|
||||
// Bean Factory within which the registry lives
|
||||
private BeanFactory beanFactory = null;
|
||||
|
||||
// Service Descriptor map
|
||||
private Map<QName, BeanServiceDescriptor> descriptors = new HashMap<QName, BeanServiceDescriptor>();
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
|
||||
*/
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
|
||||
{
|
||||
Map beans = beanFactory.getBeansOfType(ServiceDescriptorMetaData.class);
|
||||
Iterator iter = beans.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
ServiceDescriptorMetaData metaData = (ServiceDescriptorMetaData)entry.getValue();
|
||||
QName serviceName = QName.createQName(metaData.getNamespace(), (String)entry.getKey());
|
||||
StoreRedirector redirector = (entry.getValue() instanceof StoreRedirector) ? (StoreRedirector)entry.getValue() : null;
|
||||
BeanServiceDescriptor serviceDescriptor = new BeanServiceDescriptor(serviceName, metaData, redirector);
|
||||
descriptors.put(serviceDescriptor.getQualifiedName(), serviceDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
|
||||
*/
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
|
||||
{
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getServices()
|
||||
*/
|
||||
public Collection<QName> getServices()
|
||||
{
|
||||
return Collections.unmodifiableSet(descriptors.keySet());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#isServiceProvided(org.alfresco.repo.ref.QName)
|
||||
*/
|
||||
public boolean isServiceProvided(QName service)
|
||||
{
|
||||
return descriptors.containsKey(service);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getServiceDescriptor(org.alfresco.repo.ref.QName)
|
||||
*/
|
||||
public ServiceDescriptor getServiceDescriptor(QName service)
|
||||
{
|
||||
return descriptors.get(service);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getService(org.alfresco.repo.ref.QName)
|
||||
*/
|
||||
public Object getService(QName service)
|
||||
{
|
||||
return beanFactory.getBean(service.getLocalName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getDescriptorService()
|
||||
*/
|
||||
public DescriptorService getDescriptorService()
|
||||
{
|
||||
return (DescriptorService)getService(DESCRIPTOR_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getNodeService()
|
||||
*/
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
return (NodeService)getService(NODE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getNodeService()
|
||||
*/
|
||||
public AuthenticationService getAuthenticationService()
|
||||
{
|
||||
return (AuthenticationService)getService(AUTHENTICATION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getContentService()
|
||||
*/
|
||||
public ContentService getContentService()
|
||||
{
|
||||
return (ContentService)getService(CONTENT_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getMimetypeService()
|
||||
*/
|
||||
public MimetypeService getMimetypeService()
|
||||
{
|
||||
return (MimetypeService)getService(MIMETYPE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getVersionService()
|
||||
*/
|
||||
public VersionService getVersionService()
|
||||
{
|
||||
return (VersionService)getService(VERSION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getLockService()
|
||||
*/
|
||||
public LockService getLockService()
|
||||
{
|
||||
return (LockService)getService(LOCK_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getDictionaryService()
|
||||
*/
|
||||
public DictionaryService getDictionaryService()
|
||||
{
|
||||
return (DictionaryService)getService(DICTIONARY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getSearchService()
|
||||
*/
|
||||
public SearchService getSearchService()
|
||||
{
|
||||
return (SearchService)getService(SEARCH_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getTransactionService()
|
||||
*/
|
||||
public TransactionService getTransactionService()
|
||||
{
|
||||
return (TransactionService)getService(TRANSACTION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getCopyService()
|
||||
*/
|
||||
public CopyService getCopyService()
|
||||
{
|
||||
return (CopyService)getService(COPY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getCheckOutCheckInService()
|
||||
*/
|
||||
public CheckOutCheckInService getCheckOutCheckInService()
|
||||
{
|
||||
return (CheckOutCheckInService)getService(COCI_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getCategoryService()
|
||||
*/
|
||||
public CategoryService getCategoryService()
|
||||
{
|
||||
return (CategoryService)getService(CATEGORY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getNamespaceService()
|
||||
*/
|
||||
public NamespaceService getNamespaceService()
|
||||
{
|
||||
return (NamespaceService)getService(NAMESPACE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getImporterService()
|
||||
*/
|
||||
public ImporterService getImporterService()
|
||||
{
|
||||
return (ImporterService)getService(IMPORTER_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getExporterService()
|
||||
*/
|
||||
public ExporterService getExporterService()
|
||||
{
|
||||
return (ExporterService)getService(EXPORTER_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getRuleService()
|
||||
*/
|
||||
public RuleService getRuleService()
|
||||
{
|
||||
return (RuleService)getService(RULE_SERVICE);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getActionService()
|
||||
*/
|
||||
public ActionService getActionService()
|
||||
{
|
||||
return (ActionService)getService(ACTION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getPermissionService()
|
||||
*/
|
||||
public PermissionService getPermissionService()
|
||||
{
|
||||
return (PermissionService)getService(PERMISSIONS_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getAuthorityService()
|
||||
*/
|
||||
public AuthorityService getAuthorityService()
|
||||
{
|
||||
return (AuthorityService)getService(AUTHORITY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getTemplateService()
|
||||
*/
|
||||
public TemplateService getTemplateService()
|
||||
{
|
||||
return (TemplateService)getService(TEMPLATE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getTemplateService()
|
||||
*/
|
||||
public FileFolderService getFileFolderService()
|
||||
{
|
||||
return (FileFolderService)getService(FILE_FOLDER_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getScriptService()
|
||||
*/
|
||||
public ScriptService getScriptService()
|
||||
{
|
||||
return (ScriptService)getService(SCRIPT_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getWorkflowService()
|
||||
*/
|
||||
public WorkflowService getWorkflowService()
|
||||
{
|
||||
return (WorkflowService)getService(WORKFLOW_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AVMService.
|
||||
* @return The AVMService or null if there is none.
|
||||
*/
|
||||
public AVMService getAVMService()
|
||||
{
|
||||
return (AVMService)getService(AVM_SERVICE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceDescriptor;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.view.ExporterService;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of a Service Registry based on the definition of
|
||||
* Services contained within a Spring Bean Factory.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class ServiceDescriptorRegistry
|
||||
implements BeanFactoryAware, BeanFactoryPostProcessor, ServiceRegistry
|
||||
{
|
||||
// Bean Factory within which the registry lives
|
||||
private BeanFactory beanFactory = null;
|
||||
|
||||
// Service Descriptor map
|
||||
private Map<QName, BeanServiceDescriptor> descriptors = new HashMap<QName, BeanServiceDescriptor>();
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
|
||||
*/
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
|
||||
{
|
||||
Map beans = beanFactory.getBeansOfType(ServiceDescriptorMetaData.class);
|
||||
Iterator iter = beans.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
ServiceDescriptorMetaData metaData = (ServiceDescriptorMetaData)entry.getValue();
|
||||
QName serviceName = QName.createQName(metaData.getNamespace(), (String)entry.getKey());
|
||||
StoreRedirector redirector = (entry.getValue() instanceof StoreRedirector) ? (StoreRedirector)entry.getValue() : null;
|
||||
BeanServiceDescriptor serviceDescriptor = new BeanServiceDescriptor(serviceName, metaData, redirector);
|
||||
descriptors.put(serviceDescriptor.getQualifiedName(), serviceDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
|
||||
*/
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
|
||||
{
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getServices()
|
||||
*/
|
||||
public Collection<QName> getServices()
|
||||
{
|
||||
return Collections.unmodifiableSet(descriptors.keySet());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#isServiceProvided(org.alfresco.repo.ref.QName)
|
||||
*/
|
||||
public boolean isServiceProvided(QName service)
|
||||
{
|
||||
return descriptors.containsKey(service);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getServiceDescriptor(org.alfresco.repo.ref.QName)
|
||||
*/
|
||||
public ServiceDescriptor getServiceDescriptor(QName service)
|
||||
{
|
||||
return descriptors.get(service);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getService(org.alfresco.repo.ref.QName)
|
||||
*/
|
||||
public Object getService(QName service)
|
||||
{
|
||||
return beanFactory.getBean(service.getLocalName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getDescriptorService()
|
||||
*/
|
||||
public DescriptorService getDescriptorService()
|
||||
{
|
||||
return (DescriptorService)getService(DESCRIPTOR_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getNodeService()
|
||||
*/
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
return (NodeService)getService(NODE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getNodeService()
|
||||
*/
|
||||
public AuthenticationService getAuthenticationService()
|
||||
{
|
||||
return (AuthenticationService)getService(AUTHENTICATION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getContentService()
|
||||
*/
|
||||
public ContentService getContentService()
|
||||
{
|
||||
return (ContentService)getService(CONTENT_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getMimetypeService()
|
||||
*/
|
||||
public MimetypeService getMimetypeService()
|
||||
{
|
||||
return (MimetypeService)getService(MIMETYPE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getVersionService()
|
||||
*/
|
||||
public VersionService getVersionService()
|
||||
{
|
||||
return (VersionService)getService(VERSION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getLockService()
|
||||
*/
|
||||
public LockService getLockService()
|
||||
{
|
||||
return (LockService)getService(LOCK_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.service.ServiceRegistry#getDictionaryService()
|
||||
*/
|
||||
public DictionaryService getDictionaryService()
|
||||
{
|
||||
return (DictionaryService)getService(DICTIONARY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getSearchService()
|
||||
*/
|
||||
public SearchService getSearchService()
|
||||
{
|
||||
return (SearchService)getService(SEARCH_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getTransactionService()
|
||||
*/
|
||||
public TransactionService getTransactionService()
|
||||
{
|
||||
return (TransactionService)getService(TRANSACTION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getCopyService()
|
||||
*/
|
||||
public CopyService getCopyService()
|
||||
{
|
||||
return (CopyService)getService(COPY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getCheckOutCheckInService()
|
||||
*/
|
||||
public CheckOutCheckInService getCheckOutCheckInService()
|
||||
{
|
||||
return (CheckOutCheckInService)getService(COCI_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getCategoryService()
|
||||
*/
|
||||
public CategoryService getCategoryService()
|
||||
{
|
||||
return (CategoryService)getService(CATEGORY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getNamespaceService()
|
||||
*/
|
||||
public NamespaceService getNamespaceService()
|
||||
{
|
||||
return (NamespaceService)getService(NAMESPACE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getImporterService()
|
||||
*/
|
||||
public ImporterService getImporterService()
|
||||
{
|
||||
return (ImporterService)getService(IMPORTER_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getExporterService()
|
||||
*/
|
||||
public ExporterService getExporterService()
|
||||
{
|
||||
return (ExporterService)getService(EXPORTER_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getRuleService()
|
||||
*/
|
||||
public RuleService getRuleService()
|
||||
{
|
||||
return (RuleService)getService(RULE_SERVICE);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getActionService()
|
||||
*/
|
||||
public ActionService getActionService()
|
||||
{
|
||||
return (ActionService)getService(ACTION_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getPermissionService()
|
||||
*/
|
||||
public PermissionService getPermissionService()
|
||||
{
|
||||
return (PermissionService)getService(PERMISSIONS_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getAuthorityService()
|
||||
*/
|
||||
public AuthorityService getAuthorityService()
|
||||
{
|
||||
return (AuthorityService)getService(AUTHORITY_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getTemplateService()
|
||||
*/
|
||||
public TemplateService getTemplateService()
|
||||
{
|
||||
return (TemplateService)getService(TEMPLATE_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getTemplateService()
|
||||
*/
|
||||
public FileFolderService getFileFolderService()
|
||||
{
|
||||
return (FileFolderService)getService(FILE_FOLDER_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getScriptService()
|
||||
*/
|
||||
public ScriptService getScriptService()
|
||||
{
|
||||
return (ScriptService)getService(SCRIPT_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getWorkflowService()
|
||||
*/
|
||||
public WorkflowService getWorkflowService()
|
||||
{
|
||||
return (WorkflowService)getService(WORKFLOW_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getWorkflowService()
|
||||
*/
|
||||
public AuditService getAuditService()
|
||||
{
|
||||
return (AuditService)getService(AUDIT_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AVMService.
|
||||
* @return The AVMService or null if there is none.
|
||||
*/
|
||||
public AVMService getAVMService()
|
||||
{
|
||||
return (AVMService)getService(AVM_SERVICE);
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import javax.transaction.UserTransaction;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
@@ -54,6 +55,10 @@ public class VersionCounterServiceTest extends TestCase
|
||||
nodeService = serviceRegistry.getNodeService();
|
||||
counter = (VersionCounterService) ctx.getBean("versionCounterService");
|
||||
|
||||
// authenticate
|
||||
AuthenticationComponent auth = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
||||
auth.setSystemUserAsCurrentUser();
|
||||
|
||||
storeRef1 = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "test1_" + System.currentTimeMillis());
|
||||
storeRef2 = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "test2_" + System.currentTimeMillis());
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ public class StartWorkflowActionExecuterTest extends BaseSpringTest
|
||||
{
|
||||
// Execute the action
|
||||
ActionImpl action = new ActionImpl(null, GUID.generate(), StartWorkflowActionExecuter.NAME, null);
|
||||
action.setParameterValue(StartWorkflowActionExecuter.PARAM_WORKFLOW_NAME, "jbpm://wf:review");
|
||||
action.setParameterValue(StartWorkflowActionExecuter.PARAM_WORKFLOW_NAME, "jbpm$wf:review");
|
||||
action.setParameterValue(WorkflowModel.PROP_REVIEW_DUE_DATE.toPrefixString(namespaceService), new Date());
|
||||
NodeRef reviewer = personService.getPerson("admin");
|
||||
action.setParameterValue(WorkflowModel.ASSOC_REVIEWER.toPrefixString(namespaceService), reviewer);
|
||||
|
@@ -18,6 +18,7 @@ package org.alfresco.repo.workflow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -42,6 +43,10 @@ public class WorkflowServiceImplTest extends BaseSpringTest
|
||||
{
|
||||
workflowService = (WorkflowService)applicationContext.getBean(ServiceRegistry.WORKFLOW_SERVICE.getLocalName());
|
||||
nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName());
|
||||
|
||||
// authenticate
|
||||
AuthenticationComponent auth = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
||||
auth.setSystemUserAsCurrentUser();
|
||||
}
|
||||
|
||||
public void testGetWorkflowDefinitions()
|
||||
|
@@ -1,275 +1,283 @@
|
||||
/*
|
||||
* 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.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.view.ExporterService;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
|
||||
|
||||
/**
|
||||
* This interface represents the registry of public Repository Services.
|
||||
* The registry provides meta-data about each service and provides
|
||||
* access to the service interface.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
@PublicService
|
||||
public interface ServiceRegistry
|
||||
{
|
||||
// Service Bean Names
|
||||
|
||||
static final String SERVICE_REGISTRY = "ServiceRegistry";
|
||||
|
||||
static final QName REGISTRY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ServiceRegistry");
|
||||
static final QName DESCRIPTOR_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DescriptorService");
|
||||
static final QName TRANSACTION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TransactionService");
|
||||
static final QName AUTHENTICATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AuthenticationService");
|
||||
static final QName NAMESPACE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "NamespaceService");
|
||||
static final QName DICTIONARY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DictionaryService");
|
||||
static final QName NODE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "NodeService");
|
||||
static final QName CONTENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ContentService");
|
||||
static final QName MIMETYPE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "MimetypeService");
|
||||
static final QName SEARCH_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "SearchService");
|
||||
static final QName CATEGORY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CategoryService");
|
||||
static final QName COPY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CopyService");
|
||||
static final QName LOCK_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "LockService");
|
||||
static final QName VERSION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "VersionService");
|
||||
static final QName COCI_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CheckoutCheckinService");
|
||||
static final QName RULE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RuleService");
|
||||
static final QName IMPORTER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ImporterService");
|
||||
static final QName EXPORTER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ExporterService");
|
||||
static final QName ACTION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ActionService");
|
||||
static final QName PERMISSIONS_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "PermissionService");
|
||||
static final QName AUTHORITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AuthorityService");
|
||||
static final QName TEMPLATE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TemplateService");
|
||||
static final QName FILE_FOLDER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FileFolderService");
|
||||
static final QName SCRIPT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ScriptService");
|
||||
static final QName WORKFLOW_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WorkflowService");
|
||||
static final QName AVM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMService");
|
||||
|
||||
/**
|
||||
* Get the list of services provided by the Repository
|
||||
*
|
||||
* @return list of provided Services
|
||||
*/
|
||||
@NotAuditable
|
||||
Collection<QName> getServices();
|
||||
|
||||
/**
|
||||
* Is the specified service provided by the Repository?
|
||||
*
|
||||
* @param service name of service to test provision of
|
||||
* @return true => provided, false => not provided
|
||||
*/
|
||||
@NotAuditable
|
||||
boolean isServiceProvided(QName service);
|
||||
|
||||
/**
|
||||
* Get meta-data about the specified service
|
||||
*
|
||||
* @param service name of service to retrieve meta data for
|
||||
* @return the service meta data
|
||||
*/
|
||||
@NotAuditable
|
||||
ServiceDescriptor getServiceDescriptor(QName service);
|
||||
|
||||
/**
|
||||
* Get the specified service.
|
||||
*
|
||||
* @param service name of service to retrieve
|
||||
* @return the service interface (must cast to interface as described in service meta-data)
|
||||
*/
|
||||
@NotAuditable
|
||||
Object getService(QName service);
|
||||
|
||||
/**
|
||||
* @return the descriptor service
|
||||
*/
|
||||
@NotAuditable
|
||||
DescriptorService getDescriptorService();
|
||||
|
||||
/**
|
||||
* @return the transaction service
|
||||
*/
|
||||
@NotAuditable
|
||||
TransactionService getTransactionService();
|
||||
|
||||
/**
|
||||
* @return the namespace service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
NamespaceService getNamespaceService();
|
||||
|
||||
/**
|
||||
* @return the authentication service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
AuthenticationService getAuthenticationService();
|
||||
|
||||
/**
|
||||
* @return the node service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
NodeService getNodeService();
|
||||
|
||||
/**
|
||||
* @return the content service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
ContentService getContentService();
|
||||
|
||||
/**
|
||||
* @return the mimetype service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
MimetypeService getMimetypeService();
|
||||
|
||||
/**
|
||||
* @return the search service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
SearchService getSearchService();
|
||||
|
||||
/**
|
||||
* @return the version service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
VersionService getVersionService();
|
||||
|
||||
/**
|
||||
* @return the lock service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
LockService getLockService();
|
||||
|
||||
/**
|
||||
* @return the dictionary service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
DictionaryService getDictionaryService();
|
||||
|
||||
/**
|
||||
* @return the copy service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
CopyService getCopyService();
|
||||
|
||||
/**
|
||||
* @return the checkout / checkin service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
CheckOutCheckInService getCheckOutCheckInService();
|
||||
|
||||
/**
|
||||
* @return the category service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
CategoryService getCategoryService();
|
||||
|
||||
/**
|
||||
* @return the importer service or null if not present
|
||||
*/
|
||||
@NotAuditable
|
||||
ImporterService getImporterService();
|
||||
|
||||
/**
|
||||
* @return the exporter service or null if not present
|
||||
*/
|
||||
@NotAuditable
|
||||
ExporterService getExporterService();
|
||||
|
||||
/**
|
||||
* @return the rule service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
RuleService getRuleService();
|
||||
|
||||
/**
|
||||
* @return the action service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
ActionService getActionService();
|
||||
|
||||
/**
|
||||
* @return the permission service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
PermissionService getPermissionService();
|
||||
|
||||
/**
|
||||
* @return the authority service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
AuthorityService getAuthorityService();
|
||||
|
||||
/**
|
||||
* @return the template service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
TemplateService getTemplateService();
|
||||
|
||||
/**
|
||||
* @return the file-folder manipulation service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
FileFolderService getFileFolderService();
|
||||
|
||||
/**
|
||||
* @return the script execution service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
ScriptService getScriptService();
|
||||
|
||||
/**
|
||||
* @return the workflow service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
WorkflowService getWorkflowService();
|
||||
|
||||
/**
|
||||
* Get the AVMService.
|
||||
* @return The AVM service (or null if one is not provided);
|
||||
*/
|
||||
@NotAuditable
|
||||
AVMService getAVMService();
|
||||
}
|
||||
/*
|
||||
* 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.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.view.ExporterService;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
|
||||
|
||||
/**
|
||||
* This interface represents the registry of public Repository Services.
|
||||
* The registry provides meta-data about each service and provides
|
||||
* access to the service interface.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
@PublicService
|
||||
public interface ServiceRegistry
|
||||
{
|
||||
// Service Bean Names
|
||||
|
||||
static final String SERVICE_REGISTRY = "ServiceRegistry";
|
||||
|
||||
static final QName REGISTRY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ServiceRegistry");
|
||||
static final QName DESCRIPTOR_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DescriptorService");
|
||||
static final QName TRANSACTION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TransactionService");
|
||||
static final QName AUTHENTICATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AuthenticationService");
|
||||
static final QName NAMESPACE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "NamespaceService");
|
||||
static final QName DICTIONARY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DictionaryService");
|
||||
static final QName NODE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "NodeService");
|
||||
static final QName CONTENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ContentService");
|
||||
static final QName MIMETYPE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "MimetypeService");
|
||||
static final QName SEARCH_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "SearchService");
|
||||
static final QName CATEGORY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CategoryService");
|
||||
static final QName COPY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CopyService");
|
||||
static final QName LOCK_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "LockService");
|
||||
static final QName VERSION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "VersionService");
|
||||
static final QName COCI_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CheckoutCheckinService");
|
||||
static final QName RULE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RuleService");
|
||||
static final QName IMPORTER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ImporterService");
|
||||
static final QName EXPORTER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ExporterService");
|
||||
static final QName ACTION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ActionService");
|
||||
static final QName PERMISSIONS_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "PermissionService");
|
||||
static final QName AUTHORITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AuthorityService");
|
||||
static final QName TEMPLATE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TemplateService");
|
||||
static final QName FILE_FOLDER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FileFolderService");
|
||||
static final QName SCRIPT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ScriptService");
|
||||
static final QName WORKFLOW_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WorkflowService");
|
||||
static final QName AUDIT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AuditService");
|
||||
static final QName AVM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMService");
|
||||
|
||||
/**
|
||||
* Get the list of services provided by the Repository
|
||||
*
|
||||
* @return list of provided Services
|
||||
*/
|
||||
@NotAuditable
|
||||
Collection<QName> getServices();
|
||||
|
||||
/**
|
||||
* Is the specified service provided by the Repository?
|
||||
*
|
||||
* @param service name of service to test provision of
|
||||
* @return true => provided, false => not provided
|
||||
*/
|
||||
@NotAuditable
|
||||
boolean isServiceProvided(QName service);
|
||||
|
||||
/**
|
||||
* Get meta-data about the specified service
|
||||
*
|
||||
* @param service name of service to retrieve meta data for
|
||||
* @return the service meta data
|
||||
*/
|
||||
@NotAuditable
|
||||
ServiceDescriptor getServiceDescriptor(QName service);
|
||||
|
||||
/**
|
||||
* Get the specified service.
|
||||
*
|
||||
* @param service name of service to retrieve
|
||||
* @return the service interface (must cast to interface as described in service meta-data)
|
||||
*/
|
||||
@NotAuditable
|
||||
Object getService(QName service);
|
||||
|
||||
/**
|
||||
* @return the descriptor service
|
||||
*/
|
||||
@NotAuditable
|
||||
DescriptorService getDescriptorService();
|
||||
|
||||
/**
|
||||
* @return the transaction service
|
||||
*/
|
||||
@NotAuditable
|
||||
TransactionService getTransactionService();
|
||||
|
||||
/**
|
||||
* @return the namespace service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
NamespaceService getNamespaceService();
|
||||
|
||||
/**
|
||||
* @return the authentication service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
AuthenticationService getAuthenticationService();
|
||||
|
||||
/**
|
||||
* @return the node service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
NodeService getNodeService();
|
||||
|
||||
/**
|
||||
* @return the content service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
ContentService getContentService();
|
||||
|
||||
/**
|
||||
* @return the mimetype service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
MimetypeService getMimetypeService();
|
||||
|
||||
/**
|
||||
* @return the search service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
SearchService getSearchService();
|
||||
|
||||
/**
|
||||
* @return the version service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
VersionService getVersionService();
|
||||
|
||||
/**
|
||||
* @return the lock service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
LockService getLockService();
|
||||
|
||||
/**
|
||||
* @return the dictionary service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
DictionaryService getDictionaryService();
|
||||
|
||||
/**
|
||||
* @return the copy service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
CopyService getCopyService();
|
||||
|
||||
/**
|
||||
* @return the checkout / checkin service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
CheckOutCheckInService getCheckOutCheckInService();
|
||||
|
||||
/**
|
||||
* @return the category service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
CategoryService getCategoryService();
|
||||
|
||||
/**
|
||||
* @return the importer service or null if not present
|
||||
*/
|
||||
@NotAuditable
|
||||
ImporterService getImporterService();
|
||||
|
||||
/**
|
||||
* @return the exporter service or null if not present
|
||||
*/
|
||||
@NotAuditable
|
||||
ExporterService getExporterService();
|
||||
|
||||
/**
|
||||
* @return the rule service (or null, if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
RuleService getRuleService();
|
||||
|
||||
/**
|
||||
* @return the action service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
ActionService getActionService();
|
||||
|
||||
/**
|
||||
* @return the permission service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
PermissionService getPermissionService();
|
||||
|
||||
/**
|
||||
* @return the authority service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
AuthorityService getAuthorityService();
|
||||
|
||||
/**
|
||||
* @return the template service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
TemplateService getTemplateService();
|
||||
|
||||
/**
|
||||
* @return the file-folder manipulation service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
FileFolderService getFileFolderService();
|
||||
|
||||
/**
|
||||
* @return the script execution service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
ScriptService getScriptService();
|
||||
|
||||
/**
|
||||
* @return the workflow service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
WorkflowService getWorkflowService();
|
||||
|
||||
/**
|
||||
* @return the audit service (or null if one is not provided)
|
||||
*/
|
||||
@NotAuditable
|
||||
AuditService getAuditService();
|
||||
|
||||
/**
|
||||
* Get the AVMService.
|
||||
* @return The AVM service (or null if one is not provided);
|
||||
*/
|
||||
@NotAuditable
|
||||
AVMService getAVMService();
|
||||
}
|
||||
|
202
source/java/org/alfresco/service/cmr/audit/AuditInfo.java
Normal file
202
source/java/org/alfresco/service/cmr/audit/AuditInfo.java
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* 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.service.cmr.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* A single entry in an audit trail
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public interface AuditInfo
|
||||
{
|
||||
/**
|
||||
* The identifier for the application that performed the audit. Method interceptors around public services will use the string 'SystemMethodInterceptor'.
|
||||
*
|
||||
* @return - the application (may not be null).
|
||||
*/
|
||||
public String getAuditApplication();
|
||||
|
||||
/**
|
||||
* The name of the method executed on a public service.
|
||||
*
|
||||
* @return - the method name - this may be null for external audit entries.
|
||||
*/
|
||||
public String getAuditMethod();
|
||||
|
||||
/**
|
||||
* The public service on which a method was invoked.
|
||||
*
|
||||
* @return - the service name - this may be null for external audit entries.
|
||||
*/
|
||||
public String getAuditService();
|
||||
|
||||
/**
|
||||
* The address for the client. (This will be null in version 1.4)
|
||||
*
|
||||
* @return - the client address - may be null.
|
||||
*/
|
||||
public String getClientAddress();
|
||||
|
||||
/**
|
||||
* The timestamp for the audit entry.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Date getDate();
|
||||
|
||||
/**
|
||||
* Is this entry recording an error?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isFail();
|
||||
|
||||
/**
|
||||
* Was this audit entry subject to filtering (which must have been met if an entry is found). Filters are not applied in version 1.4.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isFiltered();
|
||||
|
||||
/**
|
||||
* Get the host address of the server machine.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getHostAddress();
|
||||
|
||||
/**
|
||||
* Get the ID of the key node.
|
||||
*
|
||||
* @return - the id of the key node - this may be null if there is no key or the key is not a node ref.
|
||||
*/
|
||||
public String getKeyGUID();
|
||||
|
||||
/**
|
||||
* The serialized properties on the key node, if one exists, after the method invocation. Note these values are serialized before the method is called so they are unaffected by
|
||||
* the method invocation. In V1.4 these are not stored.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<QName, Serializable> getKeyPropertiesAfter();
|
||||
|
||||
/**
|
||||
* The serialized properties on the key node, if one exists, before the method invocation. In V1.4 these are not stored.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<QName, Serializable> getKeyPropertiesBefore();
|
||||
|
||||
/**
|
||||
* The store ref for the key.
|
||||
*
|
||||
* @return - the store ref - this may be null if there is no key.
|
||||
*/
|
||||
public StoreRef getKeyStore();
|
||||
|
||||
/**
|
||||
* The message entered for application audit entries.
|
||||
*
|
||||
* @return - the audit message. This may be null, and will be null for audit entries generated from method invocations.
|
||||
*/
|
||||
public String getMessage();
|
||||
|
||||
/**
|
||||
* Get the serailized mehod arguments.
|
||||
*
|
||||
* These are not stored in V1.4.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Serializable[] getMethodArguments();
|
||||
|
||||
/**
|
||||
* Get the method arguments as strings.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getMethodArgumentsAsStrings();
|
||||
|
||||
/**
|
||||
* Get the path to the key node, if one exists.
|
||||
*
|
||||
* @return - the path or null.
|
||||
*/
|
||||
public String getPath();
|
||||
|
||||
/**
|
||||
* The serialized value of the return object.
|
||||
*
|
||||
* This is not available in V1.4.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Serializable getReturnObject();
|
||||
|
||||
/**
|
||||
* Get the return object string value.
|
||||
*
|
||||
* @return - the string value of the return object. May be null if the method is of type void or returns null.
|
||||
*/
|
||||
public String getReturnObjectAsString();
|
||||
|
||||
/**
|
||||
* Get the session id.
|
||||
*
|
||||
* This is not stored in V1.4.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getSessionId();
|
||||
|
||||
/**
|
||||
* Get the deserialized error, if one occurred.
|
||||
*
|
||||
* @return the throwable or null.
|
||||
*/
|
||||
public Throwable getThrowable();
|
||||
|
||||
/**
|
||||
* In 1.4, get the error message (no stack trace).
|
||||
*
|
||||
* @return - the error message
|
||||
*/
|
||||
public String getThrowableAsString();
|
||||
|
||||
/**
|
||||
* Get the transaction id which caused the audit.
|
||||
*
|
||||
* @return the Tx id (not null).
|
||||
*/
|
||||
public String getTxId();
|
||||
|
||||
/**
|
||||
* Get the name of the user who caused the audit entry.
|
||||
*
|
||||
* @return - the user name / user authority (not null)
|
||||
*/
|
||||
public String getUserIdentifier();
|
||||
|
||||
}
|
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package org.alfresco.service.cmr.audit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.audit.AuditState;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -81,5 +84,14 @@ public interface AuditService
|
||||
*/
|
||||
@NotAuditable
|
||||
public void audit(String source, String description, NodeRef key, Object... args);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the audit trail for a node ref.
|
||||
*
|
||||
* @param nodeRef - the node ref for which to get the audit trail.
|
||||
* @return - tha audit trail
|
||||
*/
|
||||
@NotAuditable
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef);
|
||||
}
|
||||
|
@@ -59,6 +59,11 @@ public interface CopyService
|
||||
* not copied.
|
||||
* <p>
|
||||
* Source association are not copied.
|
||||
* <p>
|
||||
* <b>NOTE:</b> The top-level node has it's <b>cm:name</b> property removed for
|
||||
* associations that do not allow duplicately named children in order
|
||||
* to prevent any chance of a duplicate name clash. Reassign the
|
||||
* <b>cm:name</b> property and catch the {@link DuplicateChildNodeNameException}.
|
||||
*
|
||||
* @param sourceNodeRef the node reference used as the source of the copy
|
||||
* @param destinationParent the intended parent of the new node
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,7 @@ import org.alfresco.repo.template.NodeSearchResultsMap;
|
||||
import org.alfresco.repo.template.SavedSearchResultsMap;
|
||||
import org.alfresco.repo.template.XPathResultsMap;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
@@ -495,7 +496,7 @@ public final class TemplateNode implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Display path to this node
|
||||
* @return Display path to this node - the path built of 'cm:name' attribute values.
|
||||
*/
|
||||
public String getDisplayPath()
|
||||
{
|
||||
@@ -514,6 +515,14 @@ public final class TemplateNode implements Serializable
|
||||
return displayPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return QName path to this node. This can be used for Lucene PATH: style queries
|
||||
*/
|
||||
public String getQnamePath()
|
||||
{
|
||||
return this.services.getNodeService().getPath(this.nodeRef).toPrefixString(this.services.getNamespaceService());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the small icon image for this node
|
||||
*/
|
||||
@@ -652,6 +661,14 @@ public final class TemplateNode implements Serializable
|
||||
}
|
||||
|
||||
|
||||
// Audit API
|
||||
|
||||
|
||||
public List<AuditInfo> getAuditTrail()
|
||||
{
|
||||
return this.services.getAuditService().getAuditTrail(this.nodeRef);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Misc helpers
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.Auditable;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -171,7 +172,7 @@ public interface PersonService
|
||||
* @param caseSensitiveUserName
|
||||
* @return
|
||||
*/
|
||||
|
||||
@NotAuditable
|
||||
public String getUserIdentifier(String caseSensitiveUserName);
|
||||
|
||||
}
|
||||
|
@@ -111,6 +111,7 @@ public interface WorkflowService
|
||||
* @param workflowName workflow name e.g. jbpm://review
|
||||
* @return the deployed workflow definition
|
||||
*/
|
||||
@Auditable(parameters = {"workflowName"})
|
||||
public WorkflowDefinition getDefinitionByName(String workflowName);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user