Example usage for java.net URISyntaxException printStackTrace

List of usage examples for java.net URISyntaxException printStackTrace

Introduction

In this page you can find the example usage for java.net URISyntaxException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:se.vgregion.portal.iframe.controller.CSViewController.java

/**
 * Prepare proxyLoginForm.jsp for form-based authentication.
 * //  w  w  w .  j  a  va 2  s  .  c o m
 * @param model
 *            model
 * @param req
 *            request
 * @param prefs
 *            portlet preferences
 * @param postLogin
 *            postLogin url
 * @return proxyLoginForm
 * @throws URISyntaxException
 */
@ResourceMapping
public String showProxyForm(PortletPreferences prefs, ResourceRequest req, ModelMap model,
        @ModelAttribute("postLogin") String postLogin) {

    PortletConfig portletConfig = PortletConfig.getInstance(prefs);
    model.addAttribute("portletConfig", portletConfig);
    if (!portletConfig.isAuth()) {
        return "view";
    }

    String userId = lookupUid(req);

    if (portletConfig.isInotesUltralight()) {
        // We happen to know that we are going to need to make a call to get the user's mail server from ldap
        // later
        // in this method or rather in a method called by this method. We also know that the LdapService is an
        // AsyncCachingLdapServiceWrapper. Making a call now will speed up the experience for the user.
        ldapService.getLdapUserByUid(userId);
    }

    // 1: Credentials
    SiteKey siteKey = credentialService.getSiteKey(portletConfig.getSiteKey());
    model.addAttribute("siteKey", siteKey);

    UserSiteCredential siteCredential = new UserSiteCredential();
    credentialsAvailable(req, model, portletConfig, siteCredential, siteKey);

    // 2: postLogin
    if (postLogin != null && postLogin.length() > 0) {
        model.addAttribute("postLoginLink", true);
    }

    // 3: Dynamic Field
    if (StringUtils.isNotBlank(portletConfig.getDynamicField())) {
        Map<String, String> dynamicFieldValues = lookupDynamicValue(portletConfig);
        model.addAttribute("dynamicFieldValues", dynamicFieldValues);
    }

    // 4: RD encode
    if (portletConfig.isRdEncode()) {
        model.addAttribute("rdPass", encodeRaindancePassword(userId, portletConfig));
    }

    if (portletConfig.isInotesUltralight()) {
        // Then we place a dynamic url (including the userId) in the hiddenVariablesMap.
        Map<String, String> hiddenVariablesMap = new HashMap<String, String>();
        hiddenVariablesMap.put("RedirectTo", String.format(INOTES_ULTRALIGHT_REDIRECT_TO_URL,
                credentialService.getUserSiteCredential(userId, portletConfig.getSiteKey()).getSiteUser()));
        model.addAttribute("hiddenVariablesMap", hiddenVariablesMap);
    } else {
        model.addAttribute("hiddenVariablesMap", portletConfig.getHiddenVariablesMap());
    }

    URI src = null;
    try {
        String srcUrl = portletConfig.getSrc();
        srcUrl = replacePlaceholders(userId, srcUrl);
        src = new URI(srcUrl);

        String proxyAction;
        if (portletConfig.getFormAction() == null || portletConfig.getFormAction().length() < 1) {
            proxyAction = src.toString();
        } else {
            proxyAction = src.resolve(portletConfig.getFormAction()).toString();
        }

        if ("basic".equals(portletConfig.getAuthType())) {
            proxyAction = prepareBasicAuthAction(siteCredential, proxyAction);
        }

        model.addAttribute("proxyAction", proxyAction);
        debug(req, proxyAction);

        return "proxyLoginForm";
    } catch (URISyntaxException e) {
        e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates.
        return "help";
    }

}

From source file:com.vobject.appengine.java.io.File.java

public URI toURI() {
    URI uri = null;/* w ww  .  j ava2  s.c o  m*/

    try {
        uri = new URI(file.getName().getURI());
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return uri;
}

From source file:org.hfoss.posit.web.Communicator.java

/**
 * Sends a HttpPost request to the given URL. Any JSON 
 * @param Uri the URL to send to/receive from
 * @param sendMap the hashMap of data to send to the server as POST data
 * @return the response from the URL/*ww w  . j  a  v  a2 s  .co  m*/
 */
private String doHTTPPost(String Uri, HashMap<String, String> sendMap) {

    if (Uri == null)
        throw new NullPointerException("The URL has to be passed");
    String responseString = null;
    HttpPost post = new HttpPost();
    if (Utils.debug)
        Log.i(TAG, "doHTTPPost() URI = " + Uri);
    try {
        post.setURI(new URI(Uri));
    } catch (URISyntaxException e) {
        Log.e(TAG, "URISyntaxException " + e.getMessage());
        e.printStackTrace();
        return e.getMessage();
    }
    List<NameValuePair> nvp = PositHttpUtils.getNameValuePairs(sendMap);
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    try {
        post.setEntity(new UrlEncodedFormEntity(nvp, HTTP.UTF_8));
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "UnsupportedEncodingException " + e.getMessage());
    }
    mStart = System.currentTimeMillis();

    try {
        responseString = mHttpClient.execute(post, responseHandler);
    } catch (ClientProtocolException e) {
        Log.e(TAG, "ClientProtocolExcpetion" + e.getMessage());
        e.printStackTrace();
        return e.getMessage();
    } catch (IOException e) {
        Log.e(TAG, "IOException " + e.getMessage());
        e.printStackTrace();
        return e.getMessage();
    } catch (IllegalStateException e) {
        Log.e(TAG, "IllegalStateException: " + e.getMessage());
        e.printStackTrace();
        return e.getMessage();
    } catch (Exception e) {
        Log.e(TAG, "Exception on HttpPost " + e.getMessage());
        e.printStackTrace();
        return e.getMessage();
    }
    long time = System.currentTimeMillis() - mStart;
    mTotalTime += time;
    Log.i(TAG, "TIME = " + time + " millisecs");

    return responseString;
}

From source file:com.ximai.savingsmore.save.activity.FourStepRegisterActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode != RESULT_OK) {
        return;/* ww w .  j av  a2 s.c  om*/
    } else if (requestCode == PICK_FROM_CAMERA || requestCode == PICK_FROM_IMAGE) {

        Uri uri = null;
        if (null != intent && intent.getData() != null) {
            uri = intent.getData();
        } else {
            String fileName = PreferencesUtils.getString(this, "tempName");
            uri = Uri.fromFile(new File(FileSystem.getCachesDir(this, true).getAbsolutePath(), fileName));
        }

        if (uri != null) {
            cropImage(uri, CROP_PHOTO_CODE);
        }
    } else if (requestCode == CROP_PHOTO_CODE) {
        Uri photoUri = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);
        if (isslinece) {
            MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), slience_image);
            zhizhao_path = photoUri.toString();
            try {
                upLoadImage(new File((new URI(photoUri.toString()))), "BusinessLicense");
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
        } else if (isZhengshu) {
            MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), zhengshu_iamge);
            xukezheng_path = photoUri.toString();
            try {
                upLoadImage(new File((new URI(photoUri.toString()))), "LicenseKey");
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }

            //upLoadImage(new File((new URI(photoUri.toString()))), "Photo");
        } else if (isItem) {
            if (images.size() < 10) {
                shangpu_path.add(photoUri.toString());
                try {
                    upLoadImage(new File((new URI(photoUri.toString()))), "Seller");
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(FourStepRegisterActivity.this, "?9",
                        Toast.LENGTH_SHORT).show();
            }
        }
        //addImage(imagePath);
    }
}

From source file:eu.planets_project.tb.impl.services.mockups.workflow.MigrateWorkflow.java

/**
 * Takes a Property that's used in Planets level-one service call results
 * and converts it into the Testbed's Property model element: MeasurementImpl
 * @param p eu.planets_project.services.datatypes.Property
 * @return/*w  w w .j a va  2s. c  om*/
 */
private MeasurementImpl createMeasurementFromProperty(Property p) {
    MeasurementImpl m = new MeasurementImpl();

    if (p == null)
        return m;

    URI propURI = p.getUri();
    // Invent a uri if required:
    if (propURI == null) {
        try {
            propURI = new URI(TecRegMockup.URI_XCDL_PROP_ROOT + p.getName());
        } catch (URISyntaxException e) {
            e.printStackTrace();
            return m;
        }
        // Rebuild the property:
        p = new Property.Builder(propURI).name(p.getName()).description(p.getDescription()).type(p.getType())
                .unit(p.getUnit()).value(p.getValue()).build();
    }

    // Copy in:
    m.setProperty(p);
    m.getTarget().setType(MeasurementTarget.TargetType.DIGITAL_OBJECT);
    m.setValue(p.getValue());

    return m;
}

From source file:eu.planets_project.tb.impl.services.mockups.workflow.MigrateWorkflow.java

/**
 * Creates a list of MeasurementImpl for the requested format and Characterise service.
 * Properties are requested from the service's .listProperties(puid) method. 
 * @param format/*  w  ww.ja v  a  2  s.  co m*/
 * @param dp
 * @return
 */
private List<MeasurementImpl> getMeasurementsForFormat(String format, Characterise dp) {
    List<MeasurementImpl> lm = new Vector<MeasurementImpl>();

    HashMap<URI, MeasurementImpl> meas = new HashMap<URI, MeasurementImpl>();
    URI formatURI;
    if (format == null) {
        log.error("Format was set to NULL.");
        return lm;
    }
    try {
        formatURI = new URI(format);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return lm;
    }
    if (dp == null) {
        return lm;
    }
    // Find all the PRONOM IDs for this format URI:
    for (URI puid : this.getPronomURIAliases(formatURI)) {
        List<Property> measurableProperties = dp.listProperties(puid);
        if (measurableProperties != null) {
            for (Property p : measurableProperties) {
                MeasurementImpl m = this.createMeasurementFromProperty(p);
                if (!meas.containsKey(m.getIdentifier())) {
                    meas.put(m.getIdentifierUri(), m);
                }
            }
        }
    }

    lm = new Vector<MeasurementImpl>(meas.values());
    //Collections.sort( lm );
    return lm;
}

From source file:org.kepler.actor.rest.RESTService.java

/**
 *
 * @param val/* w w  w. j  a  v a2  s .c o m*/
 * @return the File object for the supplied String
 */
private File getFileObject(String val) throws IllegalActionException {
    if (val.startsWith("file:")) {

        URI uri = null;
        try {
            uri = new URI(val);
        } catch (URISyntaxException synE) {
            synE.printStackTrace();
            throw new IllegalActionException(this, synE, "Error: " + synE.getMessage());
        }
        return new File(uri);
    } else {
        return new File(val);
    }
}

From source file:org.krakenapps.pkg.PackageManagerService.java

private byte[] download(PackageRepository repo, URL url)
        throws IOException, KeyStoreException, UnrecoverableKeyException, KeyManagementException {
    if (repo.isLocalFilesystem()) {
        try {//from   w w w  . j  av  a 2  s  . c om
            File file = new File(url.toURI());
            long length = file.length();
            FileInputStream stream = new FileInputStream(file);
            byte[] b = new byte[(int) length];
            stream.read(b);
            return b;
        } catch (URISyntaxException e) {
            e.printStackTrace();
            return new byte[0];
        }
    } else if (repo.isHttps()) {
        ServiceReference ref = bc.getServiceReference(KeyStoreManager.class.getName());
        KeyStoreManager keyman = (KeyStoreManager) bc.getService(ref);
        try {
            TrustManagerFactory tmf = keyman.getTrustManagerFactory(repo.getTrustStoreAlias(), "SunX509");
            KeyManagerFactory kmf = keyman.getKeyManagerFactory(repo.getKeyStoreAlias(), "SunX509");
            HttpWagon.download(url, tmf, kmf);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return HttpWagon.download(url);
    } else if (repo.isAuthRequired())
        return HttpWagon.download(url, true, repo.getAccount(), repo.getPassword());
    return HttpWagon.download(url);
}

From source file:org.krakenapps.pkg.PackageManagerService.java

private String downloadString(PackageRepository repo, URL url)
        throws IOException, KeyStoreException, UnrecoverableKeyException, KeyManagementException {
    if (repo.isLocalFilesystem()) {
        try {/*from  w w w .j a  va2 s .c  om*/
            File file = new File(url.toURI());
            long length = file.length();
            FileInputStream stream = new FileInputStream(file);
            byte[] b = new byte[(int) length];
            stream.read(b);
            return new String(b, Charset.forName("UTF-8"));
        } catch (URISyntaxException e) {
            e.printStackTrace();
            return new String();
        }
    } else if (repo.isHttps()) {
        ServiceReference ref = bc.getServiceReference(KeyStoreManager.class.getName());
        KeyStoreManager keyman = (KeyStoreManager) bc.getService(ref);
        try {
            TrustManagerFactory tmf = keyman.getTrustManagerFactory(repo.getTrustStoreAlias(), "SunX509");
            KeyManagerFactory kmf = keyman.getKeyManagerFactory(repo.getKeyStoreAlias(), "SunX509");
            HttpWagon.download(url, tmf, kmf);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return HttpWagon.downloadString(url);
    } else if (repo.isAuthRequired())
        return HttpWagon.downloadString(url, repo.getAccount(), repo.getPassword());
    return HttpWagon.downloadString(url);
}

From source file:org.rdv.ui.channel.LocalChannelDialog.java

private JPanel buildFooterPanel() {
    JPanel footerPanel = new JPanel();

    if (isChannelAddOperation()) {
        channelActionButton.setName("addChannelButton");
        channelActionButton.setText(PROPERTY_REPO.getValue(ADD_CHANNEL_BUTTON_KEY));
    } else { // channel exists
        channelActionButton.setName("saveChannelButton");
        channelActionButton.setText(PROPERTY_REPO.getValue(SAVE_CHANNEL_BUTTON_KEY));
    }//  w w w.j  a v  a 2 s  . c o m
    channelActionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isChannelAddOperation()) {
                addChannel();
            } else {
                updateChannel();
            }
        }
    });
    footerPanel.add(channelActionButton);

    JButton cancelButton = new JButton();
    cancelButton.setName("cancelButton");
    cancelButton.setText(PROPERTY_REPO.getValue(CANCEL_BUTTON_KEY));
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    });
    footerPanel.add(cancelButton);
    helpButton.setText(PROPERTY_REPO.getValue(HELP_BUTTON_KEY));
    helpButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Browser.open(getOwner(), new URI(PROPERTY_REPO.getValue(ADD_CHANNEL_DOC_KEY)));
            } catch (URISyntaxException e1) {
                LOGGER.error("", e1);
                e1.printStackTrace();
            }
        }
    });
    footerPanel.add(helpButton);
    return footerPanel;
}