Package org.fcrepo.client.utility.export

Examples of org.fcrepo.client.utility.export.AutoExporter


        super("Export Objects...");
        m_pids = pids;
    }

    public void actionPerformed(ActionEvent ae) {
        AutoExporter exporter = null;
        try {
            exporter = new AutoExporter(Administrator.APIA, Administrator.APIM);
        } catch (Exception e) {
            Administrator.showErrorDialog(Administrator.getDesktop(),
                                          "Export Failure",
                                          e.getClass().getName() + ": "
                                                  + e.getMessage(),
                                          e);
        }
        if (exporter != null) {
            if (m_prompt) {
                String pid = JOptionPane.showInputDialog("Enter the PID.");
                if (pid == null) {
                    return;
                }
                m_pids = new HashSet();
                m_pids.add(pid);
            }
            Iterator pidIter = m_pids.iterator();
            if (m_pids.size() == 1) {
                // If there's only one pid, get export filename
                String pid = (String) pidIter.next();
                try {
                    FileDialog dlg =
                            new FileDialog(Administrator.INSTANCE,
                                           "Export object to...",
                                           FileDialog.SAVE);
                    if (Administrator.getLastDir() != null) {
                        dlg.setDirectory(Administrator.getLastDir().getPath());
                    }
                    dlg.setVisible(true);
                    if (dlg.getFile() != null) {
                        File file =
                                new File(new File(dlg.getDirectory()), dlg
                                        .getFile());
                        Administrator.setLastDir(file.getParentFile()); // remember the dir for next time
                        ExportOptionsDialog optsDialog =
                                new ExportOptionsDialog("Select Options for Export");
                        if (optsDialog.getFormatSelection() != null) {
                            exporter.export(pid,
                                            optsDialog.getFormatSelection(),
                                            optsDialog.getContextSelection(),
                                            new FileOutputStream(file));
                            JOptionPane.showMessageDialog(Administrator
                                    .getDesktop(), "Exported " + pid);
                        }
                    }
                } catch (Exception e) {
                    Administrator.showErrorDialog(Administrator.getDesktop(),
                                                  "Export Failure",
                                                  e.getClass().getName() + ": "
                                                          + e.getMessage(),
                                                  e);
                }
            } else {
                // If there are multiple pids, select a directory first.
                try {
                    JFileChooser browse;
                    if (Administrator.getLastDir() == null) {
                        browse = new JFileChooser();
                    } else {
                        browse = new JFileChooser(Administrator.getLastDir());
                    }
                    browse.setApproveButtonText("Export");
                    browse.setApproveButtonMnemonic('E');
                    browse
                            .setApproveButtonToolTipText("Exports to the selected directory.");
                    browse.setDialogTitle("Export to...");
                    browse.setDialogTitle("Choose export directory...");
                    browse.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                    int returnVal =
                            browse.showOpenDialog(Administrator.getDesktop());
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        Administrator.setLastDir(browse.getSelectedFile()); // remember the dir for next time
                        ExportOptionsDialog optsDialog =
                                new ExportOptionsDialog("Select Options for Export");
                        if (optsDialog.getFormatSelection() != null) {
                            while (pidIter.hasNext()) {
                                String pid = (String) pidIter.next();
                                StringBuffer buf = new StringBuffer();
                                for (int i = 0; i < pid.length(); i++) {
                                    char c = pid.charAt(i);
                                    if (c == ':') {
                                        buf.append('_');
                                    } else {
                                        buf.append(c);
                                    }
                                }
                                File outFile =
                                        new File(browse.getSelectedFile(), buf
                                                .toString()
                                                + ".xml");
                                exporter
                                        .export(pid,
                                                optsDialog.getFormatSelection(),
                                                optsDialog
                                                        .getContextSelection(),
                                                new FileOutputStream(outFile));
View Full Code Here


                return;
            }
            m_pids = new HashSet();
            m_pids.add(pid);
        }
        AutoExporter exporter = null;
        try {
            exporter = new AutoExporter(Administrator.APIA, Administrator.APIM);
        } catch (Exception e) {
            Administrator.showErrorDialog(Administrator.getDesktop(),
                                          "View Failure",
                                          e.getClass().getName() + ": "
                                                  + e.getMessage(),
                                          e);
        }
        if (exporter != null) {
            Iterator pidIter = m_pids.iterator();
            while (pidIter.hasNext()) {
                try {
                    String pid = (String) pidIter.next();
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    exporter.getObjectXML(pid, out);
                    JTextComponent textEditor = new JTextArea();
                    textEditor.setFont(new Font("monospaced", Font.PLAIN, 12));
                    textEditor.setText(new String(out.toString("UTF-8")));
                    textEditor.setCaretPosition(0);
                    textEditor.setEditable(false);
View Full Code Here

TOP

Related Classes of org.fcrepo.client.utility.export.AutoExporter

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.