mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge LOGNEON-HEAD-3D-BENCHMARK to HEAD
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13241 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -165,6 +165,13 @@ public class FileFolderRemoteClient implements FileFolderRemote
|
||||
return remotePeer.create(ticket, parentNodeRef, name, typeQName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public FileInfo[] create(String ticket, final NodeRef[] parentNodeRefs, final String[] names, final QName[] typesQName) throws FileExistsException
|
||||
{
|
||||
return remotePeer.create(ticket, parentNodeRefs, names, typesQName);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -173,6 +180,14 @@ public class FileFolderRemoteClient implements FileFolderRemote
|
||||
remotePeer.delete(ticket, nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void delete(String ticket, final NodeRef[] nodeRefs)
|
||||
{
|
||||
remotePeer.delete(ticket, nodeRefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -213,6 +228,14 @@ public class FileFolderRemoteClient implements FileFolderRemote
|
||||
return remotePeer.putContent(ticket, nodeRef, bytes, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ContentData[] putContent(String ticket, NodeRef nodeRefs[], byte[][] bytes, String[] filenames)
|
||||
{
|
||||
return remotePeer.putContent(ticket, nodeRefs, bytes, filenames);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -357,6 +357,36 @@ public class FileFolderRemoteServer implements FileFolderRemote
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public FileInfo[] create(String ticket, final NodeRef[] parentNodeRefs, final String[] names, final QName[] typesQName) throws FileExistsException
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
try
|
||||
{
|
||||
authenticationService.validate(ticket);
|
||||
// Make the call
|
||||
RetryingTransactionCallback<FileInfo[]> callback = new RetryingTransactionCallback<FileInfo[]>()
|
||||
{
|
||||
public FileInfo[] execute() throws Throwable
|
||||
{
|
||||
FileInfo[] result = new FileInfo[parentNodeRefs.length];
|
||||
for (int i = 0; i< result.length; i++)
|
||||
{
|
||||
result[i] = fileFolderService.create(parentNodeRefs[i], names[i], typesQName[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
return retryingTransactionHelper.doInTransaction(callback, false, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -383,6 +413,33 @@ public class FileFolderRemoteServer implements FileFolderRemote
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void delete(String ticket, final NodeRef[] nodeRefs)
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
try
|
||||
{
|
||||
authenticationService.validate(ticket);
|
||||
// Make the call
|
||||
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
fileFolderService.delete(nodeRef);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
retryingTransactionHelper.doInTransaction(callback, false, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -532,6 +589,62 @@ public class FileFolderRemoteServer implements FileFolderRemote
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ContentData[] putContent(
|
||||
String ticket,
|
||||
final NodeRef[] nodeRefs,
|
||||
final byte[][] bytes,
|
||||
final String[] filenames)
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
try
|
||||
{
|
||||
authenticationService.validate(ticket);
|
||||
// Make the call
|
||||
RetryingTransactionCallback<ContentData[]> callback = new RetryingTransactionCallback<ContentData[]>()
|
||||
{
|
||||
public ContentData[] execute() throws Throwable
|
||||
{
|
||||
// Guess the mimetype
|
||||
ContentData[] results = new ContentData[filenames.length];
|
||||
|
||||
for (int i = 0; i < filenames.length; i++)
|
||||
{
|
||||
|
||||
String mimetype = mimetypeService.guessMimetype(filenames[i]);
|
||||
|
||||
// Get a writer
|
||||
ContentWriter writer = fileFolderService.getWriter(nodeRefs[i]);
|
||||
// Make a stream
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes[i]);
|
||||
// Guess the encoding
|
||||
ContentCharsetFinder charsetFinder = mimetypeService.getContentCharsetFinder();
|
||||
Charset charset = charsetFinder.getCharset(is, mimetype);
|
||||
// Set metadata
|
||||
writer.setEncoding(charset.name());
|
||||
writer.setMimetype(mimetype);
|
||||
|
||||
// Write the stream
|
||||
writer.putContent(is);
|
||||
results[i] = writer.getContentData();
|
||||
}
|
||||
// Done
|
||||
return results;
|
||||
}
|
||||
};
|
||||
ContentData[] contentData = retryingTransactionHelper.doInTransaction(callback, false, true);
|
||||
// Done
|
||||
return contentData;
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -24,25 +24,18 @@
|
||||
*/
|
||||
package org.alfresco.repo.remote;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.encoding.ContentCharsetFinder;
|
||||
import org.alfresco.repo.node.db.NodeDaoService;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.remote.FileFolderRemote;
|
||||
import org.alfresco.service.cmr.remote.LoaderRemote;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
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.repository.*;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -51,6 +44,13 @@ import org.alfresco.util.PropertyMap;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Server side implementation of the <code>LoaderServiceTransport</code> transport
|
||||
* layer. This is the class that gets exported remotely as it contains the
|
||||
@@ -73,7 +73,9 @@ public class LoaderRemoteServer implements LoaderRemote
|
||||
private NodeService nodeService;
|
||||
private NodeDaoService nodeDaoService;
|
||||
private FileFolderService fileFolderService;
|
||||
private FileFolderRemote fileFolderRemote;
|
||||
private MimetypeService mimetypeService;
|
||||
private CheckOutCheckInService checkOutCheckInService;
|
||||
|
||||
/**
|
||||
* @param transactionService provides transactional support and retrying
|
||||
@@ -115,6 +117,11 @@ public class LoaderRemoteServer implements LoaderRemote
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setFileFolderRemote(FileFolderRemote fileFolderRemote)
|
||||
{
|
||||
this.fileFolderRemote = fileFolderRemote;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mimetypeService used to determine encoding, etc
|
||||
*/
|
||||
@@ -123,6 +130,11 @@ public class LoaderRemoteServer implements LoaderRemote
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
|
||||
{
|
||||
this.checkOutCheckInService = checkOutCheckInService;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -285,4 +297,154 @@ public class LoaderRemoteServer implements LoaderRemote
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void coci(String ticket, final NodeRef[] nodeRef, byte[][] bytes, List<HashMap<String, Serializable>> versionProperties)
|
||||
{
|
||||
FileInfo[] workingCopy = checkout(ticket, nodeRef);
|
||||
String[] fna = new String[bytes.length];
|
||||
for (int i = 0; i < workingCopy.length; i++)
|
||||
{
|
||||
fna[i] = workingCopy[i].getName();
|
||||
versionProperties.add(new HashMap<String, Serializable>());
|
||||
}
|
||||
fileFolderRemote.putContent(ticket, getNodesRef(workingCopy), bytes, fna);
|
||||
checkin(ticket, getNodesRef(workingCopy), versionProperties);
|
||||
}
|
||||
|
||||
NodeRef[] getNodesRef(FileInfo[] filesInfoList)
|
||||
{
|
||||
NodeRef[] nr = new NodeRef[filesInfoList.length];
|
||||
for (int i = 0; i < filesInfoList.length; i++)
|
||||
{
|
||||
nr[i] = (filesInfoList[i].getNodeRef());
|
||||
}
|
||||
return nr;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public NodeRef checkout(String ticket,final NodeRef nodeRef)
|
||||
{
|
||||
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
try
|
||||
{
|
||||
authenticationService.validate(ticket);
|
||||
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
//check out current document
|
||||
return checkOutCheckInService.checkout(nodeRef);
|
||||
}
|
||||
|
||||
};
|
||||
return retryingTransactionHelper.doInTransaction(callback, false, true);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public FileInfo[] checkout(String ticket, final NodeRef[] nodeRef)
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
try
|
||||
{
|
||||
authenticationService.validate(ticket);
|
||||
RetryingTransactionCallback<FileInfo[]> callback = new RetryingTransactionCallback<FileInfo[]>()
|
||||
{
|
||||
public FileInfo[] execute() throws Throwable
|
||||
{
|
||||
FileInfo[] arr = new FileInfo[nodeRef.length];
|
||||
|
||||
for(int i = 0; i < nodeRef.length; i++)
|
||||
{
|
||||
//check out current document
|
||||
arr[i] = fileFolderService.getFileInfo(checkOutCheckInService.checkout(nodeRef[i]));
|
||||
}
|
||||
//Done
|
||||
return arr;
|
||||
}
|
||||
|
||||
};
|
||||
return retryingTransactionHelper.doInTransaction(callback, false, true);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public NodeRef checkin(String ticket,
|
||||
final NodeRef workingCopyNodeRef,
|
||||
final Map<String, Serializable> versionProperties)
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
try
|
||||
{
|
||||
authenticationService.validate(ticket);
|
||||
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
//check in current document
|
||||
return checkOutCheckInService.checkin(workingCopyNodeRef,versionProperties);
|
||||
}
|
||||
};
|
||||
return retryingTransactionHelper.doInTransaction(callback, false, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public NodeRef [] checkin(String ticket, final NodeRef [] workingCopyNodeRef,
|
||||
final List<HashMap<String, Serializable>> versionProperties)
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
|
||||
try
|
||||
{
|
||||
authenticationService.validate(ticket);
|
||||
RetryingTransactionCallback<NodeRef[]> callback = new RetryingTransactionCallback<NodeRef[]>()
|
||||
{
|
||||
public NodeRef [] execute() throws Throwable
|
||||
{
|
||||
NodeRef [] nr = new NodeRef[workingCopyNodeRef.length];
|
||||
for(int i = 0; i < workingCopyNodeRef.length;i++)
|
||||
{
|
||||
//check in current document
|
||||
nr[i] = checkOutCheckInService.checkin(workingCopyNodeRef[i],versionProperties.get(i));
|
||||
}
|
||||
//Done
|
||||
return nr;
|
||||
}
|
||||
|
||||
};
|
||||
return retryingTransactionHelper.doInTransaction(callback, false, true);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user