@Override public NetworkFile openFile(SrvSession sess, TreeConnection tree, FileOpenParams param) throws IOException { String path = param.getPath(); boolean truncate = param.isOverwrite(); if (logger.isDebugEnabled()) { int sharedAccess = param.getSharedAccess(); String strSharedAccess = SharingMode.getSharingModeAsString(sharedAccess); logger.debug( "openFile:" + path + ", isDirectory: " + param.isDirectory() + ", isStream: " + param.isStream() + ", readOnlyAccess: " + param.isReadOnlyAccess() + ", readWriteAccess: " + param.isReadWriteAccess() + ", writeOnlyAccess:" + param.isWriteOnlyAccess() + ", attributesOnlyAccess:" + param.isAttributesOnlyAccess() + ", sequentialAccessOnly:" + param.isSequentialAccessOnly() + ", writeThrough:" + param.isWriteThrough() + ", truncate:" + truncate + ", requestBatchOpLock:" + param.requestBatchOpLock() + ", requestExclusiveOpLock:" + param.requestExclusiveOpLock() + ", isDeleteOnClose:" + param.isDeleteOnClose() + ", allocationSize:" + param.getAllocationSize() + ", sharedAccess: " + strSharedAccess + ", openAction: " + param.getOpenAction() + param); } ContentContext tctx = (ContentContext) tree.getContext(); NodeRef rootNode = tctx.getRootNode(); DriverState driverState = getDriverState(sess); String[] paths = FileName.splitPath(path); String folder = paths[0]; String file = paths[1]; EvaluatorContext ctx = getEvaluatorContext(driverState, folder); OpenFileMode openMode = OpenFileMode.READ_ONLY; 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()) { logger.debug("open file has delete on close"); } openMode = OpenFileMode.DELETE; } try { Operation o = new OpenFileOperation(file, openMode, truncate, rootNode, path); Command c = ruleEvaluator.evaluate(ctx, o); Object ret = commandExecutor.execute(sess, tree, c); if (ret != null && ret instanceof NetworkFile) { NetworkFile x = (NetworkFile) ret; if (logger.isDebugEnabled()) { logger.debug("returning open file: for path:" + path + ", ret:" + ret); } return x; } else { // Error - contact broken logger.error( "contract broken - NetworkFile not returned. " + ret == null ? "Return value is null" : ret); return null; } } catch (org.alfresco.repo.security.permissions.AccessDeniedException ade) { throw new AccessDeniedException("Unable to open file " + param.getPath(), ade); } // return diskInterface.openFile(sess, tree, params); } // End of OpenFile
@Override public NetworkFile createFile(SrvSession sess, TreeConnection tree, FileOpenParams params) throws IOException { try { int attr = params.getAttributes(); if (logger.isDebugEnabled()) { int sharedAccess = params.getSharedAccess(); String strSharedAccess = SharingMode.getSharingModeAsString(sharedAccess); logger.debug( "createFile:" + params.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() + ", sharedAccess: " + strSharedAccess + ", allocationSize: " + params.getAllocationSize() + ", isHidden:" + FileAttribute.isHidden(attr) + ", isSystem:" + FileAttribute.isSystem(attr)); } long creationDateTime = params.getCreationDateTime(); if (creationDateTime != 0) { logger.debug("creationDateTime is set:" + new Date(creationDateTime)); } ContentContext tctx = (ContentContext) tree.getContext(); NodeRef rootNode = tctx.getRootNode(); String[] paths = FileName.splitPath(params.getPath()); String folder = paths[0]; String file = paths[1]; DriverState driverState = getDriverState(sess); EvaluatorContext ctx = getEvaluatorContext(driverState, folder); Operation o = new CreateFileOperation( file, rootNode, params.getPath(), params.getAllocationSize(), FileAttribute.isHidden(attr)); Command c = ruleEvaluator.evaluate(ctx, o); Object ret = commandExecutor.execute(sess, tree, c); if (ret != null && ret instanceof NetworkFile) { return (NetworkFile) ret; } else { // Error - contact broken logger.error( "contract broken - NetworkFile not returned. " + ret == null ? "Return value is null" : ret); return null; } } catch (org.alfresco.repo.security.permissions.AccessDeniedException ade) { throw new AccessDeniedException("Unable to create file " + params.getPath(), ade); } }