Package java.net

Examples of java.net.URLConnection$DefaultContentHandler


        String version = request.getParameter("version");
        PolicyUtil.checkPermission(PolicyConstants.EXTENSIONS_RESOURCE_TYPE,
            PolicyConstants.PERM_CHANGE,
            getSessionInfo(request).getUser());
        ActionForward fwd = new RedirectWithMessages(mapping.findForward("refresh"), request);
        URLConnection con = ExtensionStore.getInstance().downloadExtension(id, version);
       
        try {
            InputStream in = con.getInputStream();           
            ExtensionBundle bundle = ExtensionStore.getInstance().installExtensionFromStore(id, in, request, con.getContentLength());
            ExtensionStore.getInstance().licenseCheck(bundle, request, fwd);
            ExtensionStore.getInstance().postInstallExtension(bundle, request);
            ActionMessages msgs = new ActionMessages();
            msgs.add(Globals.MESSAGE_KEY, new ActionMessage("extensionStore.message.applicationInstalled", bundle.getName()));
            saveMessages(request, msgs);
View Full Code Here


        String id = request.getParameter("id");
        String version = request.getParameter("version");
        PolicyUtil.checkPermission(PolicyConstants.EXTENSIONS_RESOURCE_TYPE,
            PolicyConstants.PERM_CHANGE,
            getSessionInfo(request).getUser());
        URLConnection con = ExtensionStore.getInstance().downloadExtension(id, version);
        try {
            InputStream in = con.getInputStream();           
            ExtensionBundle bundle = ExtensionStore.getInstance().updateExtension(id, in, request, con.getContentLength());
            if (bundle.isContainsPlugin())
              GlobalWarningManager.getInstance().addMultipleGlobalWarning(new GlobalWarning(GlobalWarning.MANAGEMENT_USERS, new BundleActionMessage("extensions",
                                "extensionStore.message.extensionUpdatedRestartRequired"), DismissType.DISMISS_FOR_USER));
            ActionMessages msgs = new ActionMessages();
            msgs.add(Globals.MESSAGE_KEY, new ActionMessage("extensionStore.message.applicationUpdated", bundle.getName()));
View Full Code Here

            HttpsURLStreamHandlerFactory.addHTTPSSupport();

            URL url = new URL("https://localhost"); //$NON-NLS-1$

            URLConnection con = url.openConnection();
            con.setDoInput(true);
            con.setDoOutput(false);
            con.setAllowUserInteraction(false);

            con.setRequestProperty("Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*"); //$NON-NLS-1$ //$NON-NLS-2$
            con.setRequestProperty("Accept-Encoding", "gzip, deflate"); //$NON-NLS-1$ //$NON-NLS-2$
            con.setRequestProperty("Accept-Language", "en-gb"); //$NON-NLS-1$ //$NON-NLS-2$
            con.setRequestProperty("Connection", "Keep-Alive"); //$NON-NLS-1$ //$NON-NLS-2$
            con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"); //$NON-NLS-1$ //$NON-NLS-2$

            con.connect();

            InputStream in = con.getInputStream();
            int read;

            while ((read = in.read()) > -1) {
                System.out.write(read);
            }
View Full Code Here

                urlString.append(dirnameOption.getUncommitedValue());
                urlString.append("/");
                URL url = null;
                try {
                    url = new URL(urlString.toString() + "test.txt");
                    URLConnection urlc = url.openConnection();
                    OutputStream os = urlc.getOutputStream();
                    os.write(("This is GanttProject +++ I was here!")
                            .getBytes());
                    os.close();
                    JOptionPane.showMessageDialog(optionsPane, GanttLanguage
                            .getInstance().getText("successFTPConnection"),
View Full Code Here

            @Override
            public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control) throws Exception {
                response.cookie(new HttpCookie("a", "b")).end();
            }
        }).start();
        URLConnection urlConnection = httpGet(webServer, "/");
        List<HttpCookie> cookies = cookies(urlConnection);
        assertEquals(1, cookies.size());
        assertEquals("a", cookies.get(0).getName());
        assertEquals("b", cookies.get(0).getValue());
    }
View Full Code Here

            @Override
            public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control) throws Exception {
                response.cookie(new HttpCookie("a", "b")).cookie(new HttpCookie("c", "d")).end();
            }
        }).start();
        URLConnection urlConnection = httpGet(webServer, "/");
        List<HttpCookie> cookies = cookies(urlConnection);
        assertEquals(2, cookies.size());
        assertEquals("a", cookies.get(0).getName());
        assertEquals("b", cookies.get(0).getValue());
        assertEquals("c", cookies.get(1).getName());
View Full Code Here

                response.header("Content-Length", body.length())
                        .content(body)
                        .end();
            }
        }).start();
        URLConnection urlConnection = httpGet(webServer, "/");
        urlConnection.addRequestProperty("Cookie", new HttpCookie("someName", "someValue").toString());
        assertEquals("Your cookie value: someValue", contents(urlConnection));
    }
View Full Code Here

                response.header("Content-Length", body.length())
                        .content(body)
                        .end();
            }
        }).start();
        URLConnection urlConnection = httpGet(webServer, "/");
        urlConnection.addRequestProperty("Cookie", new HttpCookie("a", "b").toString());
        urlConnection.addRequestProperty("Cookie", new HttpCookie("c", "\"d").toString() + "; " + new HttpCookie("e", "f").toString());
        assertEquals("Your cookies: a=b c=\"d e=f", contents(urlConnection));
    }
View Full Code Here

                response.header("Content-Length", body.length())
                        .content(body)
                        .end();
            }
        }).start();
        URLConnection urlConnection = httpGet(webServer, "/");
        assertEquals("Cookie count:0", contents(urlConnection));
    }
View Full Code Here

    }
    if (url == null) {
      throw new ContainerException(400, "Invalid URL: "+pathinfo);
    }   
    try {
      URLConnection conn = url.openConnection();
      conn.connect();
      if (conn instanceof HttpURLConnection) {
        int code = ((HttpURLConnection)conn).getResponseCode();
        if (code != 200) {
          throw new ContainerException(code, "Resource: "+url);
        }
View Full Code Here

TOP

Related Classes of java.net.URLConnection$DefaultContentHandler

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.