ALF-10902 : No friendly notification occurs when Editor or Collaborator tries to delete content

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31363 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2011-10-19 15:55:01 +00:00
parent 3c079c5983
commit 912e873620
13 changed files with 359 additions and 173 deletions

View File

@@ -168,10 +168,7 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
} }
if ( context.isShareURLEnabled()) if ( context.isShareURLEnabled())
{ {
// try
// {
String site = getSiteForNode(nodeRef); String site = getSiteForNode(nodeRef);
// String site = "wibble";
if(site != null) if(site != null)
{ {
// Make sure the state has the associated node details // Make sure the state has the associated node details
@@ -179,6 +176,8 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
StringBuilder urlStr = new StringBuilder(); StringBuilder urlStr = new StringBuilder();
// This is the URL generated
// http://markr:8080/share/page/site/wibble/folder-details?nodeRef=workspace://SpacesStore/f72b2475-7571-46fe-947b-b0ee1b6a82ea
urlStr.append("[InternetShortcut]\r\n"); urlStr.append("[InternetShortcut]\r\n");
urlStr.append("URL="); urlStr.append("URL=");
urlStr.append(getShareURLPrefix()); urlStr.append(getShareURLPrefix());
@@ -188,23 +187,20 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
urlStr.append( nodeRef.getId()); urlStr.append( nodeRef.getId());
urlStr.append("\r\n"); urlStr.append("\r\n");
// Should this be the URL instead
// http://markr:8080/share/page/site/wibble/documentlibrary#filter=path%7C%2Ffolder%2520A%2FFolderB&page=1
// Create the in memory pseudo file for the URL link // Create the in memory pseudo file for the URL link
if(logger.isDebugEnabled()) if(logger.isDebugEnabled())
{ {
logger.debug("generateShareURLShortcut url as string:" + urlStr); logger.debug("generateShareURLShortcut url as string:" + urlStr);
} }
//
byte[] urlData = urlStr.toString().getBytes(); byte[] urlData = urlStr.toString().getBytes();
//
MemoryPseudoFile urlFile = new MemoryPseudoFile( context.getShareURLFileName(), urlData); MemoryPseudoFile urlFile = new MemoryPseudoFile( context.getShareURLFileName(), urlData);
return urlFile; return urlFile;
// }
} }
// catch (Throwable t)
// {
// logger.error("unexpected exception ", t);
// return null;
// }
} }
return null; return null;

View File

@@ -37,7 +37,7 @@ import org.apache.commons.logging.LogFactory;
* *
* @author gkspencer * @author gkspencer
*/ */
public class CacheLookupSearchContext extends ContentSearchContext { public class CacheLookupSearchContext extends DotDotContentSearchContext {
// Debug logging // Debug logging
@@ -47,11 +47,6 @@ public class CacheLookupSearchContext extends ContentSearchContext {
private FileStateCache m_stateCache; private FileStateCache m_stateCache;
// File information for the '.' and '..' pseduo entries, returned during a wildcard search
private FileInfo m_dotInfo;
private FileInfo m_dotDotInfo;
/** /**
* Class constructor * Class constructor
* *
@@ -125,76 +120,6 @@ public class CacheLookupSearchContext extends ContentSearchContext {
return true; return true;
} }
/**
* Check if the '.' and '..' pseudo file entries are available
*
* @return boolean
*/
public boolean hasDotFiles() {
return (m_dotInfo != null && m_dotDotInfo != null) ? true : false;
}
/**
* Return the '.' pseudo file entry details
*
* @param finfo FileInfo
* @return boolean
*/
public boolean getDotInfo(FileInfo finfo) {
// Check if the '.' file information is valid
if ( m_dotInfo != null) {
finfo.copyFrom( m_dotInfo);
return true;
}
// File information not valid
return false;
}
/**
* Return the '..' pseudo file entry details
*
* @param finfo FileInfo
* @return boolean
*/
public boolean getDotDotInfo(FileInfo finfo) {
// Check if the '..' file information is valid
if ( m_dotDotInfo != null) {
finfo.copyFrom( m_dotDotInfo);
return true;
}
// File information not valid
return false;
}
/**
* Set the '.' pseudo file entry details
*
* @param finfo FileInfo
*/
protected void setDotInfo(FileInfo finfo) {
m_dotInfo = finfo;
if ( m_dotInfo != null)
m_dotInfo.setFileName( ".");
}
/**
* Set the '..' pseudo file entry details
*
* @param finfo FileInfo
*/
protected void setDotDotInfo(FileInfo finfo) {
m_dotDotInfo = finfo;
if ( m_dotDotInfo != null)
m_dotDotInfo.setFileName( "..");
}
/** /**
* Return the search as a string * Return the search as a string
@@ -217,10 +142,11 @@ public class CacheLookupSearchContext extends ContentSearchContext {
sb.append(",cache="); sb.append(",cache=");
sb.append(m_stateCache); sb.append(m_stateCache);
if ( m_dotInfo != null) // if ( super.getDotInfo(finfo)
sb.append(",Dot"); // != null)
if ( m_dotDotInfo != null) // sb.append(",Dot");
sb.append(",DotDot"); // if ( m_dotDotInfo != null)
// sb.append(",DotDot");
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();

View File

@@ -199,6 +199,10 @@ public class CifsHelper
// retrieve required properties and create new JLAN file info // retrieve required properties and create new JLAN file info
ContentFileInfo fileInfo = new ContentFileInfo(nodeRef); ContentFileInfo fileInfo = new ContentFileInfo(nodeRef);
// Set the file id from the node's DBID
long id = DefaultTypeConverter.INSTANCE.convert(Long.class, nodeService.getProperty(nodeRef, ContentModel.PROP_NODE_DBID));
fileInfo.setFileId((int) (id & 0xFFFFFFFFL));
// unset all attribute flags // unset all attribute flags
int fileAttributes = 0; int fileAttributes = 0;
fileInfo.setFileAttributes(fileAttributes); fileInfo.setFileAttributes(fileAttributes);
@@ -226,7 +230,9 @@ public class CifsHelper
// Set the allocation size by rounding up the size to a 512 byte block boundary // Set the allocation size by rounding up the size to a 512 byte block boundary
if ( size > 0) if ( size > 0)
{
fileInfo.setAllocationSize((size + 512L) & 0xFFFFFFFFFFFFFE00L); fileInfo.setAllocationSize((size + 512L) & 0xFFFFFFFFFFFFFE00L);
}
// Check the lock status of the file // Check the lock status of the file
@@ -252,7 +258,9 @@ public class CifsHelper
// Check if it is a link node // Check if it is a link node
if ( fileFolderInfo.isLink()) if ( fileFolderInfo.isLink())
{
fileInfo.setLinkNodeRef( fileFolderInfo.getLinkNodeRef()); fileInfo.setLinkNodeRef( fileFolderInfo.getLinkNodeRef());
}
} }
// created // created

View File

@@ -209,9 +209,50 @@ public class CommandExecutorImpl implements CommandExecutor
OpenFileCommand o = (OpenFileCommand)command; OpenFileCommand o = (OpenFileCommand)command;
int openAction = FileAction.OpenIfExists; int openAction = FileAction.OpenIfExists;
// TODO Open Action FileAction.NTOverwrite o.truncate OpenFileMode mode = o.getMode();
// TODO ATTRIBUTES ONLY and DELETE ONLY int jlanAccessMode = 0;
FileOpenParams params = new FileOpenParams(o.getPath(), openAction, o.getMode() == OpenFileMode.WRITE ? AccessMode.ReadWrite : AccessMode.ReadOnly, FileAttribute.NTNormal, 0); switch (mode)
{
case ATTRIBUTES_ONLY:
jlanAccessMode = AccessMode.ReadWrite;
break;
case READ_ONLY:
jlanAccessMode = AccessMode.ReadOnly;
break;
case READ_WRITE:
jlanAccessMode = AccessMode.ReadWrite;
break;
case DELETE:
// Don't care file is being deleted
jlanAccessMode = AccessMode.ReadOnly;
break;
case WRITE_ONLY:
jlanAccessMode = AccessMode.WriteOnly;
break;
}
FileOpenParams params = new FileOpenParams(o.getPath(), openAction, jlanAccessMode, FileAttribute.NTNormal, 0);
if(logger.isDebugEnabled())
{
int sharedAccess = params.getSharedAccess();
String strSharedAccess = SharingMode.getSharingModeAsString(sharedAccess);
logger.debug("openFile:" + o.getPath()
+ ", isDirectory: " + params.isDirectory()
+ ", isStream: " + params.isStream()
+ ", readOnlyAccess: " + params.isReadOnlyAccess()
+ ", readWriteAccess: " + params.isReadWriteAccess()
+ ", writeOnlyAccess:" +params.isWriteOnlyAccess()
+ ", attributesOnlyAccess:" +params.isAttributesOnlyAccess()
+ ", sequentialAccessOnly:" + params.isSequentialAccessOnly()
+ ", requestBatchOpLock:" +params.requestBatchOpLock()
+ ", requestExclusiveOpLock:" +params.requestExclusiveOpLock()
+ ", isDeleteOnClose:" +params.isDeleteOnClose()
+ ", allocationSize:" + params.getAllocationSize()
+ ", sharedAccess: " + strSharedAccess
);
}
return diskInterface.openFile(sess, tree, params); return diskInterface.openFile(sess, tree, params);
} }

View File

@@ -686,9 +686,10 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
logger.debug("getFileInformation found nodeRef for nodeRef :"+ nodeRef + ", path: " + path); logger.debug("getFileInformation found nodeRef for nodeRef :"+ nodeRef + ", path: " + path);
} }
// Set the file id from the node's DBID // Moved to CIFS Helper
long id = DefaultTypeConverter.INSTANCE.convert(Long.class, nodeService.getProperty(nodeRef, ContentModel.PROP_NODE_DBID)); // // Set the file id from the node's DBID
finfo.setFileId((int) (id & 0xFFFFFFFFL)); // long id = DefaultTypeConverter.INSTANCE.convert(Long.class, nodeService.getProperty(nodeRef, ContentModel.PROP_NODE_DBID));
// finfo.setFileId((int) (id & 0xFFFFFFFFL));
} }
// Return the file information or null if the node ref does not exist // Return the file information or null if the node ref does not exist
@@ -805,7 +806,11 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
pseudoList = ctx.getPseudoFileOverlay().searchPseudoFiles(dirNodeRef, searchFileSpec); pseudoList = ctx.getPseudoFileOverlay().searchPseudoFiles(dirNodeRef, searchFileSpec);
} }
SearchContext searchCtx = new ContentSearchContext(getCifsHelper(), results, searchFileSpec, pseudoList, paths[0]); DotDotContentSearchContext searchCtx = new DotDotContentSearchContext(getCifsHelper(), results, searchFileSpec, pseudoList, paths[0]);
// Need to set dot and dotdot
//searchCtx.setDotInfo(finfo);
//searchCtx.setDotDotInfo(finfo);
// Debug // Debug
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@@ -975,6 +980,10 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
if ( params.hasAccessMode(AccessMode.NTRead) && if ( params.hasAccessMode(AccessMode.NTRead) &&
permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED)
{ {
if(logger.isDebugEnabled())
{
logger.debug("about to throw an no read access denied exception path:" +params.getFullPath());
}
throw new AccessDeniedException("No read access to " + params.getFullPath()); throw new AccessDeniedException("No read access to " + params.getFullPath());
} }
@@ -982,6 +991,11 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
if ( params.hasAccessMode(AccessMode.NTWrite) && if ( params.hasAccessMode(AccessMode.NTWrite) &&
permissionService.hasPermission(nodeRef, PermissionService.WRITE) == AccessStatus.DENIED) permissionService.hasPermission(nodeRef, PermissionService.WRITE) == AccessStatus.DENIED)
{ {
if(logger.isDebugEnabled())
{
logger.debug("about to throw an no write access denied exception path:" +params.getFullPath());
}
throw new AccessDeniedException("No write access to " + params.getFullPath()); throw new AccessDeniedException("No write access to " + params.getFullPath());
} }
@@ -1000,6 +1014,8 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
if ( linkRef == null) if ( linkRef == null)
{ {
// A normal node, not a link node
// TODO MER REWRITE HERE // TODO MER REWRITE HERE
FileInfo fileInfo = cifsHelper.getFileInformation(nodeRef, "", false, false); FileInfo fileInfo = cifsHelper.getFileInformation(nodeRef, "", false, false);
@@ -1011,6 +1027,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
} }
else else
{ {
// A normal file
if(params.isReadOnlyAccess()) if(params.isReadOnlyAccess())
{ {
logger.debug("open file for read only"); logger.debug("open file for read only");
@@ -1042,8 +1059,26 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
netFile = new TempNetworkFile(file, name); netFile = new TempNetworkFile(file, name);
// Always allow write access to a newly created file // Generate a file id for the file
netFile.setGrantedAccess(NetworkFile.READWRITE);
if ( netFile != null)
{
long id = DefaultTypeConverter.INSTANCE.convert(Long.class, nodeService.getProperty(nodeRef, ContentModel.PROP_NODE_DBID));
netFile.setFileId((int) (id & 0xFFFFFFFFL));
}
if (logger.isDebugEnabled())
{
logger.debug("Created file: path=" + name + " node=" + nodeRef + " network file=" + netFile);
}
}
else
{
// Write only or AttributesOnly
logger.debug("open file write or attributes only");
File file = TempFileProvider.createTempFile("cifs", ".bin");
netFile = new TempNetworkFile(file, name);
// Generate a file id for the file // Generate a file id for the file
@@ -1058,7 +1093,21 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
logger.debug("Created file: path=" + name + " node=" + nodeRef + " network file=" + netFile); logger.debug("Created file: path=" + name + " node=" + nodeRef + " network file=" + netFile);
} }
} }
}
if ( params.isReadOnlyAccess())
{
netFile.setGrantedAccess( NetworkFile.READONLY);
}
else if ( params.isWriteOnlyAccess())
{
netFile.setGrantedAccess( NetworkFile.WRITEONLY);
}
else
{
netFile.setGrantedAccess( NetworkFile.READWRITE);
}
} // end of a normal file
} }
else else
{ {
@@ -2672,7 +2721,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
// Always allow write access to a newly created file // Always allow write access to a newly created file
netFile.setGrantedAccess(NetworkFile.READWRITE); netFile.setGrantedAccess(NetworkFile.READWRITE);
netFile.setAllowedAccess(NetworkFile.READWRITE);
// Truncate the file so that the content stream is created // Truncate the file so that the content stream is created
//netFile.truncateFile( 0L); //netFile.truncateFile( 0L);
@@ -2773,11 +2822,22 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
{ {
logger.debug("closeFile has delete on close set"); logger.debug("closeFile has delete on close set");
} }
try
NodeRef target = getCifsHelper().getNodeRef(rootNode, path);
if(target!=null)
{ {
nodeService.deleteNode(target); NodeRef target = getCifsHelper().getNodeRef(rootNode, path);
if(target!=null)
{
nodeService.deleteNode(target);
}
}
catch (org.alfresco.repo.security.permissions.AccessDeniedException ex)
{
if ( logger.isDebugEnabled())
{
logger.debug("Delete file from close file- access denied", ex);
}
// Convert to a filesystem access denied status
throw new AccessDeniedException("Unable to delete " + path);
} }
// Still need to close the open file handle. // Still need to close the open file handle.

View File

@@ -0,0 +1,169 @@
/*
* Copyright (C) 2006-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.filesys.repo;
import java.util.List;
import org.alfresco.jlan.server.filesys.FileInfo;
import org.alfresco.jlan.server.filesys.cache.FileState;
import org.alfresco.jlan.server.filesys.cache.FileStateCache;
import org.alfresco.jlan.server.filesys.pseudo.PseudoFileList;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Cache Lookup Search Context Class
*
* ContentSearchContext with DotDot methods.
*
*/
public class DotDotContentSearchContext extends ContentSearchContext {
// Debug logging
private static final Log logger = LogFactory.getLog(DotDotContentSearchContext.class);
// File information for the '.' and '..' pseduo entries, returned during a wildcard search
private FileInfo m_dotInfo;
private FileInfo m_dotDotInfo;
/**
* Class constructor
*
* @param cifsHelper Filesystem helper class
* @param results List of file/folder nodes that match the search pattern
* @param searchStr Search path
* @param pseudoList List of pseudo files to be blended into the returned list of files
* @param relPath Relative path being searched
* @param stateCache File state cache
*/
protected DotDotContentSearchContext(
CifsHelper cifsHelper,
List<NodeRef> results,
String searchStr,
PseudoFileList pseudoList,
String relPath)
{
super(cifsHelper, results, searchStr, pseudoList, relPath);
super.setSearchString(searchStr);
}
/**
* Check if the '.' and '..' pseudo file entries are available
*
* @return boolean
*/
public boolean hasDotFiles() {
return (m_dotInfo != null && m_dotDotInfo != null) ? true : false;
}
/**
* Return the '.' pseudo file entry details
*
* @param finfo FileInfo
* @return boolean
*/
public boolean getDotInfo(FileInfo finfo) {
// Check if the '.' file information is valid
if ( m_dotInfo != null) {
finfo.copyFrom( m_dotInfo);
return true;
}
// File information not valid
return false;
}
/**
* Return the '..' pseudo file entry details
*
* @param finfo FileInfo
* @return boolean
*/
public boolean getDotDotInfo(FileInfo finfo) {
// Check if the '..' file information is valid
if ( m_dotDotInfo != null) {
finfo.copyFrom( m_dotDotInfo);
return true;
}
// File information not valid
return false;
}
/**
* Set the '.' pseudo file entry details
*
* @param finfo FileInfo
*/
protected void setDotInfo(FileInfo finfo) {
m_dotInfo = finfo;
if ( m_dotInfo != null)
m_dotInfo.setFileName( ".");
}
/**
* Set the '..' pseudo file entry details
*
* @param finfo FileInfo
*/
protected void setDotDotInfo(FileInfo finfo) {
m_dotDotInfo = finfo;
if ( m_dotDotInfo != null)
m_dotDotInfo.setFileName( "..");
}
/**
* Return the search as a string
*
* @return String
*/
public String toString()
{
StringBuilder sb = new StringBuilder(60);
sb.append("[DotDotContextSearch searchStr=");
sb.append(getSearchString());
sb.append(", resultCount=");
sb.append(getResultsSize());
sb.append(", pseudoList=");
if ( getPseudoListSize() != 0)
sb.append( getPseudoListSize());
else
sb.append("NULL");
if ( m_dotInfo != null)
sb.append(",Dot");
if ( m_dotDotInfo != null)
sb.append(",DotDot");
sb.append("]");
return sb.toString();
}
}

View File

@@ -272,6 +272,13 @@ public class LegacyFileStateDriver implements ExtendedDiskInterface
FileStateCache cache = tctx.getStateCache(); FileStateCache cache = tctx.getStateCache();
FileState fstate = cache.findFileState( param.getFullName(), true); FileState fstate = cache.findFileState( param.getFullName(), true);
// MER Experiment Need to reset shared access
if(fstate.getOpenCount() ==0 )
{
logger.debug("reset shared access to READWRITEDELETE");
fstate.setSharedAccess( SharingMode.READWRITE + SharingMode.DELETE);
}
if(fstate != null && param.getAccessToken() != null) if(fstate != null && param.getAccessToken() != null)
{ {
FileAccessToken token = param.getAccessToken(); FileAccessToken token = param.getAccessToken();

View File

@@ -178,28 +178,8 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
{ {
if(logger.isDebugEnabled()) if(logger.isDebugEnabled())
{ {
int sharedAccess = params.getSharedAccess();
int sharedAccess = params.getSharedAccess(); String strSharedAccess = SharingMode.getSharingModeAsString(sharedAccess);
String strSharedAccess = "none";
switch(sharedAccess)
{
case SharingMode.NOSHARING:
strSharedAccess = "nosharing";
break;
case SharingMode.READ:
strSharedAccess = "read";
break;
case SharingMode.WRITE:
strSharedAccess = "write";
break;
case SharingMode.READWRITE:
strSharedAccess = "read-write";
break;
case SharingMode.DELETE:
strSharedAccess = "delete";
break;
}
logger.debug("createFile:" + params.getPath() logger.debug("createFile:" + params.getPath()
+ ", isDirectory: " + params.isDirectory() + ", isDirectory: " + params.isDirectory()
@@ -219,8 +199,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
ContentContext tctx = (ContentContext) tree.getContext(); ContentContext tctx = (ContentContext) tree.getContext();
NodeRef rootNode = tctx.getRootNode(); NodeRef rootNode = tctx.getRootNode();
String[] paths = FileName.splitPath(params.getPath()); String[] paths = FileName.splitPath(params.getPath());
String folder = paths[0]; String folder = paths[0];
String file = paths[1]; String file = paths[1];
@@ -235,7 +213,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
if(ret != null && ret instanceof NetworkFile) if(ret != null && ret instanceof NetworkFile)
{ {
return (NetworkFile)ret; return (NetworkFile)ret;
} }
else else
@@ -309,26 +286,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
if(logger.isDebugEnabled()) if(logger.isDebugEnabled())
{ {
int sharedAccess = param.getSharedAccess(); int sharedAccess = param.getSharedAccess();
String strSharedAccess = "none"; String strSharedAccess = SharingMode.getSharingModeAsString(sharedAccess);
switch(sharedAccess)
{
case SharingMode.NOSHARING:
strSharedAccess = "nosharing";
break;
case SharingMode.READ:
strSharedAccess = "read";
break;
case SharingMode.WRITE:
strSharedAccess = "write";
break;
case SharingMode.READWRITE:
strSharedAccess = "read-write";
break;
case SharingMode.DELETE:
strSharedAccess = "delete";
break;
}
logger.debug("openFile:" + path logger.debug("openFile:" + path
+ ", isDirectory: " + param.isDirectory() + ", isDirectory: " + param.isDirectory()
@@ -358,32 +316,50 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
EvaluatorContext ctx = getEvaluatorContext(driverState, folder); EvaluatorContext ctx = getEvaluatorContext(driverState, folder);
// Todo what about attributes only and writeOnly ? // Todo what about attributes only ?
OpenFileMode writeAccess = param.isReadWriteAccess() ? OpenFileMode.WRITE : OpenFileMode.READ ;
if(param.isDeleteOnClose()) OpenFileMode openMode = OpenFileMode.READ_WRITE;
if(param.isAttributesOnlyAccess())
{
openMode = OpenFileMode.ATTRIBUTES_ONLY;
}
else if (param.isReadWriteAccess())
{
openMode = OpenFileMode.READ_WRITE;
}
else if (param.isWriteOnlyAccess())
{
openMode = OpenFileMode.WRITE_ONLY;
}
else if (param.isReadOnlyAccess())
{
openMode = OpenFileMode.READ_ONLY;
}
else if(param.isDeleteOnClose())
{ {
if(logger.isDebugEnabled()) if(logger.isDebugEnabled())
{ {
logger.debug("open file has delete on close"); logger.debug("open file has delete on close");
} }
writeAccess = OpenFileMode.DELETE; openMode = OpenFileMode.DELETE;
} }
boolean truncate = param.isOverwrite(); boolean truncate = param.isOverwrite();
Operation o = new OpenFileOperation(file, writeAccess, truncate, rootNode, path); Operation o = new OpenFileOperation(file, openMode, truncate, rootNode, path);
Command c = ruleEvaluator.evaluate(ctx, o); Command c = ruleEvaluator.evaluate(ctx, o);
Object ret = commandExecutor.execute(sess, tree, c); Object ret = commandExecutor.execute(sess, tree, c);
if(ret != null && ret instanceof NetworkFile) if(ret != null && ret instanceof NetworkFile)
{ {
NetworkFile x = (NetworkFile)ret;
if(logger.isDebugEnabled()) if(logger.isDebugEnabled())
{ {
logger.debug("returning open file: for path:" + path +", ret:" + ret); logger.debug("returning open file: for path:" + path +", ret:" + ret);
} }
return (NetworkFile)ret; return x;
} }
else else
{ {

View File

@@ -2,8 +2,9 @@ package org.alfresco.filesys.repo;
public enum OpenFileMode public enum OpenFileMode
{ {
READ, READ_ONLY,
WRITE, WRITE_ONLY,
READ_WRITE,
DELETE, DELETE,
ATTRIBUTES_ONLY ATTRIBUTES_ONLY
} }

View File

@@ -268,7 +268,7 @@ class ScenarioOpenFileInstance implements ScenarioInstance
commands.add(new CloseFileCommand(c.getName(), file, c.getRootNodeRef(), c.getPath())); commands.add(new CloseFileCommand(c.getName(), file, c.getRootNodeRef(), c.getPath()));
postErrorCommands.add(new RemoveNoContentFileOnError(c.getName(), c.getRootNodeRef(), c.getPath())); //postErrorCommands.add(new RemoveNoContentFileOnError(c.getName(), c.getRootNodeRef(), c.getPath()));
if(c.isDeleteOnClose()) if(c.isDeleteOnClose())
{ {
@@ -306,7 +306,7 @@ class ScenarioOpenFileInstance implements ScenarioInstance
if(name != null && name.equalsIgnoreCase(o.getName())) if(name != null && name.equalsIgnoreCase(o.getName()))
{ {
if(o.getMode() == OpenFileMode.WRITE) if(o.getMode() == OpenFileMode.READ_WRITE)
{ {
// This is an open of a read write access // This is an open of a read write access
if(openReadWriteCount == 0) if(openReadWriteCount == 0)

View File

@@ -90,7 +90,7 @@ public class ScenarioSimpleNonBufferedInstance implements ScenarioInstance
commands.add(new CloseFileCommand(c.getName(), file, c.getRootNodeRef(), c.getPath())); commands.add(new CloseFileCommand(c.getName(), file, c.getRootNodeRef(), c.getPath()));
postErrorCommands.add(new RemoveNoContentFileOnError(c.getName(), c.getRootNodeRef(), c.getPath())); // postErrorCommands.add(new RemoveNoContentFileOnError(c.getName(), c.getRootNodeRef(), c.getPath()));
if(c.isDeleteOnClose()) if(c.isDeleteOnClose())
{ {

View File

@@ -31,7 +31,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
public class OpenFileCommand implements Command public class OpenFileCommand implements Command
{ {
private String name; private String name;
private OpenFileMode mode = OpenFileMode.READ; private OpenFileMode mode = OpenFileMode.READ_ONLY;
private boolean truncate = false; private boolean truncate = false;
private String path; private String path;
private NodeRef rootNode; private NodeRef rootNode;

View File

@@ -37,6 +37,8 @@ public class RemoveNoContentFileOnError implements Command
public RemoveNoContentFileOnError(String name, NodeRef rootNode, String path) public RemoveNoContentFileOnError(String name, NodeRef rootNode, String path)
{ {
this.name = name; this.name = name;
this.rootNode = rootNode;
this.path = path;
} }
public String getName() public String getName()