Example usage for java.net URISyntaxException getMessage

List of usage examples for java.net URISyntaxException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns a string describing the parse error.

Usage

From source file:org.apache.jackrabbit.core.value.InternalValue.java

/**
 * Create a new internal value from the given JCR value.
 * If the data store is enabled, large binary values are stored in the data store.
 *
 * @param value the JCR value/*from w  w  w  .  j a  v a 2  s  .c  o  m*/
 * @param resolver
 * @param store the data store
 * @return the created internal value
 */
public static InternalValue create(Value value, NamePathResolver resolver, DataStore store)
        throws ValueFormatException, RepositoryException {
    switch (value.getType()) {
    case PropertyType.BINARY:
        InternalValue result;
        if (USE_DATA_STORE) {
            BLOBFileValue blob = null;
            if (value instanceof QValueValue) {
                QValueValue qvv = (QValueValue) value;
                QValue qv = qvv.getQValue();
                if (qv instanceof InternalValue) {
                    InternalValue iv = (InternalValue) qv;

                    iv.getBLOBFileValue();
                }
            }
            if (value instanceof BinaryValueImpl) {
                BinaryValueImpl bin = (BinaryValueImpl) value;
                DataIdentifier identifier = bin.getDataIdentifier();
                if (identifier != null) {
                    // access the record to ensure it is not garbage collected
                    if (store.getRecordIfStored(identifier) != null) {
                        // it exists - so we don't need to stream it again
                        // but we need to create a new object because the original
                        // one might be in a different data store (repository)
                        blob = BLOBInDataStore.getInstance(store, identifier);
                    }
                }
            }
            if (blob == null) {
                blob = getBLOBFileValue(store, value.getBinary().getStream(), true);
            }
            result = new InternalValue(blob);
        } else if (value instanceof BLOBFileValue) {
            result = new InternalValue((BLOBFileValue) value);
        } else {
            InputStream stream = value.getBinary().getStream();
            try {
                result = createTemporary(stream);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        }
        return result;
    case PropertyType.BOOLEAN:
        return create(value.getBoolean());
    case PropertyType.DATE:
        return create(value.getDate());
    case PropertyType.DOUBLE:
        return create(value.getDouble());
    case PropertyType.DECIMAL:
        return create(value.getDecimal());
    case PropertyType.LONG:
        return create(value.getLong());
    case PropertyType.REFERENCE:
        return create(new UUID(value.getString()));
    case PropertyType.WEAKREFERENCE:
        return create(new UUID(value.getString()), true);
    case PropertyType.URI:
        try {
            return create(new URI(value.getString()));
        } catch (URISyntaxException e) {
            throw new ValueFormatException(e.getMessage());
        }
    case PropertyType.NAME:
        try {
            if (value instanceof QValueValue) {
                QValue qv = ((QValueValue) value).getQValue();
                if (qv instanceof InternalValue) {
                    return (InternalValue) qv;
                } else {
                    return create(qv.getName());
                }
            } else {
                return create(resolver.getQName(value.getString()));
            }
        } catch (NameException e) {
            throw new ValueFormatException(e.getMessage());
        }
    case PropertyType.PATH:
        try {
            if (value instanceof QValueValue) {
                QValue qv = ((QValueValue) value).getQValue();
                if (qv instanceof InternalValue) {
                    return (InternalValue) qv;
                } else {
                    return create(qv.getPath());
                }
            } else {
                return create(resolver.getQPath(value.getString(), false));
            }
        } catch (MalformedPathException mpe) {
            throw new ValueFormatException(mpe.getMessage());
        }
    case PropertyType.STRING:
        return create(value.getString());
    default:
        throw new IllegalArgumentException("illegal value");
    }
}

From source file:eu.europa.cedefop.europass.jtool.util.SoftToolUtil.java

/**
 * This method is used to save the properties of the configuration file.
 * /*from  w  ww.jav a 2s . c  o  m*/
 * @param fldDatabasename the database name
 * @param fldPassword the database password     
 * @param fldURL the database URL
 * @param fldUsername the database username
 * @param sqlServer is SQL server?
 * @param mySQL is mySQL?
 * @param oracle is Oracle?
 * @return the logs of the saving
 */
public static String saveConfig(String fldDatabasename, String fldPassword, String fldURL, String fldUsername,
        boolean sqlServer, boolean mySQL, boolean oracle) {
    try {
        properties.setProperty("databasename", fldDatabasename);
        properties.setProperty("password", fldPassword);
        properties.setProperty("url", fldURL);
        properties.setProperty("username", fldUsername);
        if (sqlServer)
            properties.setProperty("default_database", "1");
        if (mySQL)
            properties.setProperty("default_database", "2");
        if (oracle)
            properties.setProperty("default_database", "3");
        try {
            properties.store(
                    new FileOutputStream(new File(
                            SoftToolUtil.class.getClassLoader().getResource("softtool.properties").toURI())),
                    null);
        } catch (URISyntaxException e) {
            return "Error: " + "(saving configurations to file) - " + e.getMessage();
        }
    } catch (IOException e) {
        return "Error: " + "(saving configurations to file) " + e.getMessage();
    }
    return null;
}

From source file:org.apache.jackrabbit.core.value.InternalValue.java

/**
 * Create a new internal value from the given JCR value.
 * If the data store is enabled, large binary values are stored in the data store.
 *
 * @param value the JCR value/*from w  w w.  jav  a 2 s.c o m*/
 * @param resolver
 * @param store the data store
 * @return the created internal value
 */
public static InternalValue create(Value value, NamePathResolver resolver, DataStore store)
        throws ValueFormatException, RepositoryException {
    switch (value.getType()) {
    case PropertyType.BINARY:
        InternalValue result;
        if (USE_DATA_STORE) {
            BLOBFileValue blob = null;
            if (value instanceof QValueValue) {
                QValueValue qvv = (QValueValue) value;
                QValue qv = qvv.getQValue();
                if (qv instanceof InternalValue) {
                    InternalValue iv = (InternalValue) qv;

                    iv.getBLOBFileValue();
                }
            }
            if (value instanceof BinaryValueImpl) {
                BinaryValueImpl bin = (BinaryValueImpl) value;
                DataIdentifier identifier = bin.getDataIdentifier();
                if (identifier != null) {
                    // access the record to ensure it is not garbage collected
                    if (store.getRecordIfStored(identifier) != null) {
                        // it exists - so we don't need to stream it again
                        // but we need to create a new object because the original
                        // one might be in a different data store (repository)
                        blob = BLOBInDataStore.getInstance(store, identifier);
                    }
                }
            }
            if (blob == null) {
                blob = getBLOBFileValue(store, value.getStream(), true);
            }
            result = new InternalValue(blob);
        } else if (value instanceof BLOBFileValue) {
            result = new InternalValue((BLOBFileValue) value);
        } else {
            InputStream stream = value.getStream();
            try {
                result = createTemporary(stream);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        }
        return result;
    case PropertyType.BOOLEAN:
        return create(value.getBoolean());
    case PropertyType.DATE:
        return create(value.getDate());
    case PropertyType.DOUBLE:
        return create(value.getDouble());
    case PropertyType.DECIMAL:
        return create(value.getDecimal());
    case PropertyType.LONG:
        return create(value.getLong());
    case PropertyType.REFERENCE:
        return create(new UUID(value.getString()));
    case PropertyType.WEAKREFERENCE:
        return create(new UUID(value.getString()), true);
    case PropertyType.URI:
        try {
            return create(new URI(value.getString()));
        } catch (URISyntaxException e) {
            throw new ValueFormatException(e.getMessage());
        }
    case PropertyType.NAME:
        try {
            if (value instanceof QValueValue) {
                QValue qv = ((QValueValue) value).getQValue();
                if (qv instanceof InternalValue) {
                    return (InternalValue) qv;
                } else {
                    return create(qv.getName());
                }
            } else {
                return create(resolver.getQName(value.getString()));
            }
        } catch (NameException e) {
            throw new ValueFormatException(e.getMessage());
        }
    case PropertyType.PATH:
        try {
            if (value instanceof QValueValue) {
                QValue qv = ((QValueValue) value).getQValue();
                if (qv instanceof InternalValue) {
                    return (InternalValue) qv;
                } else {
                    return create(qv.getPath());
                }
            } else {
                return create(resolver.getQPath(value.getString(), false));
            }
        } catch (MalformedPathException mpe) {
            throw new ValueFormatException(mpe.getMessage());
        }
    case PropertyType.STRING:
        return create(value.getString());
    default:
        throw new IllegalArgumentException("illegal value");
    }
}

From source file:com.aurel.track.lucene.LuceneUtil.java

/**
 * Gets the context path of the application
 * @return/*from w ww.  ja  v a  2  s . c  om*/
 */
public static String getContexPath() {
    URL url = null;
    File file;
    //get the application context path
    url = LuceneUtil.class.getResource("/../..");
    if (url == null) {
        return null;
    }
    if (url.getPath() != null) {
        file = new File(url.getPath());
        if (file.exists()) {
            return stripTrailingPathSeparator(url.getPath());
        }
    }
    //see Bug ID:  4466485 (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4466485) 
    URI uri = null;
    try {
        uri = new URI(url.toString());
    } catch (URISyntaxException e) {
        LOGGER.error("Getting the lucene index root URI from URL failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (uri == null) {
        return null;
    }
    //sometimes it is enough
    if (uri.getPath() != null) {
        file = new File(uri.getPath());
        if (file.exists()) {
            return stripTrailingPathSeparator(uri.getPath());
        }
    }

    try {
        url = uri.toURL();
    } catch (MalformedURLException e) {
    }
    if (url != null && url.getPath() != null) {
        file = new File(url.getPath());
        if (file.exists()) {
            return stripTrailingPathSeparator(url.getPath());
        }
    }
    return "";
}

From source file:eu.europa.ec.markt.dss.signature.xades.XAdESProfileBES.java

private static Reference createReference(Document document, DigestMethod digestMethod,
        XMLSignatureFactory sigFac, Integer index)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    String path, fragment;//  w  w  w.  java 2s  . com
    if (MimeType.XML.equals(document.getMimeType()) && document.getName() != null
            && document.getName().contains("#")) {
        path = document.getName().substring(0, document.getName().indexOf("#"));
        try {
            fragment = new URI(document.getName()).getFragment();
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    } else {
        path = document.getName();
        fragment = null;
    }

    List<Transform> transforms;
    if (MimeType.XML.equals(document.getMimeType())) {
        transforms = new ArrayList<Transform>();

        // Convert a # (fragment) within document name to element-id based Reference
        if (fragment != null) {
            // FIXME: this xpath should not be hardcoded
            String xpath = "ancestor-or-self::*[@ID=" + Utils.xPathLiteral(fragment) + "]";
            transforms
                    .add(sigFac.newTransform(Transforms.TRANSFORM_XPATH, new XPathFilterParameterSpec(xpath)));
        }

        // Canonicalize
        transforms.add(sigFac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE,
                (C14NMethodParameterSpec) null));
    } else {
        transforms = null;
    }

    return sigFac.newReference(path, digestMethod, transforms, null, index != null ? "ref-" + index : null);
}

From source file:org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl.java

private static UriInfoWithType parseUri(Edm edm, String resourcePath, Map<String, String> queryParams) {
    UriInfoWithType result;/*from w  w  w  .j av a2s .  c  o  m*/
    try {
        final List<PathSegment> pathSegments = new ArrayList<PathSegment>();
        final String[] segments = new URI(resourcePath).getPath().split(SEPARATOR);
        if (queryParams == null) {
            queryParams = Collections.emptyMap();
        }
        for (String segment : segments) {
            if (segment.indexOf(';') == -1) {

                pathSegments.add(new ODataPathSegmentImpl(segment, null));
            } else {

                // handle matrix params in path segment
                final String[] splitSegment = segment.split(";");
                segment = splitSegment[0];

                Map<String, List<String>> matrixParams = new HashMap<String, List<String>>();
                for (int i = 1; i < splitSegment.length; i++) {
                    final String[] param = splitSegment[i].split("=");
                    List<String> values = matrixParams.get(param[0]);
                    if (values == null) {
                        values = new ArrayList<String>();
                        matrixParams.put(param[0], values);
                    }
                    if (param[1].indexOf(',') == -1) {
                        values.add(param[1]);
                    } else {
                        values.addAll(Arrays.asList(param[1].split(",")));
                    }
                }
                pathSegments.add(new ODataPathSegmentImpl(segment, matrixParams));
            }
        }
        result = new UriInfoWithType(UriParser.parse(edm, pathSegments, queryParams), resourcePath);
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("resourcePath: " + e.getMessage(), e);
    } catch (ODataException e) {
        throw new IllegalArgumentException("resourcePath: " + e.getMessage(), e);
    }

    return result;
}

From source file:com.macrossx.wechat.impl.WechatMessageHelper.java

@Override
public Optional<WecahtMessageTemplateRespObj> sendTemplate(WechatMessageTemplate template) {
    try {/*from www  . ja  va2 s  .c o m*/
        Optional<WechatAccessToken> token = wechatHelper.getAccessToken();
        if (token.isPresent()) {
            WechatAccessToken accessToken = token.get();
            HttpPost httpPost = new HttpPost();
            System.out.println(new Gson().toJson(template));
            httpPost.setEntity(new StringEntity(new Gson().toJson(template), "utf-8"));
            httpPost.setURI(new URI(MessageFormat.format(WechatConstants.MESSAGE_TEMPLATE_SEND_URL,
                    accessToken.getAccess_token())));
            return new WechatHttpClient().send(httpPost, WecahtMessageTemplateRespObj.class);
        }
    } catch (URISyntaxException e) {
        log.info(e.getMessage());
    }
    return Optional.empty();
}

From source file:org.osiam.resources.converter.PhotoConverter.java

@Override
public Photo toScim(PhotoEntity entity) {
    Photo scimPhoto;//from   w ww  . ja  va2s .c o m

    try {
        scimPhoto = new Photo.Builder().setType(entity.getType()).setValue(new URI(entity.getValue()))
                .setPrimary(entity.isPrimary()).build();
    } catch (URISyntaxException e) {
        throw new OsiamException(e.getMessage(), e);
    }
    return scimPhoto;
}

From source file:com.macrossx.wechat.impl.WechatHelper.java

/**
 * {@code _token_time}<tokentoken(7200-60)
 *//*  w  w w .j  a  va  2 s  . c o m*/
public Optional<WechatAccessToken> getAccessToken() {
    try {
        if (System.currentTimeMillis() < _token_time) {
            return Optional.of(_access_token);
        }
        long current = System.currentTimeMillis();
        HttpGet httpGet = new HttpGet();
        httpGet.setURI(new URI(MessageFormat.format(WechatConstants.ACCESS_TOKEN_URL, appid, appsecret)));
        return new WechatHttpClient().send(httpGet, WechatAccessToken.class).map((e) -> {
            _access_token = e;
            _token_time = current + _access_token.getExpires_in() - 60;
            return _access_token;
        });
    } catch (URISyntaxException e) {
        log.info(e.getMessage());
        return Optional.empty();
    }

}

From source file:no.digipost.api.useragreements.client.filters.request.RequestToSign.java

public String getPath() {
    try {/*from   w w  w. j av  a 2  s.c  o  m*/
        String path = new URI(clientRequest.getRequestLine().getUri()).getPath();
        return path != null ? path : "";
    } catch (URISyntaxException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}