Index: /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java =================================================================== --- /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java (revision 0) +++ /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/Backup.java (revision 0) @@ -0,0 +1,58 @@ +/* + * 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); + + } Index: /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java =================================================================== --- /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java (revision 0) +++ /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupConfig.java (revision 0) @@ -0,0 +1,48 @@ +/* + * 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 + + } + + + + + + +} Index: /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java =================================================================== --- /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java (revision 0) +++ /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupIOHandler.java (revision 0) @@ -0,0 +1,10 @@ +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? + +} Index: /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java =================================================================== --- /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java (revision 0) +++ /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/BackupLauncher.java (revision 0) @@ -0,0 +1,118 @@ +/* + * 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 + * + * 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) + { + + } + +} Index: /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java =================================================================== --- /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java (revision 0) +++ /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/RepositoryBackup.java (revision 0) @@ -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; + +/** + * @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 + + } + + + + +} \ No newline at end of file Index: /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java =================================================================== --- /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java (revision 0) +++ /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/backup/ZipFileBackupIOHandler.java (revision 0) @@ -0,0 +1,13 @@ +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... +} Index: /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java =================================================================== --- /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (revision 417024) +++ /home/ntoper/workspace/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (working copy) @@ -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,42 @@ } } } + + + /** + * + * 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 + * + */ + 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(); + } + + }