Search in sources :

Example 11 with GenericRuntimeException

use of com.openmeap.util.GenericRuntimeException in project OpenMEAP by OpenMEAP.

the class JsError method toJSONObject.

public JSONObject toJSONObject() {
    JSONObject err = new JSONObject();
    try {
        err.put("type", type);
        err.put("message", message);
    } catch (JSONException e) {
        throw new GenericRuntimeException(e);
    }
    return err;
}
Also used : JSONObject(com.openmeap.thirdparty.org.json.me.JSONObject) JSONException(com.openmeap.thirdparty.org.json.me.JSONException) GenericRuntimeException(com.openmeap.util.GenericRuntimeException)

Example 12 with GenericRuntimeException

use of com.openmeap.util.GenericRuntimeException in project OpenMEAP by OpenMEAP.

the class ApplicationArchive method substituteArchiveVariables.

@Transient
private String substituteArchiveVariables(GlobalSettings settings, String url) {
    String externalServiceUrlPrefix = settings.getExternalServiceUrlPrefix();
    String authSalt = this.getApplication().getProxyAuthSalt();
    String newAuthToken;
    try {
        newAuthToken = AuthTokenProvider.newAuthToken(authSalt != null ? authSalt : "");
    } catch (DigestException e) {
        throw new GenericRuntimeException(e);
    }
    String replUrl = url;
    try {
        // TODO: replace these with constants
        replUrl = replUrl.replace("${globalSettings.externalServiceUrlPrefix}", externalServiceUrlPrefix != null ? externalServiceUrlPrefix : "");
        replUrl = replUrl.replace("${appName}", URLEncoder.encode(getApplication().getName(), FormConstants.CHAR_ENC_DEFAULT));
        replUrl = replUrl.replace("${newAuthToken}", URLEncoder.encode(newAuthToken, FormConstants.CHAR_ENC_DEFAULT));
        replUrl = replUrl.replace("${hash}", URLEncoder.encode(hash, FormConstants.CHAR_ENC_DEFAULT));
        replUrl = replUrl.replace("${hashAlgorithm}", URLEncoder.encode(hashAlgorithm, FormConstants.CHAR_ENC_DEFAULT));
    } catch (UnsupportedEncodingException uee) {
        logger.error("Exception thrown encoding url parameters for url: {}", uee);
    }
    return replUrl;
}
Also used : DigestException(com.openmeap.digest.DigestException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) GenericRuntimeException(com.openmeap.util.GenericRuntimeException)

Aggregations

GenericRuntimeException (com.openmeap.util.GenericRuntimeException)12 DigestException (com.openmeap.digest.DigestException)5 IOException (java.io.IOException)5 GlobalSettings (com.openmeap.model.dto.GlobalSettings)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 InputStream (java.io.InputStream)3 OutputStream (java.io.OutputStream)3 Application (com.openmeap.model.dto.Application)2 ApplicationArchive (com.openmeap.model.dto.ApplicationArchive)2 UpdateHeader (com.openmeap.protocol.dto.UpdateHeader)2 LocalStorageException (com.openmeap.thinclient.LocalStorageException)2 UpdateException (com.openmeap.thinclient.update.UpdateException)2 JSONException (com.openmeap.thirdparty.org.json.me.JSONException)2 JSONObject (com.openmeap.thirdparty.org.json.me.JSONObject)2 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 FileNameMap (java.net.FileNameMap)2 HttpRequestException (com.openmeap.http.HttpRequestException)1 ModelManager (com.openmeap.model.ModelManager)1