Package org.apache.geronimo.datastore

Examples of org.apache.geronimo.datastore.GFile


    public void testUseCase() throws Exception {

        byte[] content = "Dummy content".getBytes();
       
        Object interactId = fileManager.startInteraction();
        GFile file = fileManager.factoryGFile(interactId, "test");
        fileManager.persistNew(interactId, file);
        file.addProperty("name1", "value1");
        file.addProperty("name2", "value2");
        file.addProperty("name3", "value3");
        file.setContent(new ByteArrayInputStream(content));
        fileManager.endInteraction(interactId);
       
        interactId = fileManager.startInteraction();
        InputStream in = file.getInputStream();
        int read;
        int nbRead = 0;
        while ( -1 < (read = in.read()) ) {
            assertEquals("Wrong content", content[nbRead], read);
            nbRead++;
        }
        Map properties = file.getProperties();
        assertEquals("Properties issue", 3, properties.size());
        assertEquals("Properties issue", "value1", properties.get("name1"));
        assertEquals("Properties issue", "value2", properties.get("name2"));
        assertEquals("Properties issue", "value3", properties.get("name3"));
        file.addProperty("name4", "value4");
        file.removeProperty("name3");
        fileManager.persistUpdate(interactId, file);
        fileManager.endInteraction(interactId);
       
        interactId = fileManager.startInteraction();
        properties = file.getProperties();
        assertEquals("Properties issue", 3, properties.size());
        assertEquals("Properties issue", "value1", properties.get("name1"));
        assertEquals("Properties issue", "value2", properties.get("name2"));
        assertEquals("Properties issue", "value4", properties.get("name4"));
        fileManager.persistDelete(interactId, file);
View Full Code Here


        return fileManager.getName();
    }

    public GFile factoryGFile(Object anOpaque, String aPath)
        throws GFileManagerException {
        GFile gFile = fileManager.factoryGFile(anOpaque, aPath);
        Integer id = registerGFile(gFile);
        return new GFileStub(aPath, id);
    }
View Full Code Here

        return new GFileStub(aPath, id);
    }
   
    public void persistNew(Object anOpaque, GFile aFile) {
        GFileStub stub = (GFileStub) aFile;
        GFile actualGFile = retrieveGFile(stub.getID());
        fileManager.persistNew(anOpaque, actualGFile);
    }
View Full Code Here

        fileManager.persistNew(anOpaque, actualGFile);
    }

    public void persistUpdate(Object anOpaque, GFile aFile) {
        GFileStub stub = (GFileStub) aFile;
        GFile actualGFile = retrieveGFile(stub.getID());
        fileManager.persistUpdate(anOpaque, actualGFile);
    }
View Full Code Here

        fileManager.persistUpdate(anOpaque, actualGFile);
    }

    public void persistDelete(Object anOpaque, GFile aFile) {
        GFileStub stub = (GFileStub) aFile;
        GFile actualGFile = retrieveGFile(stub.getID());
        fileManager.persistDelete(anOpaque, actualGFile);
    }
View Full Code Here

     * @param aRequest Request to be executed against the GFile identified by
     * anID.
     * @return Request result.
     */
    public CommandResult executeOnGFile(Integer anID, CommandRequest aRequest) {
        GFile gFile = retrieveGFile(anID);
        aRequest.setTarget(gFile);
        return aRequest.execute();
    }
View Full Code Here

    
     * @param anID Id of the GFile to be returned.
     * @return GFile.
     */
    protected GFile retrieveGFile(Integer anID) {
        GFile gFile;
        synchronized(gFiles) {
            gFile = (GFile) gFiles.get(anID);
        }
        if ( null == gFile ) {
            throw new IllegalArgumentException("GFileStub {" + anID +
View Full Code Here

    public void testUseCase() throws Exception {

        byte[] content = "Dummy content".getBytes();
       
        Object interactId = fileManager.startInteraction();
        GFile file = fileManager.factoryGFile(interactId, "test");
        fileManager.persistNew(interactId, file);
        file.addProperty("name1", "value1");
        file.addProperty("name2", "value2");
        file.addProperty("name3", "value3");
        file.setContent(new ByteArrayInputStream(content));
        fileManager.endInteraction(interactId);
       
        interactId = fileManager.startInteraction();
        InputStream in = file.getInputStream();
        int read;
        int nbRead = 0;
        while ( -1 < (read = in.read()) ) {
            assertEquals("Wrong content", content[nbRead], read);
            nbRead++;
        }
        Map properties = file.getProperties();
        assertEquals("Properties issue", 3, properties.size());
        assertEquals("Properties issue", "value1", properties.get("name1"));
        assertEquals("Properties issue", "value2", properties.get("name2"));
        assertEquals("Properties issue", "value3", properties.get("name3"));
        file.addProperty("name4", "value4");
        file.removeProperty("name3");
        fileManager.persistUpdate(interactId, file);
        fileManager.endInteraction(interactId);
       
        interactId = fileManager.startInteraction();
        properties = file.getProperties();
        assertEquals("Properties issue", 3, properties.size());
        assertEquals("Properties issue", "value1", properties.get("name1"));
        assertEquals("Properties issue", "value2", properties.get("name2"));
        assertEquals("Properties issue", "value4", properties.get("name4"));
        fileManager.persistDelete(interactId, file);
View Full Code Here

TOP

Related Classes of org.apache.geronimo.datastore.GFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.