Example usage for com.google.gson.internal LinkedTreeMap get

List of usage examples for com.google.gson.internal LinkedTreeMap get

Introduction

In this page you can find the example usage for com.google.gson.internal LinkedTreeMap get.

Prototype

@Override
    public V get(Object key) 

Source Link

Usage

From source file:org.cgiar.ccafs.marlo.action.center.json.autosave.AutoSaveWriterAction.java

License:Open Source License

@Override
public String execute() throws Exception {

    String fileId = "";
    String fileClass = "";
    String nameClass = "";
    String fileAction = "";

    status = new HashMap<String, Object>();

    if (autoSave.length > 0) {

        Gson gson = new Gson();
        byte ptext[] = autoSave[0].getBytes(ISO_8859_1);
        String value = new String(ptext, UTF_8);

        @SuppressWarnings("unchecked")

        LinkedTreeMap<String, Object> result = gson.fromJson(value, LinkedTreeMap.class);

        String userModifiedBy = fileId = (String) result.get("modifiedBy.id");
        if (result.containsKey("id")) {
            fileId = (String) result.get("id");
        } else {//from   w  ww  .j  av a 2 s . com
            fileId = "XX";
        }

        if (result.containsKey("className")) {
            String ClassName = (String) result.get("className");
            String[] composedClassName = ClassName.split("\\.");
            nameClass = ClassName;
            fileClass = composedClassName[composedClassName.length - 1];
        }

        if (result.containsKey("actionName")) {
            fileAction = (String) result.get("actionName");
            fileAction = fileAction.replace("/", "_");
        }
        ArrayList<String> keysRemove = new ArrayList<>();

        for (Map.Entry<String, Object> entry : result.entrySet()) {
            if (entry.getKey().contains("__")) {
                keysRemove.add(entry.getKey());
            }
        }
        for (String string : keysRemove) {
            result.remove(string);
        }
        Date generatedDate = new Date();
        result.put("activeSince", generatedDate);

        String jSon = gson.toJson(result);

        if (nameClass.equals(CenterOutcome.class.getName())) {
            jSon = jSon.replaceAll("outcome\\.", "");
        }
        if (nameClass.equals(CenterOutput.class.getName())) {
            jSon = jSon.replaceAll("output\\.", "");
        }
        if (nameClass.equals(CenterProject.class.getName())) {
            jSon = jSon.replaceAll("project\\.", "");
        }
        if (nameClass.equals(CenterDeliverable.class.getName())) {
            jSon = jSon.replaceAll("deliverable\\.", "");
        }
        if (nameClass.equals(CapacityDevelopment.class.getName())) {
            jSon = jSon.replaceAll("capdev\\.", "");
        }

        try {

            String fileName = fileId + "_" + fileClass + "_" + fileAction + ".json";
            String pathFile = config.getAutoSaveFolder();
            Path path = Paths.get(pathFile);

            if (Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {
                File file = new File(config.getAutoSaveFolder() + fileName);
                Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8"));
                out.append(jSon).append("\r\n");
                ;

                out.flush();
                out.close();
            } else {
                Files.createDirectories(path);
                File file = new File(config.getAutoSaveFolder() + fileName);
                Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8"));
                out.append(jSon).append("\r\n");
                ;

                out.flush();
                out.close();
            }
            status.put("status", true);
            SimpleDateFormat dt = new SimpleDateFormat("yyyyy-mm-dd hh:mm:ss");
            status.put("modifiedBy",
                    userService.getUser(Long.parseLong(userModifiedBy)).getComposedCompleteName());
            status.put("activeSince", dt.format(generatedDate));
        } catch (IOException e) {
            status.put("status", false);
            e.printStackTrace();
        } catch (Exception e) {
            status.put("status", false);
            e.printStackTrace();
        }

    }

    return Action.SUCCESS;
}

From source file:org.cgiar.ccafs.marlo.action.json.autosave.AutoSaveWriterAction.java

License:Open Source License

@Override
public String execute() throws Exception {

    String fileId = "";
    String fileClass = "";
    String nameClass = "";
    String fileAction = "";

    status = new HashMap<String, Object>();

    if (autoSave.length > 0) {

        Gson gson = new Gson();
        byte ptext[] = autoSave[0].getBytes(ISO_8859_1);
        String value = new String(ptext, UTF_8);

        @SuppressWarnings("unchecked")

        LinkedTreeMap<String, Object> result = gson.fromJson(value, LinkedTreeMap.class);

        String userModifiedBy = fileId = (String) result.get("modifiedBy.id");
        if (result.containsKey("id")) {
            fileId = (String) result.get("id");
        } else {/*from   w  ww .  j a v a  2 s.c  o m*/
            fileId = "XX";
        }

        if (result.containsKey("className")) {
            String ClassName = (String) result.get("className");
            String[] composedClassName = ClassName.split("\\.");
            nameClass = ClassName;
            fileClass = composedClassName[composedClassName.length - 1];
        }

        if (result.containsKey("actionName")) {
            fileAction = (String) result.get("actionName");
            fileAction = fileAction.replace("/", "_");
        }
        ArrayList<String> keysRemove = new ArrayList<>();

        for (Map.Entry<String, Object> entry : result.entrySet()) {
            if (entry.getKey().contains("__")) {
                keysRemove.add(entry.getKey());
            }
        }
        for (String string : keysRemove) {
            result.remove(string);
        }
        Date generatedDate = new Date();
        result.put("activeSince", generatedDate);

        String jSon = gson.toJson(result);

        if (nameClass.equals(ResearchOutcome.class.getName())) {
            jSon = jSon.replaceAll("outcome\\.", "");
        }
        if (nameClass.equals(ResearchOutput.class.getName())) {
            jSon = jSon.replaceAll("output\\.", "");
        }

        try {

            String fileName = fileId + "_" + fileClass + "_" + fileAction + ".json";
            String pathFile = config.getAutoSaveFolder();
            System.out.println(pathFile);
            Path path = Paths.get(pathFile);

            if (Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {
                File file = new File(config.getAutoSaveFolder() + fileName);
                Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8"));
                out.append(jSon).append("\r\n");
                ;

                out.flush();
                out.close();
            } else {
                Files.createDirectories(path);
                File file = new File(config.getAutoSaveFolder() + fileName);
                Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8"));
                out.append(jSon).append("\r\n");
                ;

                out.flush();
                out.close();
            }
            status.put("status", true);
            SimpleDateFormat dt = new SimpleDateFormat("yyyyy-mm-dd hh:mm:ss");
            status.put("modifiedBy",
                    userService.getUser(Long.parseLong(userModifiedBy)).getComposedCompleteName());
            status.put("activeSince", dt.format(generatedDate));
        } catch (IOException e) {
            status.put("status", false);
            e.printStackTrace();
        } catch (Exception e) {
            status.put("status", false);
            e.printStackTrace();
        }

    }

    return Action.SUCCESS;
}

From source file:org.ff4j.elastic.FeatureConverter.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override//from w w  w.j  ava 2 s  . c  o  m
public Feature deserialize(JsonElement json, Type type, JsonDeserializationContext context) {

    String uid = json.getAsJsonObject().get("uid").getAsString();

    Feature feature = new Feature(uid);

    // Property "enable"
    JsonElement enable = json.getAsJsonObject().get("enable");
    if (enable != null) {
        feature.setEnable(enable.getAsBoolean());
    }

    // Description
    JsonElement description = json.getAsJsonObject().get("description");
    if (description != null) {
        feature.setDescription(description.getAsString());
    }

    // Group
    JsonElement group = json.getAsJsonObject().get("group");
    if (group != null) {
        feature.setGroup(group.getAsString());
    }

    // Permissions
    JsonElement permissions = json.getAsJsonObject().get("permissions");
    if (permissions != null) {
        Set<String> auths = gson.fromJson(permissions, new TypeToken<HashSet<String>>() {
        }.getType());
        feature.setPermissions(auths);
    }

    // Flipping strategy
    JsonElement flippingStrategy = json.getAsJsonObject().get("flippingStrategy");
    if (flippingStrategy != null && !flippingStrategy.isJsonNull()) {
        Map<String, ?> flippingStrategyParameters = gson.fromJson(flippingStrategy,
                new TypeToken<HashMap<String, ?>>() {
                }.getType());
        String flippingStrategyType = flippingStrategyParameters.get("type").toString();
        Map<String, String> initParams = (Map<String, String>) flippingStrategyParameters.get("initParams");
        // Adding flipping strategy
        feature.setFlippingStrategy(
                MappingUtil.instanceFlippingStrategy(uid, flippingStrategyType, initParams));
    }

    // Custom properties
    JsonElement customProperties = json.getAsJsonObject().get("customProperties");
    if (customProperties != null && !customProperties.isJsonNull()) {
        Map<String, LinkedTreeMap<String, Object>> map = new Gson().fromJson(customProperties,
                new TypeToken<com.google.gson.internal.LinkedTreeMap<String, LinkedTreeMap<String, Object>>>() {
                }.getType());
        for (Entry<String, LinkedTreeMap<String, Object>> element : map.entrySet()) {
            LinkedTreeMap<String, Object> propertyValues = element.getValue();
            // Getting values
            String pName = (String) propertyValues.get("name");
            String pType = (String) propertyValues.get("type");
            String pValue = (String) propertyValues.get("value");
            String desc = (String) propertyValues.get("description");
            Object fixedValues = propertyValues.get("fixedValues");
            Set pFixedValues = fixedValues != null ? new HashSet((Collection) fixedValues) : null;
            // Creating property with it
            Property<?> property = PropertyFactory.createProperty(pName, pType, pValue, desc, pFixedValues);
            feature.addProperty(property);
        }
    }

    return feature;
}

From source file:org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension.java

License:Apache License

@Override
public ListenableFuture<Image> createImage(ImageTemplate template) {

    final CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
    final String id = cloneTemplate.getSourceNodeId();
    final String name = cloneTemplate.getName();
    final String storageAccountName = id.replaceAll("[^A-Za-z0-9 ]", "") + "stor";

    api.getVirtualMachineApi(group).stop(id);
    if (nodeSuspendedPredicate.apply(id)) {
        return userExecutor.submit(new Callable<Image>() {
            @Override//from  w w w. j av a 2s  . c  o  m
            public Image call() throws Exception {
                api.getVirtualMachineApi(group).generalize(id);

                final String[] disks = new String[2];
                URI uri = api.getVirtualMachineApi(group).capture(id, cloneTemplate.getName(), CONTAINER_NAME);
                if (uri != null) {
                    if (imageAvailablePredicate.apply(uri)) {
                        List<ResourceDefinition> definitions = api.getJobApi().captureStatus(uri);
                        if (definitions != null) {
                            for (ResourceDefinition definition : definitions) {
                                LinkedTreeMap<String, String> properties = (LinkedTreeMap<String, String>) definition
                                        .properties();
                                Object storageObject = properties.get("storageProfile");
                                LinkedTreeMap<String, String> properties2 = (LinkedTreeMap<String, String>) storageObject;
                                Object osDiskObject = properties2.get("osDisk");
                                LinkedTreeMap<String, String> osProperties = (LinkedTreeMap<String, String>) osDiskObject;
                                Object dataDisksObject = properties2.get("dataDisks");
                                ArrayList<Object> dataProperties = (ArrayList<Object>) dataDisksObject;
                                LinkedTreeMap<String, String> datadiskObject = (LinkedTreeMap<String, String>) dataProperties
                                        .get(0);

                                disks[0] = osProperties.get("name");
                                disks[1] = datadiskObject.get("name");

                                VirtualMachine vm = api.getVirtualMachineApi(group).get(id);
                                final VMImage ref = VMImage.create(group, storageAccountName, disks[0],
                                        disks[1], name, "custom", vm.location());
                                return imageReferenceToImage.apply(ref);
                            }
                        }
                    }
                }
                throw new UncheckedTimeoutException(
                        "Image was not created within the time limit: " + cloneTemplate.getName());
            }
        });
    } else {
        final String illegalStateExceptionMessage = format("Node %s was not suspended within %sms.", id,
                azureComputeConstants.operationTimeout());
        throw new IllegalStateException(illegalStateExceptionMessage);
    }
}

From source file:org.matrix.console.activity.FallbackLoginActivity.java

License:Apache License

private void launchWebView() {
    mWebView.loadUrl(mHomeServerUrl + "_matrix/static/client/login/");

    mWebView.setWebViewClient(new WebViewClient() {
        @Override//  www  . ja va2 s. c o m
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);

            // on error case, close this activity
            FallbackLoginActivity.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    FallbackLoginActivity.this.finish();
                }
            });
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // avoid infinite onPageFinished call
            if (url.startsWith("http")) {
                // Generic method to make a bridge between JS and the UIWebView
                final String MXCJavascriptSendObjectMessage = "javascript:window.matrixLogin.sendObjectMessage = function(parameters) { var iframe = document.createElement('iframe');  iframe.setAttribute('src', 'js:' + JSON.stringify(parameters));  document.documentElement.appendChild(iframe); iframe.parentNode.removeChild(iframe); iframe = null; };";

                view.loadUrl(MXCJavascriptSendObjectMessage);

                // The function the fallback page calls when the registration is complete
                final String MXCJavascriptOnRegistered = "javascript:window.matrixLogin.onLogin = function(homeserverUrl, userId, accessToken) { matrixLogin.sendObjectMessage({ 'action': 'onLogin', 'homeServer': homeserverUrl,'userId': userId,  'accessToken': accessToken  }); };";

                view.loadUrl(MXCJavascriptOnRegistered);
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(android.webkit.WebView view, java.lang.String url) {
            if ((null != url) && url.startsWith("js:")) {
                String json = url.substring(3);
                HashMap<String, Object> serverParams = null;

                try {
                    // URL decode
                    json = URLDecoder.decode(json, "UTF-8");
                    serverParams = new Gson().fromJson(json, new TypeToken<HashMap<String, Object>>() {
                    }.getType());

                } catch (Exception e) {
                }

                // succeeds to parse parameters
                if (null != serverParams) {
                    try {
                        String action = (String) serverParams.get("action");
                        LinkedTreeMap<String, String> parameters = (LinkedTreeMap<String, String>) serverParams
                                .get("homeServer");

                        if (TextUtils.equals("onLogin", action) && (null != parameters)) {
                            final String userId = parameters.get("user_id");
                            final String accessToken = parameters.get("access_token");
                            final String homeServer = parameters.get("home_server");

                            // remove the trailing /
                            if (mHomeServerUrl.endsWith("/")) {
                                mHomeServerUrl = mHomeServerUrl.substring(0, mHomeServerUrl.length() - 1);
                            }

                            // check if the parameters are defined
                            if ((null != homeServer) && (null != userId) && (null != accessToken)) {
                                FallbackLoginActivity.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        Intent returnIntent = new Intent();
                                        returnIntent.putExtra("homeServerUrl", mHomeServerUrl);
                                        returnIntent.putExtra("homeServer", homeServer);
                                        returnIntent.putExtra("userId", userId);
                                        returnIntent.putExtra("accessToken", accessToken);
                                        setResult(RESULT_OK, returnIntent);

                                        FallbackLoginActivity.this.finish();
                                    }
                                });
                            }
                        }
                    } catch (Exception e) {
                    }
                }
                return true;
            }

            return false;
        }
    });
}

From source file:org.openmrs.mobile.activities.addeditpatient.AddEditPatientFragment.java

License:Open Source License

@Override
public void updateConceptAnswerView(Spinner conceptNamesDropdown, List<ConceptAnswer> conceptAnswers) {
    PersonAttributeType personAttributeType = viewPersonAttributeTypeMap.get(conceptNamesDropdown);
    ConceptAnswer conceptAnswer = new ConceptAnswer();
    conceptAnswer.setUuid(ApplicationConstants.EMPTY_STRING);
    if (conceptNamesDropdown.getPrompt().toString().equalsIgnoreCase(ApplicationConstants.CIVIL_STATUS)) {
        conceptAnswer.setDisplay(ApplicationConstants.CIVIL_STATUS);
    } else {//w ww  .  ja v a2  s  .c om
        conceptAnswer.setDisplay(ApplicationConstants.KIN_RELATIONSHIP);
    }
    conceptAnswers.add(0, conceptAnswer);
    if (context != null) {
        ArrayAdapter<ConceptAnswer> conceptNameArrayAdapter = new ArrayAdapter<>(context,
                android.R.layout.simple_spinner_dropdown_item, conceptAnswers);
        conceptNamesDropdown.setAdapter(conceptNameArrayAdapter);

        // set existing patient attribute if any
        try {
            LinkedTreeMap personAttribute = presenter.searchPersonAttributeValueByType(personAttributeType);
            String conceptUuid = (String) personAttribute.get("uuid");
            if (conceptUuid != null) {
                setDefaultDropdownSelection(conceptNameArrayAdapter, conceptUuid, conceptNamesDropdown);
            }
        } catch (Exception e) {
            logger.e(e);
        }
    }

    conceptNamesDropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ConceptAnswer conceptAnswer = conceptAnswers.get(position);
            if (!conceptAnswer.getUuid().equalsIgnoreCase(ApplicationConstants.EMPTY_STRING)) {
                PersonAttribute personAttribute = searchPersonAttribute(personAttributeType.getUuid());
                if (personAttribute == null) {
                    personAttribute = new PersonAttribute();
                    personAttribute.setAttributeType(personAttributeType);
                    personAttribute.setValue(conceptAnswer.getUuid());
                    personAttributeMap.put(conceptAnswer.getUuid(), personAttribute);
                } else {
                    personAttribute.setValue(conceptAnswer.getUuid());
                }
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

}

From source file:org.talend.components.marketo.runtime.client.MarketoBaseRESTClient.java

License:Open Source License

public void getToken() throws MarketoException {
    try {/*from w w w . ja  v  a 2  s .c om*/
        URL basicURI = new URL(endpoint);
        current_uri = new StringBuilder(basicURI.getProtocol())//
                .append("://")//
                .append(basicURI.getHost())//
                .append(API_PATH_IDENTITY_OAUTH_TOKEN)//
                .append(fmtParams("client_id", userId))//
                .append(fmtParams("client_secret", secretKey));
        URL url = new URL(current_uri.toString());
        HttpsURLConnection urlConn = (HttpsURLConnection) url.openConnection();
        urlConn.setRequestMethod("GET");
        urlConn.setRequestProperty(REQUEST_PROPERTY_ACCEPT, REQUEST_VALUE_APPLICATION_JSON);
        int responseCode = urlConn.getResponseCode();
        if (responseCode == 200) {
            InputStream inStream = urlConn.getInputStream();
            Reader reader = new InputStreamReader(inStream);
            Gson gson = new Gson();
            LinkedTreeMap js = (LinkedTreeMap) gson.fromJson(reader, Object.class);
            Object ac = js.get("access_token");
            if (ac != null) {
                accessToken = ac.toString();
                LOG.debug("MarketoRestExecutor.getAccessToken GOT token");
            } else {
                LinkedTreeMap err = (LinkedTreeMap) ((ArrayList) js.get(FIELD_ERRORS)).get(0);
                throw new MarketoException(REST, err.get("code").toString(), err.get("message").toString());
            }
        } else {
            throw new MarketoException(REST, responseCode,
                    "Marketo Authentication failed! Please check your " + "setting!");
        }
    } catch (ProtocolException | SocketTimeoutException | SocketException e) {
        LOG.error("AccessToken error: {}.", e.getMessage());
        throw new MarketoException(REST, "Marketo Authentication failed : " + e.getMessage());
    } catch (IOException e) {
        LOG.error("AccessToken error: {}.", e.getMessage());
        throw new MarketoException(REST, "Marketo Authentication failed : " + e.getMessage());
    }
}

From source file:org.talend.components.marketo.runtime.client.MarketoBaseRESTClient.java

License:Open Source License

public MarketoRecordResult executeFakeGetRequest(Schema schema, String input) throws MarketoException {
    InputStreamReader reader = httpFakeGet(input, false);
    // TODO refactor this part with method executeGetRequest(Schema s);
    Gson gson = new Gson();
    MarketoRecordResult mkr = new MarketoRecordResult();
    LinkedTreeMap ltm = (LinkedTreeMap) gson.fromJson(reader, Object.class);
    LOG.debug("ltm = {}.", ltm);
    mkr.setRequestId(REST + "::" + ltm.get("requestId"));
    mkr.setSuccess(Boolean.parseBoolean(ltm.get("success").toString()));
    mkr.setStreamPosition((String) ltm.get(FIELD_NEXT_PAGE_TOKEN));
    if (!mkr.isSuccess() && ltm.get(FIELD_ERRORS) != null) {
        List<LinkedTreeMap> errors = (List<LinkedTreeMap>) ltm.get(FIELD_ERRORS);
        for (LinkedTreeMap err : errors) {
            MarketoError error = new MarketoError(REST, (String) err.get("code"), (String) err.get("message"));
            mkr.setErrors(Collections.singletonList(error));
        }//from   w  ww  . j  a v a  2s  .c om
    }
    if (mkr.isSuccess()) {
        List<LinkedTreeMap> tmp = (List<LinkedTreeMap>) ltm.get("result");
        if (tmp != null) {
            mkr.setRecordCount(tmp.size());
            mkr.setRecords(parseRecords(tmp, schema));
        }
        if (mkr.getStreamPosition() != null) {
            mkr.setRemainCount(mkr.getRecordCount());
        }
    }
    return mkr;
}

From source file:org.talend.components.marketo.runtime.client.MarketoBaseRESTClient.java

License:Open Source License

public List<IndexedRecord> parseRecords(List<LinkedTreeMap> values, Schema schema) {
    List<IndexedRecord> records = new ArrayList<>();
    if (values == null || schema == null) {
        return records;
    }// ww w .ja va  2  s . c om
    for (LinkedTreeMap r : values) {
        IndexedRecord record = new GenericData.Record(schema);
        for (Field f : schema.getFields()) {
            Object o = r.get(f.name());
            record.put(f.pos(), getValueType(f, o));
        }
        records.add(record);
    }
    return records;
}

From source file:org.talend.components.marketo.runtime.client.MarketoBaseRESTClient.java

License:Open Source License

public MarketoRecordResult executeGetRequest(Schema schema) throws MarketoException {
    try {/*from   ww w. j a v a  2s  .c o m*/
        URL url = new URL(current_uri.toString());
        HttpsURLConnection urlConn = (HttpsURLConnection) url.openConnection();
        urlConn.setRequestMethod("GET");
        urlConn.setDoOutput(true);
        urlConn.setRequestProperty(REQUEST_PROPERTY_ACCEPT, REQUEST_VALUE_TEXT_JSON);
        int responseCode = urlConn.getResponseCode();
        if (responseCode == 200) {
            InputStream inStream = urlConn.getInputStream();
            Reader reader = new InputStreamReader(inStream);
            Gson gson = new Gson();
            MarketoRecordResult mkr = new MarketoRecordResult();
            LinkedTreeMap ltm = (LinkedTreeMap) gson.fromJson(reader, Object.class);
            mkr.setRequestId(REST + "::" + ltm.get("requestId"));
            mkr.setSuccess(Boolean.parseBoolean(ltm.get("success").toString()));
            mkr.setStreamPosition((String) ltm.get(FIELD_NEXT_PAGE_TOKEN));
            if (!mkr.isSuccess() && ltm.get(FIELD_ERRORS) != null) {
                List<LinkedTreeMap> errors = (List<LinkedTreeMap>) ltm.get(FIELD_ERRORS);
                for (LinkedTreeMap err : errors) {
                    MarketoError error = new MarketoError(REST, (String) err.get("code"),
                            (String) err.get("message"));
                    mkr.setErrors(Arrays.asList(error));
                }
            }
            if (mkr.isSuccess()) {
                List<LinkedTreeMap> tmp = (List<LinkedTreeMap>) ltm.get("result");
                if (tmp != null) {
                    mkr.setRecordCount(tmp.size());
                    mkr.setRecords(parseRecords(tmp, schema));
                }
                if (mkr.getStreamPosition() != null) {
                    mkr.setRemainCount(mkr.getRecordCount());
                }
            }
            return mkr;
        } else {
            LOG.error("GET request failed: {}", responseCode);
            throw new MarketoException(REST, responseCode,
                    "Request failed! Please check your request setting!");
        }

    } catch (IOException e) {
        LOG.error("GET request failed: {}", e.getMessage());
        throw new MarketoException(REST, e.getMessage());
    }
}