Example usage for org.dom4j.io SAXReader SAXReader

List of usage examples for org.dom4j.io SAXReader SAXReader

Introduction

In this page you can find the example usage for org.dom4j.io SAXReader SAXReader.

Prototype

public SAXReader() 

Source Link

Usage

From source file:com.doculibre.constellio.izpack.PersistenceXMLUtils.java

License:Open Source License

@SuppressWarnings("unchecked")
public static void run(AbstractUIProcessHandler handler, String[] args) {
    if (args.length != 5) {
        System.out.println("persistence_mysqlPath defaultPersistencePath server login password");
        return;// ww w .j  a  v  a 2 s .  c  o m
    }

    String persistence_mysqlPath = args[0];
    String defaultPersistencePath = args[1];
    String server = args[2];
    String login = args[3];
    String password = args[4];

    Document xmlDocument;
    try {
        xmlDocument = new SAXReader().read(persistence_mysqlPath);
        Element root = xmlDocument.getRootElement();
        Iterator<Element> it = root.elementIterator("persistence-unit");
        if (!it.hasNext()) {
            System.out.println("Corrupt persistence file :" + persistence_mysqlPath);
            return;
        }
        it = it.next().elementIterator("properties");
        if (!it.hasNext()) {
            System.out.println("Corrupt persistence file :" + persistence_mysqlPath);
            return;
        }
        Element properties = it.next();
        for (it = properties.elementIterator("property"); it.hasNext();) {
            Element property = it.next();
            String id = property.attributeValue("name");
            if (id.equals(SERVER_ELEMENT_ID)) {
                Attribute att = property.attribute("value");
                att.setText(BEFORE_SERVER_NAME + server + AFTER_SERVER_NAME);
            } else {
                if (id.equals(LOGIN_ELEMENT_ID)) {
                    Attribute att = property.attribute("value");
                    att.setText(login);
                } else {
                    if (id.equals(PASSWORD_ELEMENT_ID)) {
                        Attribute att = property.attribute("value");
                        att.setText(password);
                    }
                }
            }

        }

        OutputFormat format = OutputFormat.createPrettyPrint();

        File xmlFile = new File(persistence_mysqlPath);
        XMLWriter writer2 = new XMLWriter(new FileOutputStream(xmlFile), format);

        writer2.write(xmlDocument);
        writer2.close();
        // copier au fichier de persistence par dfaut:
        xmlFile = new File(defaultPersistencePath);
        writer2 = new XMLWriter(new FileOutputStream(xmlFile), format);

        writer2.write(xmlDocument);
        writer2.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.doculibre.constellio.izpack.TomcatUtil.java

License:Open Source License

@SuppressWarnings("unchecked")
public static void run(AbstractUIProcessHandler handler, String[] args) {
    if (args.length != 2) {
        System.out.println("serverPath port");
        return;/*from  ww  w  . j  av  a 2s  .  c  o  m*/
    }

    String serverPath = args[0];
    String port = args[1];
    if (port.equals("8080")) {
        // C'est celui par defaut => ne rien faire
        return;
    }

    Document xmlDocument;
    try {
        xmlDocument = new SAXReader().read(serverPath);
        Element root = xmlDocument.getRootElement();

        Iterator<Element> it = root.elementIterator("Service");
        if (!it.hasNext()) {
            System.out.println("Corrupt persistence file :" + serverPath);
            return;
        }
        Element connectors = it.next();
        for (it = connectors.elementIterator("Connector"); it.hasNext();) {
            Element connector = it.next();
            String id = connector.attributeValue("protocol");
            if (id.startsWith("HTTP")) {
                Attribute att = connector.attribute("port");
                att.setText(port);
                break;
            }
        }

        OutputFormat format = OutputFormat.createPrettyPrint();

        File xmlFile = new File(serverPath);
        XMLWriter writer2 = new XMLWriter(new FileOutputStream(xmlFile), format);

        writer2.write(xmlDocument);
        writer2.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.doculibre.constellio.izpack.UsersToXmlFile.java

License:Open Source License

public static void run(AbstractUIProcessHandler handler, String[] args) {
    if (args.length != 3) {
        System.out.println("file login password");
        return;/* ww  w  .j  av  a  2  s.c  o  m*/
    }

    String target = args[0];

    File xmlFile = new File(target);

    BufferedWriter writer;
    try {
        writer = new BufferedWriter(new FileWriter(xmlFile));
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }

    try {
        for (String line : Arrays.asList(emptyFileLines)) {
            writer.write(line + System.getProperty("line.separator"));
        }

        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    String login = args[1];

    String passwd = args[2];

    UsersToXmlFile elem = new UsersToXmlFile();

    ConstellioUser dataUser = elem.new ConstellioUser(login, passwd, null);
    dataUser.setFirstName("System");
    dataUser.setLastName("Administrator");
    dataUser.getRoles().add(Roles.ADMIN);

    Document xmlDocument;
    try {
        xmlDocument = new SAXReader().read(target);
        Element root = xmlDocument.getRootElement();

        BaseElement user = new BaseElement(USER);
        user.addAttribute(FIRST_NAME, dataUser.getFirstName());
        user.addAttribute(LAST_NAME, dataUser.getLastName());
        user.addAttribute(LOGIN, dataUser.getUsername());
        user.addAttribute(PASSWORD_HASH, dataUser.getPasswordHash());

        if (dataUser.getLocale() != null) {
            user.addAttribute(LOCALE, dataUser.getLocaleCode());
        }

        Set<String> constellioRoles = dataUser.getRoles();
        if (!constellioRoles.isEmpty()) {
            Element roles = user.addElement(ROLES);
            for (String constellioRole : constellioRoles) {
                Element role = roles.addElement(ROLE);
                role.addAttribute(VALUE, constellioRole);
            }
        }

        root.add(user);

        OutputFormat format = OutputFormat.createPrettyPrint();

        xmlFile = new File(target);
        // FIXME recrire la DTD
        // xmlDocument.addDocType(arg0, arg1, arg2)
        XMLWriter writer2 = new XMLWriter(new FileOutputStream(xmlFile), format);

        writer2.write(xmlDocument);
        writer2.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.doculibre.constellio.utils.izpack.UsersXmlFileUtils.java

License:Open Source License

@SuppressWarnings("unchecked")
public static List<ConstellioUser> readUsers(String fileName) {
    List<ConstellioUser> returnList = new ArrayList<ConstellioUser>();

    File xmlFile = new File(fileName);

    Document xmlDocument;/*from   w  w  w. j a  v  a2s . c  o  m*/
    if (!xmlFile.exists()) {
        return returnList;
    }
    try {
        xmlDocument = new SAXReader().read(xmlFile);
    } catch (DocumentException e) {
        e.printStackTrace();
        return returnList;
    }

    Element root = xmlDocument.getRootElement();
    for (Iterator<Element> it = root.elementIterator(USER); it.hasNext();) {
        Element currentUser = it.next();
        returnList.add(toConstellioUser(currentUser));

    }
    return returnList;
}

From source file:com.doculibre.constellio.utils.izpack.UsersXmlFileUtils.java

License:Open Source License

public static void addUserTo(ConstellioUser constellioUser, String fileName) {
    Document xmlDocument;//from  w w w .  j a va  2 s .c  om
    try {
        xmlDocument = new SAXReader().read(fileName);
        Element root = xmlDocument.getRootElement();

        Element user = toXmlElement(constellioUser);
        root.add(user);

        OutputFormat format = OutputFormat.createPrettyPrint();

        File xmlFile = new File(fileName);
        //FIXME recrire la DTD
        //xmlDocument.addDocType(arg0, arg1, arg2)
        XMLWriter writer = new XMLWriter(new FileOutputStream(xmlFile), format);

        writer.write(xmlDocument);
        writer.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.doculibre.constellio.utils.SolrSchemaUtils.java

License:Open Source License

public static IndexSchema getSchema(ConnectorType connectorType) {
    IndexSchema connectorTypeSchema;/*  w  w w.  ja va  2  s  .  com*/

    String targetSchemaName;
    if (connectorType != null) {
        targetSchemaName = connectorType.getName();
    } else {
        targetSchemaName = "constellio"; // Default
    }

    Resource[] classpathResources = ConstellioSpringUtils.getResources(SOLR_SCHEMA_PATTERN);
    if (classpathResources != null) {
        connectorTypeSchema = null;
        for (int i = 0; i < classpathResources.length; i++) {
            InputStream resourceInput = null;
            try {
                Resource resource = classpathResources[i];
                resourceInput = resource.getInputStream();
                Document schema = new SAXReader().read(resourceInput);
                Element schemaElement = schema.getRootElement();
                String schemaName = schemaElement.attributeValue("name");
                if (targetSchemaName.equals(schemaName)) {
                    resourceInput = resource.getInputStream();

                    SolrConfig dummySolrConfig;
                    URL dummySolrConfigURL = SolrSchemaUtils.class.getClassLoader()
                            .getResource("config" + File.separator + "solrdefault" + File.separator);
                    File dummySolrConfigDir = new File(dummySolrConfigURL.toURI());
                    File dummySolrConfigFile = new File(dummySolrConfigDir,
                            "conf" + File.separator + "solrconfig.xml");
                    dummySolrConfig = new SolrConfig(dummySolrConfigDir.getPath(),
                            dummySolrConfigFile.getPath(), null);

                    connectorTypeSchema = new IndexSchema(dummySolrConfig, null,
                            new InputSource(resourceInput));
                    break;
                }
            } catch (DocumentException e) {
                throw new RuntimeException(e);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } catch (ParserConfigurationException e) {
                throw new RuntimeException(e);
            } catch (SAXException e) {
                throw new RuntimeException(e);
            } catch (URISyntaxException e) {
                throw new RuntimeException(e);
            } catch (Exception e) {
                if (e instanceof RuntimeException) {
                    throw (RuntimeException) e;
                } else {
                    throw new RuntimeException(e);
                }
            } finally {
                IOUtils.closeQuietly(resourceInput);
            }
        }
    } else {
        connectorTypeSchema = null;
    }
    return connectorTypeSchema;
}

From source file:com.doculibre.constellio.utils.xml.SolrShemaXmlReader.java

License:Open Source License

public static Document readDocument(File file) {
    if (!file.exists()) {
        throw new RuntimeException(file.getAbsolutePath() + "does not exist!");
    }/*from w  ww. jav a  2  s .co m*/
    try {
        Document schemaDocument = new SAXReader().read(file);
        return schemaDocument;
    } catch (DocumentException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.doculibre.constellio.wicket.panels.results.DefaultSearchResultPanel.java

License:Open Source License

public DefaultSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id);//from  w ww.j a v a  2  s.co  m

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
            .getSearchInterfaceConfigServices();

    String collectionName = dataProvider.getSimpleSearch().getCollectionName();

    RecordCollection collection = collectionServices.get(collectionName);
    Record record = recordServices.get(doc);
    if (record != null) {
        SearchInterfaceConfig searchInterfaceConfig = searchInterfaceConfigServices.get();

        IndexField uniqueKeyField = collection.getUniqueKeyIndexField();
        IndexField defaultSearchField = collection.getDefaultSearchIndexField();
        IndexField urlField = collection.getUrlIndexField();
        IndexField titleField = collection.getTitleIndexField();

        if (urlField == null) {
            urlField = uniqueKeyField;
        }
        if (titleField == null) {
            titleField = urlField;
        }

        final String recordURL = record.getUrl();
        final String displayURL;

        if (record.getDisplayUrl().startsWith("/get?file=")) {
            HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
            displayURL = ContextUrlUtils.getContextUrl(req) + record.getDisplayUrl();

        } else {
            displayURL = record.getDisplayUrl();
        }

        String title = record.getDisplayTitle();

        final String protocol = StringUtils.substringBefore(displayURL, ":");
        boolean linkEnabled = isLinkEnabled(protocol);

        // rcupration des champs highlight  partir de la cl unique
        // du document, dans le cas de Nutch c'est l'URL
        QueryResponse response = dataProvider.getQueryResponse();
        Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
        Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL);

        String titleHighlight = getTitleFromHighlight(titleField.getName(), fieldsHighlighting);
        if (titleHighlight != null) {
            title = titleHighlight;
        }

        String excerpt = null;
        String description = getDescription(record);
        String summary = getSummary(record);

        if (StringUtils.isNotBlank(description) && searchInterfaceConfig.isDescriptionAsExcerpt()) {
            excerpt = description;
        } else {
            excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting);
            if (excerpt == null) {
                excerpt = description;
            }
        }

        toggleSummaryLink = new WebMarkupContainer("toggleSummaryLink");
        add(toggleSummaryLink);
        toggleSummaryLink.setVisible(StringUtils.isNotBlank(summary));
        toggleSummaryLink.add(new AttributeModifier("onclick", new LoadableDetachableModel() {
            @Override
            protected Object load() {
                return "toggleSearchResultSummary('" + summaryLabel.getMarkupId() + "')";
            }
        }));

        summaryLabel = new Label("summary", summary);
        add(summaryLabel);
        summaryLabel.setOutputMarkupId(true);
        summaryLabel.setVisible(StringUtils.isNotBlank(summary));

        ExternalLink titleLink;
        if (displayURL.startsWith("file://")) {
            HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
            String newDisplayURL = ContextUrlUtils.getContextUrl(req) + "app/getSmbFile?"
                    + SmbServletPage.RECORD_ID + "=" + record.getId() + "&" + SmbServletPage.COLLECTION + "="
                    + collectionName;
            titleLink = new ExternalLink("titleLink", newDisplayURL);
        } else {
            titleLink = new ExternalLink("titleLink", displayURL);
        }

        final RecordModel recordModel = new RecordModel(record);
        AttributeModifier computeClickAttributeModifier = new AttributeModifier("onmousedown", true,
                new LoadableDetachableModel() {
                    @Override
                    protected Object load() {
                        Record record = recordModel.getObject();
                        SimpleSearch simpleSearch = dataProvider.getSimpleSearch();
                        WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
                        HttpServletRequest httpRequest = webRequest.getHttpServletRequest();
                        return ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch,
                                record);
                    }
                });
        titleLink.add(computeClickAttributeModifier);
        titleLink.setEnabled(linkEnabled);

        boolean resultsInNewWindow;
        PageParameters params = RequestCycle.get().getPageParameters();
        if (params != null && params.getString(POPUP_LINK) != null) {
            resultsInNewWindow = params.getBoolean(POPUP_LINK);
        } else {
            resultsInNewWindow = searchInterfaceConfig.isResultsInNewWindow();
        }
        titleLink.add(new SimpleAttributeModifier("target", resultsInNewWindow ? "_blank" : "_self"));

        // Add title
        title = StringUtils.remove(title, "\n");
        title = StringUtils.remove(title, "\r");
        if (StringUtils.isEmpty(title)) {
            title = StringUtils.defaultString(displayURL);
            title = StringUtils.substringAfterLast(title, "/");
            title = StringUtils.substringBefore(title, "?");
            try {
                title = URLDecoder.decode(title, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (title.length() > 120) {
                title = title.substring(0, 120) + " ...";
            }
        }

        Label titleLabel = new Label("title", title);
        titleLink.add(titleLabel.setEscapeModelStrings(false));
        add(titleLink);

        Label excerptLabel = new Label("excerpt", excerpt);
        add(excerptLabel.setEscapeModelStrings(false));
        // add(new ExternalLink("url", url,
        // url).add(computeClickAttributeModifier).setEnabled(linkEnabled));
        if (displayURL.startsWith("file://")) {
            // Creates a Windows path for file URLs
            String urlLabel = StringUtils.substringAfter(displayURL, "file:");
            urlLabel = StringUtils.stripStart(urlLabel, "/");
            urlLabel = "\\\\" + StringUtils.replace(urlLabel, "/", "\\");
            try {
                urlLabel = URLDecoder.decode(urlLabel, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            add(new Label("url", urlLabel));
        } else {
            add(new Label("url", displayURL));
        }

        final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>(
                collection);
        add(new ListView("searchResultFields", new LoadableDetachableModel() {
            @Override
            protected Object load() {
                RecordCollection collection = collectionModel.getObject();
                return collection.getSearchResultFields();
            }

            /**
             * Detaches from the current request. Implement this method with
             * custom behavior, such as setting the model object to null.
             */
            protected void onDetach() {
                recordModel.detach();
                collectionModel.detach();
            }
        }) {
            @Override
            protected void populateItem(ListItem item) {
                SearchResultField searchResultField = (SearchResultField) item.getModelObject();
                IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
                Record record = recordModel.getObject();
                IndexField indexField = searchResultField.getIndexField();
                Locale locale = getLocale();
                String indexFieldTitle = indexField.getTitle(locale);
                if (StringUtils.isBlank(indexFieldTitle)) {
                    indexFieldTitle = indexField.getName();
                }
                StringBuffer fieldValueSb = new StringBuffer();
                List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField);
                Map<String, String> defaultLabelledValues = indexFieldServices
                        .getDefaultLabelledValues(indexField, locale);
                for (Object fieldValue : fieldValues) {
                    if (fieldValueSb.length() > 0) {
                        fieldValueSb.append("\n");
                    }
                    String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale);
                    if (fieldValueLabel == null) {
                        fieldValueLabel = defaultLabelledValues.get("" + fieldValue);
                    }
                    if (fieldValueLabel == null) {
                        fieldValueLabel = "" + fieldValue;
                    }
                    fieldValueSb.append(fieldValueLabel);
                }

                item.add(new Label("indexField", indexFieldTitle));
                item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString()));
                item.setVisible(fieldValueSb.length() > 0);
            }

            @SuppressWarnings("unchecked")
            @Override
            public boolean isVisible() {
                boolean visible = super.isVisible();
                if (visible) {
                    List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject();
                    visible = !searchResultFields.isEmpty();
                }
                return visible;
            }
        });

        // md5
        ConstellioSession session = ConstellioSession.get();
        ConstellioUser user = session.getUser();
        // TODO Provide access to unauthenticated users ?
        String md5 = "";
        if (user != null) {
            IntelliGIDServiceInfo intelligidServiceInfo = ConstellioSpringUtils.getIntelliGIDServiceInfo();
            if (intelligidServiceInfo != null) {
                Collection<Object> md5Coll = doc.getFieldValues(IndexField.MD5);
                if (md5Coll != null) {
                    for (Object md5Obj : md5Coll) {
                        try {
                            String md5Str = new String(Hex.encodeHex(Base64.decodeBase64(md5Obj.toString())));
                            InputStream is = HttpClientHelper
                                    .get(intelligidServiceInfo.getIntelligidUrl() + "/connector/checksum",
                                            "md5=" + URLEncoder.encode(md5Str, "ISO-8859-1"),
                                            "username=" + URLEncoder.encode(user.getUsername(), "ISO-8859-1"),
                                            "password=" + URLEncoder.encode(Base64.encodeBase64String(
                                                    ConstellioSession.get().getPassword().getBytes())),
                                            "ISO-8859-1");
                            try {
                                Document xmlDocument = new SAXReader().read(is);
                                Element root = xmlDocument.getRootElement();
                                for (Iterator<Element> it = root.elementIterator("fichier"); it.hasNext();) {
                                    Element fichier = it.next();
                                    String url = fichier.attributeValue("url");
                                    md5 += "<a href=\"" + url + "\">" + url + "</a> ";
                                }
                            } finally {
                                IOUtils.closeQuietly(is);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
        Label md5Label = new Label("md5", md5) {
            public boolean isVisible() {
                boolean visible = super.isVisible();
                if (visible) {
                    visible = StringUtils.isNotBlank(this.getModelObjectAsString());
                }
                return visible;
            }
        };
        md5Label.setEscapeModelStrings(false);
        add(md5Label);

        add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch()));
    } else {
        setVisible(false);
    }
}

From source file:com.dotmarketing.viewtools.XmlTool.java

License:Apache License

/**
 * Reads, parses and creates a {@link Document} from the given {@link URL} and uses it as the root {@link Node} for
 * this instance./*  ww  w .j  av  a 2  s . com*/
 */
protected void read(URL url) throws Exception {
    SAXReader reader = new SAXReader();
    setRoot(reader.read(url));
}

From source file:com.dp2345.plugin.tenpayBank.TenpayBankPlugin.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//w  w  w .j  a v a2s . com
public boolean verifyNotify(String sn, NotifyMethod notifyMethod, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);
    if (generateSign(request.getParameterMap()).equals(request.getParameter("sign"))
            && pluginConfig.getAttribute("partner").equals(request.getParameter("partner"))
            && sn.equals(request.getParameter("out_trade_no"))
            && "0".equals(request.getParameter("trade_state"))
            && payment.getAmount().multiply(new BigDecimal(100))
                    .compareTo(new BigDecimal(request.getParameter("total_fee"))) == 0) {
        try {
            Map<String, Object> parameterMap = new HashMap<String, Object>();
            parameterMap.put("input_charset", "utf-8");
            parameterMap.put("sign_type", "MD5");
            parameterMap.put("partner", pluginConfig.getAttribute("partner"));
            parameterMap.put("notify_id", request.getParameter("notify_id"));
            String verifyUrl = "https://gw.tenpay.com/gateway/simpleverifynotifyid.xml?input_charset=utf-8&sign_type=MD5&partner="
                    + pluginConfig.getAttribute("partner") + "&notify_id=" + request.getParameter("notify_id")
                    + "&sign=" + generateSign(parameterMap);
            Document document = new SAXReader().read(new URL(verifyUrl));
            Node node = document.selectSingleNode("/root/retcode");
            if ("0".equals(node.getText().trim())) {
                return true;
            }
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
    return false;
}