@SuppressWarnings({"unused", "unchecked"}) public final JSONObject object() throws ParseException { final JSONObject json = new JSONObject(); String key; Object value; key = objectKey(); jj_consume_token(EQUALS); value = value(); json.put(key, value); key = null; value = null; label_2: while (true) { if (jj_2_1(2)) {; } else { break label_2; } jj_consume_token(COMMA); key = objectKey(); jj_consume_token(EQUALS); value = value(); json.put(key, value); key = null; value = null; } { if (true) return json; } throw new Error("Missing return statement in function"); }
private void addTagsToProperties(MethodInfo mi, JSONObject propJ) throws JSONException { // create description object. description tag enables the visual tools to display description of // keys/values // of a map property, items of a list, properties within a complex type. JSONObject descriptionObj = new JSONObject(); if (mi.comment != null) { descriptionObj.put("$", mi.comment); } for (Map.Entry<String, String> descEntry : mi.descriptions.entrySet()) { descriptionObj.put(descEntry.getKey(), descEntry.getValue()); } if (descriptionObj.length() > 0) { propJ.put("descriptions", descriptionObj); } // create useSchema object. useSchema tag is added to enable visual tools to be able to render a // text field // as a dropdown with choices populated from the schema attached to the port. JSONObject useSchemaObj = new JSONObject(); for (Map.Entry<String, String> useSchemaEntry : mi.useSchemas.entrySet()) { useSchemaObj.put(useSchemaEntry.getKey(), useSchemaEntry.getValue()); } if (useSchemaObj.length() > 0) { propJ.put("useSchema", useSchemaObj); } }
/** * Construct a JSONObject from a ResourceBundle. * * @param baseName The ResourceBundle base name. * @param locale The Locale to load the ResourceBundle for. * @throws JSONException If any JSONExceptions are detected. */ public JSONObject(String baseName, Locale locale) throws JSONException { this(); final ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader()); // Iterate through the keys in the bundle. final Enumeration keys = bundle.getKeys(); while (keys.hasMoreElements()) { final Object key = keys.nextElement(); if (key instanceof String) { // Go through the path, ensuring that there is a nested // JSONObject for each // segment except the last. Add the value using the last // segment's name into // the deepest nested JSONObject. final String[] path = ((String) key).split("\\."); final int last = path.length - 1; JSONObject target = this; for (int i = 0; i < last; i += 1) { final String segment = path[i]; JSONObject nextTarget = target.optJSONObject(segment); if (nextTarget == null) { nextTarget = new JSONObject(); target.put(segment, nextTarget); } target = nextTarget; } target.put(path[last], bundle.getString((String) key)); } } }
@SuppressWarnings({"unchecked", "unused"}) public final JSONObject innerMap() throws ParseException { final JSONObject json = new JSONObject(); String key; Object value; key = objectKey(); jj_consume_token(EQUALS); value = value(); json.put(key, value); key = null; value = null; label_1: while (true) { switch (jj_nt.kind) { case SLASH:; break; default: jj_la1[1] = jj_gen; break label_1; } jj_consume_token(SLASH); jj_consume_token(COMMA); key = objectKey(); jj_consume_token(EQUALS); value = value(); json.put(key, value); key = null; value = null; } { if (true) return json; } throw new Error("Missing return statement in function"); }
public static JSONObject createInfoAlert(String message) { try { JSONObject ret = new JSONObject(); ret.put("type", "info"); ret.put("message", message); return ret; } catch (JSONException e) { return null; } }
public static JSONObject buildErrorJson(String errorMsg) { JSONObject ret = new JSONObject(); try { JSONObject error = new JSONObject(); error.put("message", errorMsg); error.put("type", "error"); ret.put("announce", error); } catch (JSONException e) { return null; } return ret; }
/** * Sends command to retrieve phones list. * * @return is command successful. */ @SuppressWarnings("unchecked") private boolean getPhoneList() { JSONObject obj = new JSONObject(); try { obj.put("class", "phones"); obj.put("function", "getlist"); return send(obj); } catch (Exception e) { logger.error("Error retrieving phones"); return false; } }
private JSONObject getJSONNote(Note note) { JSONObject jsonNote = new JSONObject(); jsonNote.put("noteID", note.getNoteID()); jsonNote.put("noteTitle", note.getNoteTitle()); jsonNote.put("noteURL", note.getNoteURL()); JSONObject jsonSubject = api.login.SubjectsController.getJSONsubject(note.getSubject()); jsonNote.put("subject", jsonSubject); JSONObject jsonUser = api.login.UsersController.getJSONuser(note.getUser()); jsonNote.put("user", jsonUser); return jsonNote; }
/** * Sends password command. * * @param sessionId the session id from previous command. * @param password the password to authorize. * @return is command successful. */ @SuppressWarnings("unchecked") private boolean authorize(String sessionId, String password) { if (connection == null || sessionId == null || password == null) return false; JSONObject obj = new JSONObject(); try { obj.put("class", "login_pass"); obj.put("hashedpassword", Sha1Crypto.encode(sessionId + ":" + password)); return send(obj); } catch (Exception e) { logger.error("Error login with password", e); return false; } }
/** * Send needed command for features. * * @param astid param from previous command. * @param xivoUserId param from previous command. * @return is command successful. */ @SuppressWarnings("unchecked") private boolean sendFeatures(String astid, String xivoUserId) { if (connection == null || astid == null || xivoUserId == null) return false; JSONObject obj = new JSONObject(); try { obj.put("class", "featuresget"); obj.put("userid", astid + "/" + xivoUserId); return send(obj); } catch (Exception e) { logger.error("Error send features get command", e); return false; } }
/** * Performs a test by sending HTTP Gets to the URL, and records the number of bytes returned. Each * test results are documented and displayed in standard out with the following information: * * <p>URL - The source URL of the test REQ CNT - How many times this test has run START - The * start time of the last test run STOP - The stop time of the last test run THREAD - The thread * id handling this test case RESULT - The result of the test. Either the number of bytes returned * or an error message. */ private void doTest() { String result = ""; this.reqCount++; // Connect and run test steps Date startTime = new Date(); try { ClientResource client = new ClientResource(this.myURL); // place order JSONObject json = new JSONObject(); json.put("payment", "quarter"); json.put("action", "place-order"); client.post(new JsonRepresentation(json), MediaType.APPLICATION_JSON); // Get Gumball Count Representation result_string = client.get(); JSONObject json_count = new JSONObject(result_string.getText()); result = Integer.toString((int) json_count.get("count")); } catch (Exception e) { result = e.toString(); } finally { Date stopTime = new Date(); // Print Report of Result: System.out.println( "======================================\n" + "URL => " + this.myURL + "\n" + "REQ CNT => " + this.reqCount + "\n" + "START => " + startTime + "\n" + "STOP => " + stopTime + "\n" + "THREAD => " + Thread.currentThread().getName() + "\n" + "RESULT => " + result + "\n"); } }
public Resolution getUniqueValues() throws JSONException { JSONObject json = new JSONObject(); json.put("success", Boolean.FALSE); try { Layer layer = applicationLayer.getService().getSingleLayer(applicationLayer.getLayerName()); if (layer != null && layer.getFeatureType() != null) { SimpleFeatureType sft = layer.getFeatureType(); List<String> beh = sft.calculateUniqueValues(attribute); json.put("uniqueValues", new JSONArray(beh)); json.put("success", Boolean.TRUE); } } catch (Exception e) { json.put("msg", e.toString()); } return new StreamingResolution("application/json", new StringReader(json.toString())); }
/** * Sends login command. * * @param capalistParam param from previous command. * @return is command successful. */ @SuppressWarnings("unchecked") private boolean sendCapas(JSONArray capalistParam) { if (connection == null || capalistParam == null || capalistParam.isEmpty()) return false; JSONObject obj = new JSONObject(); try { obj.put("class", "login_capas"); obj.put("capaid", capalistParam.get(0)); obj.put("lastconnwins", "false"); obj.put("loginkind", "agent"); obj.put("state", ""); return send(obj); } catch (Exception e) { logger.error("Error login", e); return false; } }
@SuppressWarnings("unchecked") public void addDefaultValue(String className, JSONObject oper) throws Exception { ObjectMapper defaultValueMapper = ObjectMapperFactory.getOperatorValueSerializer(); Class<? extends Operator> clazz = (Class<? extends Operator>) classLoader.loadClass(className); if (clazz != null) { Operator operIns = clazz.newInstance(); String s = defaultValueMapper.writeValueAsString(operIns); oper.put("defaultValue", new JSONObject(s).get(className)); } }
private JSONObject setFieldAttributes(String clazz, CompactFieldNode field) throws JSONException { JSONObject port = new JSONObject(); port.put("name", field.getName()); TypeGraphVertex tgv = typeGraph.getTypeGraphVertex(clazz); putFieldDescription(field, port, tgv); List<CompactAnnotationNode> annotations = field.getVisibleAnnotations(); CompactAnnotationNode firstAnnotation; if (annotations != null && !annotations.isEmpty() && (firstAnnotation = field.getVisibleAnnotations().get(0)) != null) { for (Map.Entry<String, Object> entry : firstAnnotation.getAnnotations().entrySet()) { port.put(entry.getKey(), entry.getValue()); } } return port; }
public JSONObject describeClass(Class<?> clazz) throws Exception { JSONObject desc = new JSONObject(); desc.put("name", clazz.getName()); if (clazz.isEnum()) { @SuppressWarnings("unchecked") Class<Enum<?>> enumClass = (Class<Enum<?>>) clazz; ArrayList<String> enumNames = Lists.newArrayList(); for (Enum<?> e : enumClass.getEnumConstants()) { enumNames.add(e.name()); } desc.put("enum", enumNames); } UI_TYPE ui_type = UI_TYPE.getEnumFor(clazz); if (ui_type != null) { desc.put("uiType", ui_type.getName()); } desc.put("properties", getClassProperties(clazz, 0)); return desc; }
public static JSONObject bundleJsonResponseObject(String name, Object o) { try { Gson gson = new Gson(); String jsonString = gson.toJson(o); log.finer(jsonString); JSONObject obj = new JSONObject(); if (o instanceof Collection) { JSONArray arr = new JSONArray(jsonString); obj.put(name, arr); } else { JSONObject obj2 = new JSONObject(jsonString); obj.put(name, obj2); } return obj; } catch (JSONException e) { log.throwing(KEY, "bundleJsonResponse", e); return null; } }
public JSONObject asJSONTreeAux(ConcurrentHashMap<DomainConcept, DomainConcept> written) { JSONObject jsonObj = new JSONObject(); try { jsonObj.put("class", "ClassModel"); jsonObj.put("id", id); if (written.contains(this)) { return jsonObj; } written.put(this, this); if (getHasArcs() != null) { JSONArray jsonHasArcs = new JSONArray(); for (Arc row : getHasArcs()) { jsonHasArcs.put(row.asJSONTreeAux(written)); } jsonObj.put("hasArcs", jsonHasArcs); } if (getHasPropertySet() != null) { jsonObj.put("hasPropertySet", getHasPropertySet().asJSONTreeAux(written)); } jsonObj.put("id", getId()); if (getHasDomainNodes() != null) { jsonObj.put("hasDomainNodes", getHasDomainNodes().asJSONTreeAux(written)); } written.remove(this); } catch (Exception e1) { logWriter.error("Error in marshalling to JSON ", e1); } return jsonObj; }
private JSONObject createNewUser(int gameId) { int userId; JSONObject jObj = new JSONObject(); JSONObject action = new JSONObject(); Random randomNum = new Random(); userId = randomNum.nextInt(max_users) + 1; while (userIds[userId] == true) { userId = randomNum.nextInt(max_users) + 1; } userIds[userId] = true; try { jObj.put("game", gameId); action.put("actionType", "gameStart"); action.put("actionNumber", 1); jObj.put("action", action); jObj.put("user", "u" + userId); } catch (JSONException e) { System.out.println("could not put"); } gameRecord.put(gameId, new GameInfo("u" + userId, userId)); return jObj; }
private void makeAttributeJSONArray(final SimpleFeatureType layerSft) throws JSONException { List<ConfiguredAttribute> cas = applicationLayer.getAttributes(); // Sort the attributes, by featuretype and the featuretyp Collections.sort( cas, new Comparator<ConfiguredAttribute>() { @Override public int compare(ConfiguredAttribute o1, ConfiguredAttribute o2) { if (o1.getFeatureType() == null) { return -1; } if (o2.getFeatureType() == null) { return 1; } if (o1.getFeatureType().getId().equals(layerSft.getId())) { return -1; } if (o2.getFeatureType().getId().equals(layerSft.getId())) { return 1; } return o1.getFeatureType().getId().compareTo(o2.getFeatureType().getId()); } }); for (ConfiguredAttribute ca : cas) { JSONObject j = ca.toJSONObject(); // Copy alias over from feature type SimpleFeatureType sft = ca.getFeatureType(); if (sft == null) { sft = layerSft; } AttributeDescriptor ad = sft.getAttribute(ca.getAttributeName()); j.put("alias", ad.getAlias()); j.put("featureTypeAttribute", ad.toJSONObject()); attributesJSON.put(j); } }
public static JsonRepresentation bundleJsonResponse( String name, Object o, String repository, String patid) { try { Gson gson = new Gson(); String jsonString = gson.toJson(o); log.finer(jsonString); JSONObject obj = new JSONObject(); obj.put("patient_id", patid); obj.put("repository", repository); if (o instanceof Collection) { JSONArray arr = new JSONArray(jsonString); obj.put(name, arr); } else { JSONObject obj2 = new JSONObject(jsonString); obj.put(name, obj2); } return new JsonRepresentation(obj); } catch (JSONException e) { log.throwing(KEY, "bundleJsonResponse", e); return null; } }
@RequestMapping( value = "/getCityApi", method = {RequestMethod.GET, RequestMethod.POST}) public String getCityApi( HttpServletRequest request, @RequestParam(value = "locationname") String locationname, ModelMap model) { Map<Object, Object> map = new HashMap<Object, Object>(); JSONArray jSONArray = new JSONArray(); try { String status = "active"; List<City> cityList = cityService.getCityApi(locationname, status); if (cityList != null && cityList.size() > 0) { for (int i = 0; i < cityList.size(); i++) { City city = (City) cityList.get(i); String cityName = (String) city.getCity(); String stateName = (String) city.getState(); int ID = (Integer) (city.getId()); JSONObject jSONObject = new JSONObject(); jSONObject.put("id", ID); jSONObject.put("text", cityName); jSONArray.put(jSONObject); } utilities.setSuccessResponse(response, jSONArray.toString()); } else { throw new ConstException(ConstException.ERR_CODE_NO_DATA, ConstException.ERR_MSG_NO_DATA); } } catch (Exception ex) { logger.error("getCity :" + ex.getMessage()); utilities.setErrResponse(ex, response); } model.addAttribute("model", jSONArray.toString()); return "home"; }
private void putFieldDescription(CompactFieldNode field, JSONObject port, TypeGraphVertex tgv) throws JSONException { OperatorClassInfo oci = classInfo.get(tgv.typeName); if (oci != null) { String fieldDesc = oci.fields.get(field.getName()); if (fieldDesc != null) { port.put("description", fieldDesc); return; } } for (TypeGraphVertex ancestor : tgv.getAncestors()) { putFieldDescription(field, port, ancestor); } }
private JSONObject moveUser(int gameCount) { Random randomNum = new Random(); GameInfo gameInfo; JSONObject jObj = new JSONObject(); JSONObject action = new JSONObject(); JSONObject coords = new JSONObject(); int game; int xCoord; int yCoord; int addPoints; // Gets random number to denote which game to use action on game = getRandomGame(gameCount); xCoord = randomNum.nextInt(20) + 1; yCoord = randomNum.nextInt(20) + 1; addPoints = randomNum.nextInt(41) - 20; gameInfo = gameRecord.get(game); gameInfo.addPoints(addPoints); gameInfo.incrementCount(); try { jObj.put("game", game); coords.put("x", xCoord); coords.put("y", yCoord); action.put("actionType", "Move"); action.put("actionNumber", gameInfo.getCount()); action.put("location", coords); action.put("pointsAdded", addPoints); action.put("points", gameInfo.getPoints()); jObj.put("action", action); jObj.put("user", gameInfo.getUser()); } catch (JSONException e) { System.out.println("could not put"); } return jObj; }
private JSONObject endGame(int gameCount) { Random randomNum = new Random(); GameInfo gameInfo; JSONObject jObj = new JSONObject(); JSONObject action = new JSONObject(); int game; String status; game = getRandomGame(gameCount); gameInfo = gameRecord.get(game); gameInfo.incrementCount(); if (gameInfo.getCount() < 9) { return moveUser(gameCount); } if (gameInfo.getPoints() > 40 || gameInfo.getPoints() < -40) { status = "WIN"; } else { status = "LOSS"; } try { jObj.put("game", game); action.put("actionType", "gameEnd"); action.put("gameStatus", status); action.put("actionNumber", gameInfo.getCount()); action.put("points", gameInfo.getPoints()); jObj.put("action", action); jObj.put("user", gameInfo.getUser()); userIds[gameInfo.getId()] = false; gameRecord.remove(game); } catch (JSONException e) { System.out.println("could not put"); } return jObj; }
/** * Sends login command. * * @param username the username. * @return is command successful. */ @SuppressWarnings("unchecked") private boolean login(String username) { if (connection == null || username == null) return false; JSONObject obj = new JSONObject(); try { obj.put("class", "login_id"); obj.put("company", "Jitsi"); String os = "x11"; if (OSUtils.IS_WINDOWS) os = "win"; else if (OSUtils.IS_MAC) os = "mac"; obj.put("ident", username + "@" + os); obj.put("userid", username); obj.put("version", "9999"); obj.put("xivoversion", "1.1"); return send(obj); } catch (Exception e) { logger.error("Error login", e); return false; } }
/** method to marshall data from caching layer object to JSON * */ public JSONObject asJSON() { JSONObject jsonObj = new JSONObject(); try { jsonObj.put("class", "ClassModel"); jsonObj.put("id", id); if (getHasArcs() != null) { JSONArray jsonHasArcs = new JSONArray(); for (Arc row : getHasArcs()) { jsonHasArcs.put(row.getId()); } jsonObj.put("hasArcs", jsonHasArcs); } if (getHasPropertySet() != null) { jsonObj.put("hasPropertySet", getHasPropertySet().getId()); } jsonObj.put("id", getId()); if (getHasDomainNodes() != null) { jsonObj.put("hasDomainNodes", getHasDomainNodes().getId()); } } catch (Exception e1) { logWriter.error("Error in marshalling to JSON ", e1); } return jsonObj; }
private JSONObject specialMove(int gameCount) { Random randomNum = new Random(); GameInfo gameInfo; JSONObject jObj = new JSONObject(); JSONObject action = new JSONObject(); int game; int addPoints; int special; // Gets random number to denote which game to use action on game = getRandomGame(gameCount); gameInfo = gameRecord.get(game); // Checks if all specials are used if (gameInfo.checkSpecial()) { return moveUser(gameCount); } // Gets random number to denote which special move to use special = randomNum.nextInt(4); while (gameInfo.checkSpecialMove(special)) { special = randomNum.nextInt(4); } gameInfo.useSpecialMove(special); addPoints = randomNum.nextInt(41) - 20; gameInfo.addPoints(addPoints); gameInfo.incrementCount(); try { jObj.put("game", game); action.put("actionType", "specialMove"); action.put("actionNumber", gameInfo.getCount()); action.put("pointsAdded", addPoints); if (special == SHUFFLE) { action.put("move", "Shuffle"); } else if (special == CLEAR) { action.put("move", "Clear"); } else if (special == INVERT) { action.put("move", "Invert"); } else { action.put("move", "Rotate"); } action.put("points", gameInfo.getPoints()); jObj.put("action", action); jObj.put("user", gameInfo.getUser()); } catch (JSONException e) { System.out.println("could not put"); } return jObj; }
@Before public void synchronizeFeatureTypeAndLoadInfo() throws JSONException { Layer layer = applicationLayer.getService().getSingleLayer(applicationLayer.getLayerName()); if (layer == null) { getContext() .getValidationErrors() .addGlobalError( new SimpleError( "Laag niet gevonden bij originele service - verwijder deze laag uit niveau")); return; } for (StyleLibrary sld : layer.getService().getStyleLibraries()) { Map style = new HashMap(); JSONObject styleTitleJson = new JSONObject(); style.put("id", "sld:" + sld.getId()); style.put( "title", "SLD stijl: " + sld.getTitle() + (sld.isDefaultStyle() ? " (standaard)" : "")); // Find stuff for layerName if (sld.getNamedLayerUserStylesJson() != null) { JSONObject sldNamedLayerJson = new JSONObject(sld.getNamedLayerUserStylesJson()); if (sldNamedLayerJson.has(layer.getName())) { JSONObject namedLayer = sldNamedLayerJson.getJSONObject(layer.getName()); if (namedLayer.has("title")) { styleTitleJson.put("namedLayerTitle", namedLayer.get("title")); } JSONArray userStyles = namedLayer.getJSONArray("styles"); if (userStyles.length() > 0) { JSONObject userStyle = userStyles.getJSONObject(0); if (userStyle.has("title")) { styleTitleJson.put("styleTitle", userStyle.get("title")); } } } } styles.add(style); stylesTitleJson.put((String) style.get("id"), styleTitleJson); } if (layer.getDetails().containsKey(Layer.DETAIL_WMS_STYLES)) { JSONArray wmsStyles = new JSONArray(layer.getDetails().get(Layer.DETAIL_WMS_STYLES).getValue()); for (int i = 0; i < wmsStyles.length(); i++) { JSONObject wmsStyle = wmsStyles.getJSONObject(i); Map style = new HashMap(); style.put("id", "wms:" + wmsStyle.getString("name")); style.put( "title", "WMS server stijl: " + wmsStyle.getString("name") + " (" + wmsStyle.getString("title") + ")"); JSONObject styleTitleJson = new JSONObject(); styleTitleJson.put("styleTitle", wmsStyle.getString("title")); styles.add(style); stylesTitleJson.put((String) style.get("id"), styleTitleJson); } } if (!styles.isEmpty()) { List<Map> temp = new ArrayList(); Map s = new HashMap(); s.put("id", "registry_default"); s.put("title", "In gegevensregister als standaard ingestelde SLD"); temp.add(s); s = new HashMap(); s.put("id", "none"); s.put("title", "Geen: standaard stijl van WMS service zelf"); temp.add(s); temp.addAll(styles); styles = temp; } // Synchronize configured attributes with layer feature type if (layer.getFeatureType() == null || layer.getFeatureType().getAttributes().isEmpty()) { applicationLayer.getAttributes().clear(); } else { List<String> attributesToRetain = new ArrayList(); SimpleFeatureType sft = layer.getFeatureType(); editable = sft.isWriteable(); // Rebuild ApplicationLayer.attributes according to Layer FeatureType // New attributes are added at the end of the list; the original // order is only used when the Application.attributes list is empty // So a feature for reordering attributes per applicationLayer is // possible. // New Attributes from a join or related featureType are added at the // end of the list. attributesToRetain = rebuildAttributes(sft); // JSON info about attributed required for editing makeAttributeJSONArray(layer.getFeatureType()); // Remove ConfiguredAttributes which are no longer present List<ConfiguredAttribute> attributesToRemove = new ArrayList(); for (ConfiguredAttribute ca : applicationLayer.getAttributes()) { if (ca.getFeatureType() == null) { ca.setFeatureType(layer.getFeatureType()); } if (!attributesToRetain.contains(ca.getFullName())) { // Do not modify list we are iterating over attributesToRemove.add(ca); if (!"save".equals(getContext().getEventName())) { getContext() .getMessages() .add( new SimpleMessage( "Attribuut \"{0}\" niet meer beschikbaar in attribuutbron: wordt verwijderd na opslaan", ca.getAttributeName())); } } } for (ConfiguredAttribute ca : attributesToRemove) { applicationLayer.getAttributes().remove(ca); Stripersist.getEntityManager().remove(ca); } } }
public void doRequest(int type) { switch (type) { case REQUEST_SESSION: { String time = new Long(new Date().getTime()).toString(); String timestamp = time.substring(0, time.length() - 3); String postParam = "application_id=" + PUSH_APP_ID + "&auth_key=" + PUSH_AUTH_KEY + "&nonce=" + nonce + "×tamp=" + timestamp; String signature = ""; try { signature = QBUtils.hmacsha1(PUSH_AUTH_SECRET, postParam); } catch (Exception ex) { DebugStorage.getInstance().Log(0, "<PushAuthScreen> doRequest REQUEST_SESSION ", ex); break; } JSONObject postObject = new JSONObject(); try { postObject.put("application_id", PUSH_APP_ID); postObject.put("auth_key", PUSH_AUTH_KEY); postObject.put("nonce", nonce); postObject.put("timestamp", timestamp); postObject.put("signature", signature); } catch (Exception ex) { DebugStorage.getInstance().Log(0, "<PushAuthScreen> doRequest REQUEST_SESSION ", ex); } BigVector postData = new BigVector(); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager(POST, PUSH_SERVER_API + "session.json", postData, type, this); break; } case REQUEST_SIGN_UP_USER: { String pin = Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase(); JSONObject credentialsObject = new JSONObject(); JSONObject postObject = new JSONObject(); try { credentialsObject.put("login", pin); credentialsObject.put("password", TextUtils.reverse(pin)); postObject.put("user", credentialsObject); } catch (Exception ex) { } BigVector postData = new BigVector(); postData.addElement(TOKEN); postData.addElement(postObject.toString()); DebugStorage.getInstance().Log(0, "Post data: " + postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager(POST, PUSH_SERVER_API + "users.json", postData, type, this); break; } case REQUEST_SESSION_WITH_USER_AND_DEVICE_PARAMS: { JSONObject postObject = new JSONObject(); JSONObject userObject = new JSONObject(); JSONObject deviceObject = new JSONObject(); try { String pin = Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase(); String postParam = "application_id=" + PUSH_APP_ID + "&auth_key=" + PUSH_AUTH_KEY + "&device[platform]=" + "blackberry" + "&device[udid]=" + pin + "&nonce=" + nonce + "×tamp=" + timestamp + "&user[login]=" + pin + "&user[password]=" + TextUtils.reverse(pin); String signature = ""; try { signature = QBUtils.hmacsha1(PUSH_AUTH_SECRET, postParam); } catch (Exception ex) { System.out.println("QBUtils.hmacsha1(PUSH_AUTH_SECRET, postParam) exception = " + ex); } postObject.put("application_id", PUSH_APP_ID); postObject.put("auth_key", PUSH_AUTH_KEY); postObject.put("timestamp", timestamp); postObject.put("nonce", nonce); postObject.put("signature", signature); userObject.put("login", pin); userObject.put("password", TextUtils.reverse(pin)); postObject.put("user", userObject); deviceObject.put("platform", "blackberry"); deviceObject.put("udid", pin); postObject.put("device", deviceObject); } catch (Exception ex) { DebugStorage.getInstance().Log(0, "<PushAuthScreen> doRequest REQUEST_SESSION ", ex); onClose(); } BigVector postData = new BigVector(); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager(POST, PUSH_SERVER_API + "session.json", postData, type, this); break; } case REQUEST_PUSH_TOKEN: { String pin = Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase(); JSONObject credentialsObject = new JSONObject(); JSONObject postObject = new JSONObject(); try { // credentialsObject.put("environment", "production"); credentialsObject.put("environment", "development"); credentialsObject.put("client_identification_sequence", pin); postObject.put("push_token", credentialsObject); } catch (Exception ex) { System.out.println("-----<doRequest><REQUEST_PUSH_TOKEN> Exception = " + ex); } BigVector postData = new BigVector(); postData.addElement(TOKEN); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager( POST, PUSH_SERVER_API + "push_tokens.json", postData, type, this); break; } // REQUEST_PUSH_SUBSCRIBE case REQUEST_PUSH_SUBSCRIBE: { System.out.println("-----<doRequest><REQUEST_PUSH_SUBSCRIBE>"); JSONObject postObject = new JSONObject(); try { postObject.put("notification_channels", "bbps"); } catch (Exception ex) { System.out.println("-----<doRequest><REQUEST_PUSH_SUBSCRIBE> Exception = " + ex); } BigVector postData = new BigVector(); postData.addElement(TOKEN); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager( POST, PUSH_SERVER_API + "subscriptions.json", postData, type, this); break; } default: break; } }