jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r418655 - in /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit: backup/ core/
Date Sun, 02 Jul 2006 21:55:45 GMT
Author: jukka
Date: Sun Jul  2 14:55:45 2006
New Revision: 418655

URL: http://svn.apache.org/viewvc?rev=418655&view=rev
Log:
JCR-442: Merged the backup tool skeleton contributed by Nicolas Toper. (Work in progress)

Added:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java   (with
props)
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java
  (with props)
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java
  (with props)
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java
  (with props)
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java
  (with props)
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java

Added: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java?rev=418655&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java (added)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java Sun
Jul  2 14:55:45 2006
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.backup;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+
+/**
+ * This class is the abstract class of all resources to backup. If you need to add a new
backuped resource
+ * extend Backup and implement both the save and restore methods.
+ *
+ * The constructor is called when instantiating the specific backup resource class through
RepositoryBackup.
+ */
+public abstract class Backup {
+
+    RepositoryImpl repo;
+    BackupConfig conf;
+    String name;
+
+    /**
+     *
+     * @param repo The repository to backup
+     * @param conf The specific BackupConfig object (usually a subset of backup.xml)
+     * @param name Name of the resource to backup. Unique. Useful?
+     */
+    public Backup(RepositoryImpl repo, BackupConfig conf) {
+        this.repo = repo;
+        this.conf = conf;
+    }
+
+    public void setRepo(RepositoryImpl repo) {
+        this.repo = repo;
+    }
+
+    public RepositoryImpl getRepo() {
+        return this.repo;
+    }
+
+    public abstract void backup(BackupIOHandler out, BackupConfig conf);
+    public abstract void restore(BackupIOHandler in);
+
+}

Propchange: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java?rev=418655&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java
(added)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java
Sun Jul  2 14:55:45 2006
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.backup;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+
+public class BackupConfig {
+
+    public BackupConfig() {
+        // TODO Auto-generated constructor stub
+    }
+
+    public Backup getBackup() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void setRepo(RepositoryImpl impl) {
+        // TODO Auto-generated method stub
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java?rev=418655&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java
(added)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java
Sun Jul  2 14:55:45 2006
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.backup;
+
+public interface BackupIOHandler {
+
+	void setMaxFileSize(int i);
+	int getMaxFileSize();
+	//Add reference to the file
+	// How to precise if in or out... Maybe not needed?
+
+}

Propchange: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java?rev=418655&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java
(added)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java
Sun Jul  2 14:55:45 2006
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.backup;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+
+/**
+ * BackupLauncher is a command line tool and a demo tool for the backup tool. To
+ * get all available options please type BackupLauncher --help
+ * Used to launch a backup while the repository is inactive.
+ *
+ * @author Nicolas Toper <ntoper@gmail.com>
+ * Date: 23-jun-06
+ */
+public class BackupLauncher {
+
+    BackupConfig conf;
+    RepositoryImpl repo;
+
+    /**
+     * The command line tool.
+     *
+     * BackupLauncher --zip "myzip.zip" --size 2 save
+     * BackupLauncher --zip "./myzip.zip" --size 2 restore
+     *
+     * -zip: where is the zip file (only implemented way to backup for now)
+     * -size in Go
+     *
+     * --help for help option
+     *
+     */
+    public static void main(String[] args) {
+
+        for (int i = 0; i < args.length; i++) {
+            if ( args[i].equals("--help")  || args.length == 0) {
+                usage();
+            }
+
+            //To finish
+            /* BackupIOHandler h = new ZipFileBackupIOHandler("mybackup.zip");
+             h.setMaxFileSize(2);*/
+            //repo.getBackupManager().save(h, config);
+            //path to repository.xml
+            // TODO Auto-generated method stub
+        }
+    }
+
+    /**
+     * Auxiliary method for main
+     *
+     */
+    private static void usage(){
+        System.out.println("options:\n --zip to specify the path of the zip file.\n --size
(optional) max size of the file\n save|restore\n" +
+                "example 1: java BackupLauncher --zip \"myzip.zip\" --size 2 save " +
+        "example 2: java BackupLauncher --zip \"./myzip.zip\" --size 2 restore");
+        System.exit(0);
+    }
+
+    /**
+     * Constructor of BackupLauncher. Initiate the repository.
+     *
+     * @param String filename: name of the configuration file
+     */
+    public BackupLauncher(String filename) {
+        //this.conf = new BackupConfig(filename);
+        //How to launch the repository? JNDI?
+    }
+
+    public void backup(String out) throws AccessDeniedException, RepositoryException, IOException
{
+        //repo.getBackupRepository();
+    }
+
+    /**
+     *
+     * @param filename
+     */
+    public void restore(FileInputStream file) {
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java?rev=418655&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java
(added)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java
Sun Jul  2 14:55:45 2006
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.backup;
+
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+
+/**
+ * @author ntoper
+ *
+ */
+public class RepositoryBackup extends Backup {
+
+    public RepositoryBackup(RepositoryImpl repo, BackupConfig conf) {
+        super(repo, conf);
+        // TODO Auto-generated constructor stub
+    }
+
+//  @Override
+    public void backup(BackupIOHandler out, BackupConfig conf) {
+        // TODO Auto-generated method stub
+    }
+    
+//  @Override
+    public void restore(BackupIOHandler in) {
+        // TODO Auto-generated method stub
+        
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java?rev=418655&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java
(added)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java
Sun Jul  2 14:55:45 2006
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.backup;
+
+public class ZipFileBackupIOHandler implements BackupIOHandler {
+
+    public void setMaxFileSize(int i) {
+    }
+
+    public int getMaxFileSize() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    //To finish...
+
+}

Propchange: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=418655&r1=418654&r2=418655&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Sun Jul  2 14:55:45 2006
@@ -21,6 +21,9 @@
 import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.api.JackrabbitRepository;
+import org.apache.jackrabbit.backup.BackupIOHandler;
+import org.apache.jackrabbit.backup.BackupConfig;
+import org.apache.jackrabbit.backup.RepositoryBackup;
 import org.apache.jackrabbit.core.config.FileSystemConfig;
 import org.apache.jackrabbit.core.config.LoginModuleConfig;
 import org.apache.jackrabbit.core.config.PersistenceManagerConfig;
@@ -1840,4 +1843,38 @@
             }
         }
     }
+
+    /**
+     *
+     * This method returns a RepositoryBackup object configured to save this repository.
+     *
+     * Some operations are needed to initiate the RepositoryBackup object properly before
performing
+     * the backup or restore operation.
+     *
+     * @param BackupConfig conf: BackupConfig object containing all the parameters.
+     * @return RepositoryBackup configured
+     * @throws RepositoryException
+     * @throws AccessDeniedException
+     * @throws IoException
+     * @author: Nicolas Toper <ntoper@gmail.com>
+     */
+    public RepositoryBackup getBackupRepository(BackupConfig conf, BackupIOHandler h) throws
RepositoryException, IOException, AccessDeniedException {
+        conf.setRepo(this);
+        return (RepositoryBackup) conf.getBackup();
+    }
+
+    /**
+     * For restore operations since the
+     * @return RepositoryBackup to configure
+     * @param BackupIOHandler is a pointer to the file to restore
+     * @throws RepositoryException
+     * @throws IOException
+     * @throws AccessDeniedException
+     */
+    public RepositoryBackup getBackupRepository(BackupIOHandler source) throws RepositoryException,
IOException, AccessDeniedException {
+        BackupConfig conf = new BackupConfig();
+        conf.setRepo(this);
+        return (RepositoryBackup) conf.getBackup();
+    }
+
 }



Mime
View raw message