jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCR-556) Refactoring of the BackupTool
Date Thu, 22 Feb 2007 13:43:06 GMT

    [ https://issues.apache.org/jira/browse/JCR-556?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475012
] 

Stefan Guggisberg commented on JCR-556:
---------------------------------------

> Nicolas Toper updated JCR-556:
> ------------------------------
> 
> I didn't change the code flow. IMO both ways has drawbacks. 

what is the drawback of jukka's suggestion? the code would imo be cleaner.

btw:  there's no need to synchronize on the sql stmt  since there are no bound paramaters.

here's my suggestion:

    //-----------------------------------------< VisitableItemStateCollection >
    /**
     * {@inheritDoc}
     */
    public void accept(ItemStateVisitor visitor) throws ItemStateException {
        ResultSet rs = null;
        InputStream in = null;
        try {
            // visit node states
            Statement stmt = executeStmt(nodeStateSelectAllSQL, new Object[0]);
            rs = stmt.getResultSet();
            while (rs.next()) {
                String id = rs.getString(1);
                NodeState state = createNew(NodeId.valueOf(id));
                in = rs.getBinaryStream(2);
                Serializer.deserialize(state, in);
                visitor.visit(state);
            }
            closeStream(in);
            closeResultSet(rs);

            // visit property states
            stmt = executeStmt(propertyStateSelectAllSQL, new Object[0]);
            rs = stmt.getResultSet();
            while (rs.next()) {
                String id = rs.getString(1);
                PropertyState state = createNew(PropertyId.valueOf(id));
                in = rs.getBinaryStream(2);
                Serializer.deserialize(state, in, blobStore);
                visitor.visit(state);
            }
        } catch (Exception e) {
            String msg = "failed to visit item states";
            log.error(msg, e);
            throw new ItemStateException(msg, e);
        } finally {
            closeStream(in);
            closeResultSet(rs);
        }
    }

the above code assumes the following sql stmts:

+        nodeStateSelectAllSQL = "select NODE_ID, NODE_DATA from " + schemaObjectPrefix +
"NODE";
+        propertyStateSelectAllSQL = "select PROP_ID, PROP_DATA from " + schemaObjectPrefix
+ "PROP";


there are also some minor javaodc issues: 
e.g. javadoc of  generic VisitableItemStateCollection & ItemStateVisitor refer to 'persistence
manager'

> Refactoring of the BackupTool
> -----------------------------
>
>                 Key: JCR-556
>                 URL: https://issues.apache.org/jira/browse/JCR-556
>             Project: Jackrabbit
>          Issue Type: Improvement
>            Reporter: Nicolas Toper
>            Priority: Minor
>         Attachments: BIO.patch, patch-backup-040906.txt, patch-jr-010906-NodeVersionHistoriesUpdatableStateManager.txt,
patch-jr-010906-PropInfo.txt, patch-jr-010906-RepositoryImpl.txt, patch-jr-010906-SysViewImporter.txt,
patch-jr-010906-VersionManagerImpl.txt, PropInfo.patch, VisitorPattern200207.patch, VisitorPattern22022007-2.patch,
VisitorPattern22022007.patch
>
>
> The BackupTool has still some refactoring to perform. I will propose the patch on this
new issue since we cannot change the JCR-442 (Google wants to see a place where all the Google
SoC work is).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message