Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP on output stream #144

Closed
michael-conway opened this issue Aug 25, 2015 · 5 comments
Closed

PEP on output stream #144

michael-conway opened this issue Aug 25, 2015 · 5 comments

Comments

@michael-conway
Copy link
Collaborator

If you use the method, IRODSFileFactory.instanceIRODSFileOutputStream(file, DataObjInp.OpenFlags.WRITE_TRUNCATE), the acPostProcOnPut rule isn't fired.

via tony

@michael-conway
Copy link
Collaborator Author

seems to work here...

ref IRODSFileOutputStreamTest in jargon

core.re

acPostProcForPut {writeLine("serverLog","Post Proc! ---  File Path is "++$filePath);}

@Test
    public final void testIRODSFileOutputStreamOverwrite() throws Exception {
        String testFileName = "testIRODSFileOutputStreamOverwrite.txt";
        String string1 = "jfaijfjasidjfaisehfuaehfahfhudhfuashfuasfdhaisdfhaisdhfiaf";
        String string2 = "nvmzncvzmvnzx,mcv";
        String absPath = scratchFileUtils
                .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH);
        String localFilePath = FileGenerator
                .generateFileOfFixedLengthGivenName(absPath, testFileName, 8);

        new File(localFilePath);
        String targetIrodsCollection = testingPropertiesHelper
                .buildIRODSCollectionAbsolutePathFromTestProperties(
                        testingProperties, IRODS_TEST_SUBDIR_PATH);

        IRODSAccount irodsAccount = testingPropertiesHelper
                .buildIRODSAccountFromTestProperties(testingProperties);

        IRODSAccessObjectFactory accessObjectFactory = irodsFileSystem
                .getIRODSAccessObjectFactory();
        IRODSFileFactory irodsFileFactory = accessObjectFactory
                .getIRODSFileFactory(irodsAccount);
        IRODSFile irodsFile = irodsFileFactory
                .instanceIRODSFile(targetIrodsCollection + '/' + testFileName);

        IRODSFileOutputStream irodsFileOutputStream = irodsFileFactory
                .instanceIRODSFileOutputStream(irodsFile);

        irodsFileOutputStream.write(string1.getBytes());
        irodsFileOutputStream.close();
        irodsFileOutputStream = irodsFileFactory.instanceIRODSFileOutputStream(
                irodsFile, OpenFlags.WRITE_TRUNCATE);

        irodsFileOutputStream.write(string2.getBytes());
        irodsFileOutputStream.close();

        IRODSFileInputStream irodsFileInputStream = irodsFileFactory
                .instanceIRODSFileInputStream(irodsFile);
        String actual = MiscIRODSUtils
                .convertStreamToString(irodsFileInputStream);
        irodsFileInputStream.close();

        Assert.assertEquals("should be second string", string2, actual);

    }

in test, these lines:

IRODSFileOutputStream irodsFileOutputStream = irodsFileFactory
                .instanceIRODSFileOutputStream(irodsFile);

        irodsFileOutputStream.write(string1.getBytes());
        irodsFileOutputStream.close();

yield

Aug 25 14:34:34 pid:9226 NOTICE: Agent process 9618 started for puser=test1 and cuser=test1 from 127.0.0.1
Aug 25 14:34:37 pid:9618 NOTICE: writeLine: inString = Post Proc! ---  File Path is /var/lib/irods/iRODS/Vault1/home/test1/jargon-scratch/IRODSFileOutputStreamTest/testIRODSFileOutputStreamOverwrite.txt

Then these subsequent lines

irodsFileOutputStream = irodsFileFactory.instanceIRODSFileOutputStream(
                irodsFile, OpenFlags.WRITE_TRUNCATE);

        irodsFileOutputStream.write(string2.getBytes());
        irodsFileOutputStream.close();

again yield


Aug 25 14:34:46 pid:9618 NOTICE: writeLine: inString = Post Proc! ---  File Path is /var/lib/irods/iRODS/Vault1/home/test1/jargon-scratch/IRODSFileOutputStreamTest/testIRODSFileOutputStreamOverwrite.txt


@tedgin
Copy link
Contributor

tedgin commented Aug 25, 2015

If verified that if the file exists before the output stream is opened with WRITE_TRUNCATE flag, the acPostProcForPut rule will be called when the output stream is closed. If the file doesn't exist, the rule will not be called.

@michael-conway
Copy link
Collaborator Author

thanks! I'm on it.

@michael-conway
Copy link
Collaborator Author

this is linked to #146.

michael-conway pushed a commit that referenced this issue Aug 26, 2015
@michael-conway michael-conway modified the milestone: Minor changes and compatibility - 4.1.0 Sep 24, 2015
@michael-conway
Copy link
Collaborator Author

retest with 4.1.6 before release

michael-conway pushed a commit that referenced this issue Nov 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants