Package com.openkm.openoffice.bean

Examples of com.openkm.openoffice.bean.ConfigBean


    private ConfigFile configFile;

    /** Creates new form Configuration */
    public ConfigForm(ConfigFile configFile) throws OKMException {
        this.configFile = configFile;
        ConfigBean configBean = configFile.read();
        initComponents();
        setLocationByPlatform(true);
        setLocationRelativeTo(getParent());
        hostInput.setText(configBean.getHost());
        userInput.setText(configBean.getUser());
        passwordInput.setText(configBean.getPassword());

        // I18N Translations
        setTitle(OpenKMAddOn.get().getLang().getString("config.title"));
        userLabel.setText(OpenKMAddOn.get().getLang().getString("config.user"));
        passwordLabel.setText(OpenKMAddOn.get().getLang().getString("config.password"));
View Full Code Here


            configFilename = directoryToStoreFiles + FileUtil.getFolderPathSeparator() + OPENKM_CONFIG_FILENAME;
            File f = new File(configFilename);
            try {
                if (!f.exists()) {
                    f.createNewFile();
                    save(new ConfigBean());
                }
            } catch (IOException ex) {
                throw new OKMException(ex);
            }
        }
View Full Code Here

        } finally {
        }
    }

    public ConfigBean read() throws OKMException {
        ConfigBean configBean = new ConfigBean();

        try {
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse (new File(configFilename));

            NodeList nodes = doc.getElementsByTagName("openkm");
            if (nodes.getLength()>0) {
                Node config = nodes.item(0);
                Element configElement = (Element) config;
                if (configElement.getElementsByTagName("host").item(0).hasChildNodes()) {
                    configBean.setHost(configElement.getElementsByTagName("host").item(0).getChildNodes().item(0).getNodeValue());
                }
                if (configElement.getElementsByTagName("user").item(0).hasChildNodes()) {
                    configBean.setUser(configElement.getElementsByTagName("user").item(0).getChildNodes().item(0).getNodeValue());
                }
                if (configElement.getElementsByTagName("password").item(0).hasChildNodes()) {
                    configBean.setPassword(configElement.getElementsByTagName("password").item(0).getChildNodes().item(0).getNodeValue());
                }
                if (configBean.getPassword().length()>0) {
                    configBean.setPassword(encryption.decrypt(configBean.getPassword()));
                }
            }

        } catch (ParserConfigurationException ex) {
            throw new OKMException(ex);
View Full Code Here

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void acceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptButtonActionPerformed
        ConfigBean configBean = new ConfigBean();
        String host = hostInput.getText();
        if (!host.startsWith("http://")) {
            host = "http://" + host;
        }
        if (host.endsWith("/")) {
            host = host.substring(0, host.lastIndexOf("/"));
        }
        configBean.setHost(host);
        configBean.setUser(userInput.getText());
        configBean.setPassword(new String(passwordInput.getPassword()));
        if (host.equals("")) {
            new ErrorForm(new OKMException(OpenKMAddOn.get().getLang().getString("config.error.host.empty")));
        } else if (configBean.getUser().equals("")) {
            new ErrorForm(new OKMException(OpenKMAddOn.get().getLang().getString("config.error.user.empty")));
        } else if (configBean.getPassword().equals("")) {
            new ErrorForm(new OKMException(OpenKMAddOn.get().getLang().getString("config.error.password.empty")));
        } else {
            try {
                configFile.save(configBean);
            } catch (OKMException ex) {
View Full Code Here

                }

                if ( aURL.Path.compareTo("edit") == 0 )
                {
                    try {
                        ConfigBean configBean = configFile.read();
                        ExplorerForm explorerForm = new ExplorerForm(documentFile,imageUtil);
                        explorerForm.initServices(configFile.read().getHost());
                        explorerForm.startUp(m_xFrame, configBean.getUser(), configBean.getPassword());
                        explorerForm.setVisible(true);
                    } catch (OKMException ex) {
                        new ErrorForm(ex);
                    }
                    return;
                }
                if ( aURL.Path.compareTo("add") == 0 )
                {
                    String documentPath = getCurrentDocumentPath();
                    if (documentPath!=null && !documentPath.equals("")) {
                        try {
                            ConfigBean configBean = configFile.read();
                            TreeForm treeForm = new TreeForm(imageUtil);
                            treeForm.initServices(configFile.read().getHost());
                            treeForm.startUp(configBean.getUser(), configBean.getPassword(),documentPath);
                            treeForm.setVisible(true);
                        } catch (OKMException ex) {
                            new ErrorForm(ex);
                        }
                    } else {
View Full Code Here

    }

    public void create(String path, String documentPath) throws OKMException {
        if (documentPath!=null && !documentPath.equals("")) {
            waitWindow.setVisible(true);
            ConfigBean configBean = configFile.read();
            OKMDocumentBean document = new OKMDocumentBean();
            document.setLocalFilename(documentPath);
            try {
                document.setPath(path + "/" + Util.getLocalFileName(documentPath));
            } catch (UnsupportedEncodingException ex) {
                new OKMException(ex);
            }
            DocumentLogic.create(configBean.getHost(), configBean.getUser(), configBean.getPassword(), document);
            waitWindow.setVisible(false);
            new ConfirmationForm("main.document.added",ConfirmationForm.OPERATION_DOCUMENT_ADDED, "");
        } else {
            waitWindow.setVisible(false);
            new ErrorForm(new OKMException(lang.getString("main.error.save.file")));
View Full Code Here

    public void executeCheckin(String documentPath) {
        try {
            waitWindow.setVisible(true);
            storeToDisk();
            OKMDocumentBean oKMDocumentBean = documentFile.findByLocalFileName(documentPath);
            ConfigBean configBean = configFile.read();
            DocumentLogic.checkin(configBean.getHost(), configBean.getUser(), configBean.getPassword(), oKMDocumentBean);
            documentFile.remove(oKMDocumentBean);
            waitWindow.setVisible(false);
            m_xFrame.dispose();
            File file = new File(documentPath);
            file.delete(); // file is always locally deleted
View Full Code Here

    public void executeCancelCheckin(String documentPath) {
        try {
            waitWindow.setVisible(true);
            OKMDocumentBean oKMDocumentBean = documentFile.findByLocalFileName(documentPath);
            ConfigBean configBean = configFile.read();
            DocumentLogic.cancelCheckout(configBean.getHost(), configBean.getUser(), configBean.getPassword(), oKMDocumentBean);
            documentFile.remove(oKMDocumentBean);
            waitWindow.setVisible(false);
            m_xFrame.dispose();
            File file = new File(documentPath);
            file.delete(); // file is always locally deleted
View Full Code Here

TOP

Related Classes of com.openkm.openoffice.bean.ConfigBean

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.