Example usage for com.fasterxml.jackson.databind JsonNode asText

List of usage examples for com.fasterxml.jackson.databind JsonNode asText

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JsonNode asText.

Prototype

public abstract String asText();

Source Link

Usage

From source file:com.baasbox.controllers.File.java

@With({ UserCredentialWrapFilter.class, ConnectToDBFilter.class })
public static Result storeFile() throws Throwable {
    MultipartFormData body = request().body().asMultipartFormData();
    if (body == null)
        return badRequest(
                "missing data: is the body multipart/form-data? Check if it contains boundaries too! ");
    //FilePart file = body.getFile(FILE_FIELD_NAME);
    List<FilePart> files = body.getFiles();
    FilePart file = null;/*  w  w  w  .j  a  v  a  2s  . c  o m*/
    if (!files.isEmpty())
        file = files.get(0);
    String ret = "";
    if (file != null) {
        Map<String, String[]> data = body.asFormUrlEncoded();
        String[] datas = data.get(DATA_FIELD_NAME);
        String[] acl = data.get(ACL_FIELD_NAME);

        /*extract attachedData */
        String dataJson = null;
        if (datas != null && datas.length > 0) {
            dataJson = datas[0];
        } else
            dataJson = "{}";

        /*extract acl*/
        /*the acl json must have the following format:
         * {
         *       "read" : {
         *                "users":[],
         *                "roles":[]
         *              }
         *       "update" : .......
         * }
         */
        String aclJsonString = null;
        if (acl != null && datas.length > 0) {
            aclJsonString = acl[0];
            ObjectMapper mapper = new ObjectMapper();
            JsonNode aclJson = null;
            try {
                aclJson = mapper.readTree(aclJsonString);
            } catch (JsonProcessingException e) {
                return status(CustomHttpCode.ACL_JSON_FIELD_MALFORMED.getBbCode(),
                        "The 'acl' field is malformed");
            }
            /*check if the roles and users are valid*/
            Iterator<Entry<String, JsonNode>> it = aclJson.fields();
            while (it.hasNext()) {
                //check for permission read/update/delete/all
                Entry<String, JsonNode> next = it.next();
                if (!PermissionsHelper.permissionsFromString.containsKey(next.getKey())) {
                    return status(CustomHttpCode.ACL_PERMISSION_UNKNOWN.getBbCode(), "The key '" + next.getKey()
                            + "' is invalid. Valid ones are 'read','update','delete','all'");
                }
                //check for users/roles
                Iterator<Entry<String, JsonNode>> it2 = next.getValue().fields();
                while (it2.hasNext()) {
                    Entry<String, JsonNode> next2 = it2.next();
                    if (!next2.getKey().equals("users") && !next2.getKey().equals("roles")) {
                        return status(CustomHttpCode.ACL_USER_OR_ROLE_KEY_UNKNOWN.getBbCode(), "The key '"
                                + next2.getKey() + "' is invalid. Valid ones are 'users' or 'roles'");
                    }
                    //check for the existance of users/roles
                    JsonNode arrNode = next2.getValue();
                    if (arrNode.isArray()) {
                        for (final JsonNode objNode : arrNode) {
                            //checks the existance users and/or roles
                            if (next2.getKey().equals("users") && !UserService.exists(objNode.asText()))
                                return status(CustomHttpCode.ACL_USER_DOES_NOT_EXIST.getBbCode(),
                                        "The user " + objNode.asText() + " does not exists");
                            if (next2.getKey().equals("roles") && !RoleService.exists(objNode.asText()))
                                return status(CustomHttpCode.ACL_ROLE_DOES_NOT_EXIST.getBbCode(),
                                        "The role " + objNode.asText() + " does not exists");

                        }
                    } else
                        return status(CustomHttpCode.JSON_VALUE_MUST_BE_ARRAY.getBbCode(),
                                "The '" + next2.getKey() + "' value must be an array");
                }

            }

        } else
            aclJsonString = "{}";

        java.io.File fileContent = file.getFile();
        String fileName = file.getFilename();
        /*String contentType = file.getContentType(); 
         if (contentType==null || contentType.isEmpty() || contentType.equalsIgnoreCase("application/octet-stream")){   //try to guess the content type
        InputStream is = new BufferedInputStream(new FileInputStream(fileContent));
        contentType = URLConnection.guessContentTypeFromStream(is);
        if (contentType==null || contentType.isEmpty()) contentType="application/octet-stream";
         }*/
        InputStream is = new FileInputStream(fileContent);
        /* extract file metadata and content */
        try {
            BodyContentHandler contenthandler = new BodyContentHandler();
            //DefaultHandler contenthandler = new DefaultHandler();
            Metadata metadata = new Metadata();
            metadata.set(Metadata.RESOURCE_NAME_KEY, fileName);
            Parser parser = new AutoDetectParser();
            parser.parse(is, contenthandler, metadata, new ParseContext());
            String contentType = metadata.get(Metadata.CONTENT_TYPE);
            if (StringUtils.isEmpty(contentType))
                contentType = "application/octet-stream";

            HashMap<String, Object> extractedMetaData = new HashMap<String, Object>();
            for (String key : metadata.names()) {
                try {
                    if (metadata.isMultiValued(key)) {
                        if (Logger.isDebugEnabled())
                            Logger.debug(key + ": ");
                        for (String value : metadata.getValues(key)) {
                            if (Logger.isDebugEnabled())
                                Logger.debug("   " + value);
                        }
                        extractedMetaData.put(key.replace(":", "_").replace(" ", "_").trim(),
                                Arrays.asList(metadata.getValues(key)));
                    } else {
                        if (Logger.isDebugEnabled())
                            Logger.debug(key + ": " + metadata.get(key));
                        extractedMetaData.put(key.replace(":", "_").replace(" ", "_").trim(),
                                metadata.get(key));
                    }
                } catch (Throwable e) {
                    Logger.warn("Unable to extract metadata for file " + fileName + ", key " + key);
                }
            }

            if (Logger.isDebugEnabled())
                Logger.debug(".................................");
            if (Logger.isDebugEnabled())
                Logger.debug(new JSONObject(extractedMetaData).toString());

            is.close();
            is = new FileInputStream(fileContent);
            ODocument doc = FileService.createFile(fileName, dataJson, aclJsonString, contentType,
                    fileContent.length(), is, extractedMetaData, contenthandler.toString());
            ret = prepareResponseToJson(doc);
        } catch (JsonProcessingException e) {
            throw new Exception("Error parsing acl field. HINTS: is it a valid JSON string?", e);
        } catch (Throwable e) {
            throw new Exception("Error parsing uploaded file", e);
        } finally {
            if (is != null)
                is.close();
        }
    } else {
        return badRequest("missing the file data in the body payload");
    }
    return created(ret);
}

From source file:com.amazonaws.services.kinesis.aggregators.configuration.ExternalConfigurationModel.java

public static List<ExternalConfigurationModel> buildFromConfig(String configFilePath) throws Exception {
    List<ExternalConfigurationModel> response = new ArrayList<>();

    // reference the config file as a full path
    File configFile = new File(configFilePath);
    if (!configFile.exists()) {

        // try to load the file from the classpath
        InputStream classpathConfig = ExternalConfigurationModel.class.getClassLoader()
                .getResourceAsStream(configFilePath);
        if (classpathConfig != null && classpathConfig.available() > 0) {
            configFile = new File(ExternalConfigurationModel.class
                    .getResource((configFilePath.startsWith("/") ? "" : "/") + configFilePath).toURI());

            LOG.info(String.format("Loaded Configuration %s from Classpath", configFilePath));
        } else {//  w w w . java 2  s  .c o m
            if (configFilePath.startsWith("s3://")) {
                AmazonS3 s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain());
                TransferManager tm = new TransferManager(s3Client);

                // parse the config path to get the bucket name and prefix
                final String s3ProtoRegex = "s3:\\/\\/";
                String bucket = configFilePath.replaceAll(s3ProtoRegex, "").split("/")[0];
                String prefix = configFilePath.replaceAll(String.format("%s%s\\/", s3ProtoRegex, bucket), "");

                // download the file using TransferManager
                configFile = File.createTempFile(configFilePath, null);
                Download download = tm.download(bucket, prefix, configFile);
                download.waitForCompletion();

                // shut down the transfer manager
                tm.shutdownNow();

                LOG.info(String.format("Loaded Configuration from Amazon S3 %s/%s to %s", bucket, prefix,
                        configFile.getAbsolutePath()));
            } else {
                // load the file from external URL
                try {
                    configFile = File.createTempFile(configFilePath, null);
                    FileUtils.copyURLToFile(new URL(configFilePath), configFile, 1000, 1000);
                    LOG.info(String.format("Loaded Configuration from %s to %s", configFilePath,
                            configFile.getAbsolutePath()));
                } catch (IOException e) {
                    // handle the timeouts and so on with a generalised
                    // config
                    // file not found handler later
                }
            }
        }
    } else {
        LOG.info(String.format("Loaded Configuration from Filesystem %s", configFilePath));
    }

    // if we haven't been able to load a config file, then bail
    if (configFile == null || !configFile.exists()) {
        throw new InvalidConfigurationException(
                String.format("Unable to Load Config File from %s", configFilePath));
    }

    JsonNode document = StreamAggregatorUtils.asJsonNode(configFile);

    ExternalConfigurationModel config = null;

    Iterator<JsonNode> i = document.elements();
    while (i.hasNext()) {
        config = new ExternalConfigurationModel();

        JsonNode section = i.next();

        // set generic properties
        config.setNamespace(StreamAggregatorUtils.readValueAsString(section, "namespace"));
        config.setDateFormat(StreamAggregatorUtils.readValueAsString(section, "dateFormat"));
        addTimeHorizons(section, config);
        setAggregatorType(section, config);

        // set the label items
        JsonNode labelItems = StreamAggregatorUtils.readJsonValue(section, "labelItems");
        if (labelItems != null && labelItems.size() > 0) {
            Iterator<JsonNode> iterator = labelItems.elements();
            while (iterator.hasNext()) {
                JsonNode n = iterator.next();
                config.addLabelItems(n.asText());
            }
        }
        config.setLabelAttributeAlias(StreamAggregatorUtils.readValueAsString(section, "labelAttributeAlias"));

        config.setDateItem(StreamAggregatorUtils.readValueAsString(section, "dateItem"));
        config.setDateAttributeAlias(StreamAggregatorUtils.readValueAsString(section, "dateAttributeAlias"));
        JsonNode summaryItems = StreamAggregatorUtils.readJsonValue(section, "summaryItems");
        if (summaryItems != null && summaryItems.size() > 0) {
            Iterator<JsonNode> iterator = summaryItems.elements();
            while (iterator.hasNext()) {
                JsonNode n = iterator.next();
                config.addSummaryItem(n.asText());
            }
        }

        config.setTableName(StreamAggregatorUtils.readValueAsString(section, "tableName"));

        String readIO = StreamAggregatorUtils.readValueAsString(section, "readIOPS");
        if (readIO != null)
            config.setReadIOPs(Long.parseLong(readIO));
        String writeIO = StreamAggregatorUtils.readValueAsString(section, "writeIOPS");
        if (writeIO != null)
            config.setWriteIOPs(Long.parseLong(writeIO));

        // configure tolerance of data extraction problems
        String failOnDataExtraction = StreamAggregatorUtils.readValueAsString(section, "failOnDataExtraction");
        if (failOnDataExtraction != null)
            config.setFailOnDataExtraction(Boolean.parseBoolean(failOnDataExtraction));

        // configure whether metrics should be emitted
        String emitMetrics = StreamAggregatorUtils.readValueAsString(section, "emitMetrics");
        String metricsEmitterClassname = StreamAggregatorUtils.readValueAsString(section,
                "metricsEmitterClass");
        if (emitMetrics != null || metricsEmitterClassname != null) {
            if (metricsEmitterClassname != null) {
                config.setMetricsEmitter((Class<IMetricsEmitter>) ClassLoader.getSystemClassLoader()
                        .loadClass(metricsEmitterClassname));
            } else {
                config.setEmitMetrics(Boolean.parseBoolean(emitMetrics));
            }
        }

        // configure the data store class
        String dataStoreClass = StreamAggregatorUtils.readValueAsString(section, "IDataStore");
        if (dataStoreClass != null) {
            Class<IDataStore> dataStore = (Class<IDataStore>) ClassLoader.getSystemClassLoader()
                    .loadClass(dataStoreClass);
            config.setDataStore(dataStore);
        }

        // get the data extractor configuration, so we know what other json
        // elements to retrieve from the configuration document
        String useExtractor = null;
        try {
            useExtractor = StreamAggregatorUtils.readValueAsString(section, "dataExtractor");
            config.setDataExtractor(DataExtractor.valueOf(useExtractor));
        } catch (Exception e) {
            throw new Exception(
                    String.format("Unable to configure aggregator with Data Extractor %s", useExtractor));
        }

        switch (config.getDataExtractor()) {
        case CSV:
            configureStringCommon(section, config);
            configureCsv(section, config);
            break;
        case JSON:
            configureStringCommon(section, config);
            break;
        case OBJECT:
            configureObject(section, config);
            break;
        case REGEX:
            configureRegex(section, config);
        }

        response.add(config);
    }
    return response;
}

From source file:com.squarespace.template.plugins.platform.ContentFormatters.java

private static String[] splitDimensions(JsonNode node) {
    String val = node.asText();
    String[] parts = StringUtils.split(val, 'x');
    if (parts.length != 2) {
        return null;
    }//  w  w  w.j a  va  2 s. c  o m
    return parts;
}

From source file:com.palominolabs.crm.sf.rest.RestConnectionImpl.java

@Nonnull
private static RestSObject getSObject(JsonNode rawNode) throws IOException {
    ObjectNode jsonNode = asObjectNode(rawNode);

    ObjectNode attributes = getObjectNode(jsonNode, ATTRIBUTES_KEY);

    String type = getString(attributes, "type");
    JsonNode idNode = jsonNode.get(ID_KEY);
    RestSObjectImpl sObject;/*from w  ww  .java2  s.c  o  m*/
    if (isNull(idNode)) {
        sObject = RestSObjectImpl.getNew(type);
    } else {
        if (!idNode.isTextual()) {
            throw new ResponseParseException("Id node <" + idNode + "> wasn't textual");
        }
        sObject = RestSObjectImpl.getNewWithId(type, new Id(idNode.textValue()));
    }

    jsonNode.remove(ID_KEY);
    jsonNode.remove(ATTRIBUTES_KEY);

    Iterator<String> fieldNames = jsonNode.fieldNames();
    while (fieldNames.hasNext()) {
        String fieldName = fieldNames.next();
        JsonNode fieldValueNode = jsonNode.get(fieldName);

        if (fieldValueNode.isNull()) {
            // null node is a value node so handle it first
            sObject.setField(fieldName, null);
            continue;
        } else if (fieldValueNode.isValueNode()) {
            sObject.setField(fieldName, fieldValueNode.asText());
            continue;
        } else if (fieldValueNode.isObject()) {
            // it could either be a subquery or a sub object at this point.
            if (fieldValueNode.path("attributes").isObject()) {
                sObject.setRelationshipSubObject(fieldName, getSObject(fieldValueNode));
            } else if (fieldValueNode.path("records").isArray()) {
                sObject.setRelationshipQueryResult(fieldName, getQueryResult(fieldValueNode));
            } else {
                throw new ResponseParseException("Could not understand field value node: " + fieldValueNode);
            }

            continue;
        }

        throw new ResponseParseException("Unknown node type <" + fieldValueNode + ">");
    }
    return sObject;
}

From source file:com.baasbox.service.scripting.ScriptingService.java

public static JsonNode callJsonSync(JsonNode req) throws Exception {
    JsonNode url = req.get("url");
    JsonNode method = req.get("method");
    JsonNode timeout = req.get("timeout");

    if (url == null || url instanceof NullNode)
        throw new IllegalArgumentException("Missing URL to call");
    if (method == null || method instanceof NullNode)
        throw new IllegalArgumentException("Missing method to use when calling the URL");

    return callJsonSync(url.asText(), method.asText(), mapJson(req.get("params")), mapJson(req.get("headers")),
            req.get("body"), (timeout != null && timeout.isNumber()) ? timeout.asInt() : null);
}

From source file:com.squarespace.template.plugins.platform.ContentFormatters.java

private static String getAltTextFromContentItem(JsonNode contentItemNode) {
    JsonNode title = contentItemNode.path("title");
    if (isTruthy(title)) {
        return title.asText();
    }//from w  w w. j  av  a2 s .  com

    JsonNode body = contentItemNode.path("body");
    if (isTruthy(body)) {
        String text = PluginUtils.removeTags(body.asText());
        if (text.length() > 0) {
            return text;
        }
    }

    JsonNode filename = contentItemNode.path("filename");
    if (isTruthy(filename)) {
        return filename.asText();
    }

    return "";
}

From source file:com.redhat.lightblue.metadata.mongo.BSONParser.java

private static Object convertValue(JsonNode node) {
    if (node instanceof BigIntegerNode) {
        return node.bigIntegerValue();
    } else if (node instanceof BooleanNode) {
        return new Boolean(node.asBoolean());
    } else if (node instanceof DecimalNode) {
        return node.decimalValue();
    } else if (node instanceof DoubleNode || node instanceof FloatNode) {
        return node.asDouble();
    } else if (node instanceof IntNode || node instanceof LongNode || node instanceof ShortNode) {
        return node.asLong();
    }/*from  w w w . jav a 2s .c  om*/
    return node.asText();
}

From source file:org.dswarm.wikidataimporter.WikibaseAPIClient.java

public static String getToken(final Response loginResponse) {

    try {//from   w  w  w.  j a va  2s.c  o m

        final String responseBody = loginResponse.readEntity(String.class);

        if (responseBody == null) {

            LOG.error("cannot extract token - response body is not available");

            return null;
        }

        final ObjectNode json = MAPPER.readValue(responseBody, ObjectNode.class);

        if (json == null) {

            LOG.error("cannot extract token - response JSON is not available");

            return null;
        }

        final JsonNode loginNode = json.get(MEDIAWIKI_API_LOGIN);

        if (loginNode == null) {

            LOG.error("cannot extract token - '{}' node is not available in response JSON '{}'",
                    MEDIAWIKI_API_LOGIN, responseBody);

            return null;
        }

        final JsonNode tokenNode = loginNode.get(MEDIAWIKI_API_TOKEN_IDENTIFIER);

        if (tokenNode == null) {

            LOG.error("cannot extract token - '{}' node is not available in response JSON '{}'",
                    MEDIAWIKI_API_TOKEN_IDENTIFIER, responseBody);

            return null;
        }

        return tokenNode.asText();
    } catch (final Exception e) {

        LOG.error(
                "cannot extract token - an error occurred while trying to extract the token from the response body",
                e);

        return null;
    }
}

From source file:org.dswarm.wikidataimporter.WikibaseAPIClient.java

public static String getEditToken(final Response editTokenResponse) {

    try {//from ww  w  .j  a  v a 2  s .com

        final String responseBody = editTokenResponse.readEntity(String.class);

        if (responseBody == null) {

            LOG.error("cannot extract edit token - response body is not available");

            return null;
        }

        final ObjectNode json = MAPPER.readValue(responseBody, ObjectNode.class);

        if (json == null) {

            LOG.error("cannot extract edit token - response JSON is not available");

            return null;
        }

        final JsonNode queryNode = json.get(MEDIAWIKI_API_QUERY);

        if (queryNode == null) {

            LOG.error("cannot extract edit token - '{}' node is not available in response JSON '{}'",
                    MEDIAWIKI_API_QUERY, responseBody);

            return null;
        }

        final JsonNode tokensNode = queryNode.get(MEDIAWIKI_API_TOKENS_IDENTIFIER);

        if (tokensNode == null) {

            LOG.error("cannot extract edit token - '{}' node is not available in response JSON '{}'",
                    MEDIAWIKI_API_TOKENS_IDENTIFIER, responseBody);

            return null;
        }

        final JsonNode csrfTokenNode = tokensNode.get(MEDIAWIKI_API_CSRFTOKEN_IDENTIFIER);

        if (csrfTokenNode == null) {

            LOG.error("cannot extract edit token - '{}' node is not available in response JSON '{}'",
                    MEDIAWIKI_API_CSRFTOKEN_IDENTIFIER, responseBody);

            return null;
        }

        return csrfTokenNode.asText();
    } catch (final Exception e) {

        LOG.error(
                "cannot extract edit token - an error occurred while trying to extract the edit token from the response body",
                e);

        return null;
    }
}

From source file:com.baasbox.controllers.Push.java

public static Result send(String username) throws Exception {
    if (BaasBoxLogger.isTraceEnabled())
        BaasBoxLogger.trace("Method Start");
    Http.RequestBody body = request().body();
    JsonNode bodyJson = body.asJson(); //{"message":"Text"}
    if (BaasBoxLogger.isTraceEnabled())
        BaasBoxLogger.trace("send bodyJson: " + bodyJson);
    if (bodyJson == null)
        return status(CustomHttpCode.JSON_PAYLOAD_NULL.getBbCode(),
                CustomHttpCode.JSON_PAYLOAD_NULL.getDescription());
    JsonNode messageNode = bodyJson.findValue("message");
    if (messageNode == null)
        return status(CustomHttpCode.PUSH_MESSAGE_INVALID.getBbCode(),
                CustomHttpCode.PUSH_MESSAGE_INVALID.getDescription());
    if (!messageNode.isTextual())
        return status(CustomHttpCode.PUSH_MESSAGE_INVALID.getBbCode(),
                CustomHttpCode.PUSH_MESSAGE_INVALID.getDescription());

    String message = messageNode.asText();

    List<String> usernames = new ArrayList<String>();
    usernames.add(username);//from  w  ww .j  a v a  2 s.c o  m

    JsonNode pushProfilesNodes = bodyJson.get("profiles");

    List<Integer> pushProfiles = new ArrayList<Integer>();
    if (!(pushProfilesNodes == null)) {
        if (!(pushProfilesNodes.isArray()))
            return status(CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getBbCode(),
                    CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getDescription());
        for (JsonNode pushProfileNode : pushProfilesNodes) {
            pushProfiles.add(pushProfileNode.asInt());
        }
    } else {
        pushProfiles.add(1);
    }
    boolean[] withError = new boolean[6];
    PushService ps = new PushService();
    try {
        if (ps.validate(pushProfiles))
            withError = ps.send(message, usernames, pushProfiles, bodyJson, withError);
    } catch (UserNotFoundException e) {
        BaasBoxLogger.error("Username not found " + username, e);
        return notFound("Username not found");
    } catch (SqlInjectionException e) {
        return badRequest("the supplied name appears invalid (Sql Injection Attack detected)");
    } catch (PushNotInitializedException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_CONFIG_INVALID.getBbCode(),
                CustomHttpCode.PUSH_CONFIG_INVALID.getDescription());
    } catch (PushProfileDisabledException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_PROFILE_DISABLED.getBbCode(),
                CustomHttpCode.PUSH_PROFILE_DISABLED.getDescription());
    } catch (PushProfileInvalidException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_PROFILE_FORMAT_INVALID.getDescription());
    } catch (UnknownHostException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_HOST_UNREACHABLE.getBbCode(),
                CustomHttpCode.PUSH_HOST_UNREACHABLE.getDescription());
    } catch (InvalidRequestException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_INVALID_REQUEST.getBbCode(),
                CustomHttpCode.PUSH_INVALID_REQUEST.getDescription());
    } catch (PushSoundKeyFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_SOUND_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_SOUND_FORMAT_INVALID.getDescription());
    } catch (PushBadgeFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_BADGE_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_BADGE_FORMAT_INVALID.getDescription());
    } catch (PushActionLocalizedKeyFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_ACTION_LOCALIZED_KEY_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_ACTION_LOCALIZED_KEY_FORMAT_INVALID.getDescription());
    } catch (PushLocalizedKeyFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_LOCALIZED_KEY_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_LOCALIZED_ARGUMENTS_FORMAT_INVALID.getDescription());
    } catch (PushLocalizedArgumentsFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_LOCALIZED_ARGUMENTS_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_LOCALIZED_ARGUMENTS_FORMAT_INVALID.getDescription());
    } catch (PushCollapseKeyFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_COLLAPSE_KEY_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_COLLAPSE_KEY_FORMAT_INVALID.getDescription());
    } catch (PushTimeToLiveFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_TIME_TO_LIVE_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_TIME_TO_LIVE_FORMAT_INVALID.getDescription());
    } catch (PushContentAvailableFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_CONTENT_AVAILABLE_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_CONTENT_AVAILABLE_FORMAT_INVALID.getDescription());
    } catch (PushCategoryFormatException e) {
        BaasBoxLogger.error(ExceptionUtils.getMessage(e));
        return status(CustomHttpCode.PUSH_CATEGORY_FORMAT_INVALID.getBbCode(),
                CustomHttpCode.PUSH_CATEGORY_FORMAT_INVALID.getDescription());
    }
    if (BaasBoxLogger.isTraceEnabled())
        BaasBoxLogger.trace("Method End");
    for (int i = 0; i < withError.length; i++) {
        if (withError[i] == true)
            return status(CustomHttpCode.PUSH_SENT_WITH_ERROR.getBbCode(),
                    CustomHttpCode.PUSH_SENT_WITH_ERROR.getDescription());
    }
    return ok();
}