当前位置: 首页>>代码示例>>Java>>正文


Java FileOpenParams类代码示例

本文整理汇总了Java中org.alfresco.jlan.server.filesys.FileOpenParams的典型用法代码示例。如果您正苦于以下问题:Java FileOpenParams类的具体用法?Java FileOpenParams怎么用?Java FileOpenParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileOpenParams类属于org.alfresco.jlan.server.filesys包,在下文中一共展示了FileOpenParams类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDirectory

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
@Override
public void createDirectory(SrvSession sess, TreeConnection tree,
        FileOpenParams params) throws IOException
{
	try
	{
        FileFilterMode.setClient(ClientHelper.getClient(sess));
        try
        {
            diskInterface.createDirectory(sess, tree, params);
        }
        finally
        {
            FileFilterMode.clearClient();
        }
	}
    catch(org.alfresco.repo.security.permissions.AccessDeniedException ade)
    {
	    throw new AccessDeniedException("Unable to create directory " +  params.getPath(), ade);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:NonTransactionalRuleContentDiskDriver.java

示例2: openFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
@Override
public NetworkFile openFile(final SrvSession sess, final TreeConnection tree, final FileOpenParams params) throws IOException {
    if (params != null) {
        final String path = params.getPath();
        final PseudoFile pseudoFile = findPseudoFile(path);
        if (pseudoFile != null) {
            return pseudoFile.getFile(path);
        }
    }

    return super.openFile(sess, tree, params);
}
 
开发者ID:raqet,项目名称:acquisition-server,代码行数:13,代码来源:RaqetDiskDriver.java

示例3: createFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:67,代码来源:NonTransactionalRuleContentDiskDriver.java

示例4: createDirectory

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
public void createDirectory(SrvSession sess, TreeConnection tree,
FileOpenParams params);
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:3,代码来源:ContentDiskCallback.java

示例5: createFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
public void createFile(SrvSession sess, TreeConnection tree,
FileOpenParams params, NetworkFile newFile);
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:3,代码来源:ContentDiskCallback.java

示例6: createDirectory

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
@Override
public void createDirectory(SrvSession sess, TreeConnection tree,
        FileOpenParams params) throws IOException
{
    diskInterface.createDirectory(sess, tree, params);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:7,代码来源:LegacyFileStateDriver.java

示例7: createFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
@Override
public NetworkFile createFile(SrvSession sess, TreeConnection tree,
        FileOpenParams params) throws IOException
{
    return diskInterface.createFile(sess, tree, params);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:7,代码来源:BufferedContentDiskDriver.java

示例8: openFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
@Override
public NetworkFile openFile(SrvSession sess, TreeConnection tree,
        FileOpenParams params) throws IOException
{
    return diskInterface.openFile(sess, tree, params);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:7,代码来源:BufferedContentDiskDriver.java

示例9: testDeleteFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
/**
 * Unit test of delete file
 */
public void testDeleteFile() throws Exception
{
    logger.debug("testDeleteFile");
    
    ServerConfiguration scfg = new ServerConfiguration("testServer");
    TestServer testServer = new TestServer("testServer", scfg);
    SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
    DiskSharedDevice share = getDiskSharedDevice();

    TreeConnection testConnection = testServer.getTreeConnection(share);
    
    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();

    /**
     * Step 1 : Create a new file in read/write mode and add some content.
     */
    int openAction = FileAction.CreateNotExist;
    String FILE_PATH="\\testDeleteFile.new";
      
    FileOpenParams params = new FileOpenParams(FILE_PATH, openAction, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
            
    final NetworkFile file = driver.createFile(testSession, testConnection, params);
    assertNotNull("file is null", file);
    assertFalse("file is read only, should be read-write", file.isReadOnly());
        
    RetryingTransactionCallback<Void> writeStuffCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable
        {
            byte[] stuff = "Hello World".getBytes();
            file.writeFile(stuff, stuff.length, 0, 0);
            file.close();  // needed to actually flush content to node
            return null;
        }
    };
    tran.doInTransaction(writeStuffCB);
             
    /**
      * Step 1: Delete file by path
      */
    driver.deleteFile(testSession, testConnection, FILE_PATH);
    
    /**
     * Step 2: Negative test - Delete file again
     */
    try
    {
        driver.deleteFile(testSession, testConnection, FILE_PATH);
        fail("delete a non existent file");
    }
    catch (IOException fe)
    {
            // expect to go here
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:60,代码来源:ContentDiskDriverTest.java

示例10: testFileExists

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
/**
 * Unit test of file exists
 */
public void testFileExists() throws Exception
{
    logger.debug("testFileExists");
    ServerConfiguration scfg = new ServerConfiguration("testServer");
    TestServer testServer = new TestServer("testServer", scfg);
    final SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
    DiskSharedDevice share = getDiskSharedDevice();
    final TreeConnection testConnection = testServer.getTreeConnection(share);
    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
    
    final String FILE_PATH= TEST_ROOT_DOS_PATH + "\\testFileExists.new";
    
    class TestContext
    {
    };
    
    final TestContext testContext = new TestContext();
   
    /**
     * Step 1 : Call FileExists for a directory which does not exist
     */
    logger.debug("Step 1, negative test dir does not exist");
    int status = driver.fileExists(testSession, testConnection, TEST_ROOT_DOS_PATH);
    assertEquals(status, 0);
  
    /**
     * Step 2 : Call FileExists for a file which does not exist
     */
    logger.debug("Step 2, negative test file does not exist");
    status = driver.fileExists(testSession, testConnection, FILE_PATH);
    assertEquals(status, 0);
    
    /**
     * Step 3: Create a new file in read/write mode and add some content.
     */
    int openAction = FileAction.CreateNotExist;

    FileOpenParams params = new FileOpenParams(FILE_PATH, openAction, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
    FileOpenParams dirParams = new FileOpenParams(TEST_ROOT_DOS_PATH, 0, AccessMode.ReadOnly, FileAttribute.NTDirectory, 0);
 
    driver.createDirectory(testSession, testConnection, dirParams);        
    final NetworkFile file = driver.createFile(testSession, testConnection, params);
    assertNotNull("file is null", file);
    assertFalse("file is read only, should be read-write", file.isReadOnly());
    
    RetryingTransactionCallback<Void> createFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable
        {
            byte[] stuff = "Hello World".getBytes();
            file.writeFile(stuff, stuff.length, 0, 0);
            driver.closeFile(testSession, testConnection, file);
        
            return null;
        }
    };
    tran.doInTransaction(createFileCB, false, true);
     
    status = driver.fileExists(testSession, testConnection, FILE_PATH);
    assertEquals(status, 1);
     
    /**
      * Step 4 : Delete the node - check status goes back to 0
      */
    logger.debug("Step 4, successfully delete node");
    driver.deleteFile(testSession, testConnection, FILE_PATH);
    
    status = driver.fileExists(testSession, testConnection, FILE_PATH);
    assertEquals(status, 0);  
   
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:76,代码来源:ContentDiskDriverTest.java

示例11: testScenarioRenameVersionableFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
/**
 * Unit test of rename versionable file
 */
public void testScenarioRenameVersionableFile() throws Exception
{  
    logger.debug("testScenarioRenameVersionableFile");
    
    ServerConfiguration scfg = new ServerConfiguration("testServer");
    TestServer testServer = new TestServer("testServer", scfg);
    SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
    DiskSharedDevice share = getDiskSharedDevice();
    final TreeConnection testConnection = testServer.getTreeConnection(share);
    
    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();

    final String FILE_PATH1=TEST_ROOT_DOS_PATH + "\\SourceFile1.new";
    final String FILE_PATH2=TEST_ROOT_DOS_PATH + "\\SourceFile2.new";
    
    class TestContext
    {
    };
    
    final TestContext testContext = new TestContext();
   
    FileOpenParams dirParams = new FileOpenParams(TEST_ROOT_DOS_PATH, 0, AccessMode.ReadOnly, FileAttribute.NTDirectory, 0);
    driver.createDirectory(testSession, testConnection, dirParams);

    FileOpenParams params1 = new FileOpenParams(FILE_PATH1, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
    NetworkFile file1 = driver.createFile(testSession, testConnection, params1);
    
    /**
     * Make Node 1 versionable
     */
    final String LAST_NAME= "Bloggs";
     
    RetryingTransactionCallback<Void> makeVersionableCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable
        {
            NodeRef file1NodeRef = getNodeForPath(testConnection, FILE_PATH1);
            nodeService.addAspect(file1NodeRef, ContentModel.ASPECT_VERSIONABLE, null);
            
            ContentWriter contentWriter2 = contentService.getWriter(file1NodeRef, ContentModel.PROP_CONTENT, true);
            contentWriter2.putContent("test rename versionable");
            
            nodeService.setProperty(file1NodeRef, ContentModel.PROP_LASTNAME, LAST_NAME);
            nodeService.setProperty(file1NodeRef, TransferModel.PROP_ENDPOINT_PROTOCOL, "http");

            return null;
        }
    };
    tran.doInTransaction(makeVersionableCB, false, true);
  
    /**
     * Step 1: Successfully rename a versionable file - check the name, props and content.
     * TODO Check primary assoc, peer assocs, child assocs, modified date, created date, nodeid, permissions.
     */
    driver.renameFile(testSession, testConnection, FILE_PATH1, FILE_PATH2);
    
    RetryingTransactionCallback<Void> validateVersionableCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable
        {
            NodeRef file2NodeRef = getNodeForPath(testConnection, FILE_PATH2);
            assertNotNull("file2 node ref is null", file2NodeRef);
            //assertEquals(nodeService.getProperty(file2NodeRef, ContentModel.PROP_LASTNAME), LAST_NAME);
            assertTrue("does not have versionable aspect", nodeService.hasAspect(file2NodeRef, ContentModel.ASPECT_VERSIONABLE));   
            assertTrue("sample property is null", nodeService.getProperty(file2NodeRef, TransferModel.PROP_ENDPOINT_PROTOCOL) != null);     
            
            return null;
        }
    };
    tran.doInTransaction(validateVersionableCB, false, true);

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:78,代码来源:ContentDiskDriverTest.java

示例12: openFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
/**
 * Open a file or folder - obsolete implementation.
 * 
 * @param session SrvSession
 * @param tree TreeConnection
 * @param params FileOpenParams
 * @return NetworkFile
 * @exception IOException
 */
public NetworkFile openFile(SrvSession session, TreeConnection tree, FileOpenParams params) throws IOException
{
    // obsolete
    logger.error("Obsolete method called");
    throw new AlfrescoRuntimeException("obsolete method called");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:ContentDiskDriver2.java

示例13: createFile

import org.alfresco.jlan.server.filesys.FileOpenParams; //导入依赖的package包/类
/**
 * Create a new file on the file system.
 * 
 * @param sess Server session
 * @param tree Tree connection
 * @param params File create parameters
 * @return NetworkFile
 * @exception java.io.IOException If an error occurs.
 */
public NetworkFile createFile(SrvSession sess, final TreeConnection tree, final FileOpenParams params) throws IOException
{
    // Obsolete
    logger.error("Obsolete method called");
    throw new AlfrescoRuntimeException("obsolete method called");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:ContentDiskDriver2.java


注:本文中的org.alfresco.jlan.server.filesys.FileOpenParams类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。