edu.internet2.middleware.grouper.app.gsh.xmlToFile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grouper Show documentation
Show all versions of grouper Show documentation
Internet2 Groups Management Toolkit
/**
* Copyright 2014 Internet2
*
* Licensed 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.
*/
/*
* Copyright (C) 2006-2007 blair christensen.
* All Rights Reserved.
*
* You may use and distribute under the same terms as Grouper itself.
*/
package edu.internet2.middleware.grouper.app.gsh;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Properties;
import bsh.CallStack;
import bsh.Interpreter;
import edu.internet2.middleware.grouper.GrouperSession;
import edu.internet2.middleware.grouper.exception.GrouperException;
import edu.internet2.middleware.grouper.xml.XmlExporter;
/**
* Export Groups Registry to XML file.
*
* @author blair christensen.
* @version $Id: xmlToFile.java,v 1.2 2008-09-29 03:38:28 mchyzer Exp $
* @since 0.1.0
*/
public class xmlToFile {
// PUBLIC CLASS METHODS //
/**
* Export Groups Registry to XML file.
*
* @param i BeanShell interpreter.
* @param stack BeanShell call stack.
* @param file Export XML to file with this name.
* @return boolean
* @throws GrouperShellException
* @since 0.1.0
*/
public static boolean invoke(Interpreter i, CallStack stack, String file)
throws GrouperShellException
{
GrouperShell.setOurCommand(i, true);
try {
GrouperSession s = GrouperShell.getSession(i);
return invoke(s, file);
}
catch (GrouperException eG) {
GrouperShell.error(i, eG);
}
catch (Exception e) {
GrouperShell.error(i, e);
}
return false;
}
/**
* Export Groups Registry to XML file.
*
* @param grouperSession
* @param file Export XML to file with this name.
* @return boolean
*/
public static boolean invoke(GrouperSession grouperSession, String file) {
try {
XmlExporter exporter = new XmlExporter(grouperSession, new Properties());
Writer w = new BufferedWriter( new FileWriter( new File(file) ) );
exporter.export(w);
return true;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} // public class xmlToFile
© 2015 - 2024 Weber Informatics LLC | Privacy Policy