예제 #1
0
  /** 基类实现消息监听接口,加上打印metaq监控日志的方法 */
  @Override
  public ConsumeConcurrentlyStatus consumeMessage(
      List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
    long startTime = System.currentTimeMillis();
    logger.info("receive_message:{}", msgs.toString());
    if (msgs == null || msgs.size() < 1) {
      logger.error("receive empty msg!");
      return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
    }

    List<Serializable> msgList = new ArrayList<>();
    for (MessageExt message : msgs) {
      msgList.add(decodeMsg(message));
    }

    final int reconsumeTimes = msgs.get(0).getReconsumeTimes();
    MsgObj msgObj = new MsgObj();
    msgObj.setReconsumeTimes(reconsumeTimes);
    msgObj.setMsgList(msgList);
    msgObj.setContext(context);
    context.setDelayLevelWhenNextConsume(getDelayLevelWhenNextConsume(reconsumeTimes));

    ConsumeConcurrentlyStatus status = doConsumeMessage(msgObj);
    logger.info(
        "ConsumeConcurrentlyStatus:{}|cost:{}", status, System.currentTimeMillis() - startTime);
    return status;
  }
예제 #2
0
  /** @param aProperties the updated properties. */
  @SuppressWarnings("rawtypes")
  final void setProperties(final Dictionary aProperties) {
    final Map<String, String> newProps = new HashMap<String, String>();

    Enumeration keys = aProperties.keys();
    while (keys.hasMoreElements()) {
      final String key = (String) keys.nextElement();
      if (!KNOWN_KEYS.contains(key) && !IGNORED_KEYS.contains(key)) {
        LOG.log(Level.WARNING, "Unknown/unsupported profile key: " + key);
        continue;
      }

      final String value = aProperties.get(key).toString();
      newProps.put(key, value.trim());
    }

    // Verify whether all known keys are defined...
    final List<String> checkedKeys = new ArrayList<String>(KNOWN_KEYS);
    checkedKeys.removeAll(newProps.keySet());
    if (!checkedKeys.isEmpty()) {
      throw new IllegalArgumentException(
          "Profile settings not complete! Missing keys are: " + checkedKeys.toString());
    }

    this.properties.putAll(newProps);

    LOG.log(
        Level.INFO,
        "New device profile settings applied for {1} ({0}) ...", //
        new Object[] {getType(), getDescription()});
  }
 protected void setValidationErrorMessage(
     List<org.kuali.coeus.s2sgen.api.core.AuditError> errors) {
   if (errors != null) {
     LOG.info("Error list size:" + errors.size() + errors.toString());
     List<org.kuali.rice.krad.util.AuditError> auditErrors = new ArrayList<>();
     for (org.kuali.coeus.s2sgen.api.core.AuditError error : errors) {
       auditErrors.add(
           new org.kuali.rice.krad.util.AuditError(
               error.getErrorKey(),
               Constants.GRANTS_GOV_GENERIC_ERROR_KEY,
               error.getLink(),
               new String[] {error.getMessageKey()}));
     }
     if (!auditErrors.isEmpty()) {
       getGlobalVariableService()
           .getAuditErrorMap()
           .put(
               "grantsGovAuditErrors",
               new AuditCluster(
                   Constants.GRANTS_GOV_OPPORTUNITY_PANEL,
                   auditErrors,
                   Constants.GRANTSGOV_ERRORS));
     }
   }
 }
 /** toString contains toString of elements */
 public void testToString() {
   List full = populatedArray(3);
   String s = full.toString();
   for (int i = 0; i < 3; ++i) {
     assertTrue(s.indexOf(String.valueOf(i)) >= 0);
   }
 }
예제 #5
0
 public void testListToString() throws Exception {
   removeAll(Book.class);
   // Create
   Book book = new Book("Starship internals", "1-3-5-7");
   getStore().save(book);
   // Select ref1
   List result = getStore().find("find book");
   result.toString();
 }
예제 #6
0
 public static <T> void show(String title, Stream<T> stream) {
   final int SIZE = 10;
   List<T> firstElements = stream.limit(SIZE + 1).collect(Collectors.toList());
   System.out.print(title + ": ");
   if (firstElements.size() <= SIZE) System.out.println(firstElements);
   else {
     firstElements.remove(SIZE);
     String out = firstElements.toString();
     System.out.println(out.substring(0, out.length() - 1) + ", ...]");
   }
 }
  private void jsonReadContElements(JsonReader jReader) throws IOException {
    jReader.beginObject();
    List<String> loadedLfs = new ArrayList<>();
    boolean exceptForDecimal5Raised = false;
    boolean enumChecked = false;
    boolean bitsChecked = false;
    boolean lfdecimal6Checked = false;
    boolean lfdecimal4Checked = false;
    boolean lfdecimal3Checked = false;
    boolean lfdecimal2Checked = false;
    boolean lfdecimal1Checked = false;
    boolean lfbool1Checked = false;
    boolean lfbool2Checked = false;
    boolean lfstrChecked = false;
    boolean lfbinaryChecked = false;
    // boolean lfref1Checked = false;
    boolean lfemptyChecked = false;
    boolean lfstr1Checked = false;

    while (jReader.hasNext()) {
      String keyName = jReader.nextName();
      JsonToken peek = null;
      try {
        peek = jReader.peek();
      } catch (IOException e) {
        if (keyName.equals("lfdecimal5")) {
          exceptForDecimal5Raised = true;
        } else {
          assertTrue("Key " + keyName + " has incorrect value for specifed type", false);
        }
      }

      if (keyName.startsWith("lfnint") || keyName.startsWith("lfnuint")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        try {
          jReader.nextLong();
        } catch (NumberFormatException e) {
          assertTrue("Key " + keyName + " has incorrect value - " + e.getMessage(), false);
        }
        loadedLfs.add(keyName.substring(3));
      } else if (keyName.equals("lfstr")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.STRING, peek);
        assertEquals("lfstr", jReader.nextString());
        lfstrChecked = true;
      } else if (keyName.equals("lfstr1")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.STRING, peek);
        assertEquals("", jReader.nextString());
        lfstr1Checked = true;
      } else if (keyName.equals("lfbool1")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.BOOLEAN, peek);
        assertEquals(true, jReader.nextBoolean());
        lfbool1Checked = true;
      } else if (keyName.equals("lfbool2")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.BOOLEAN, peek);
        assertEquals(false, jReader.nextBoolean());
        lfbool2Checked = true;
      } else if (keyName.equals("lfbool3")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.BOOLEAN, peek);
        assertEquals(false, jReader.nextBoolean());
      } else if (keyName.equals("lfdecimal1")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(43.32), (Double) jReader.nextDouble());
        lfdecimal1Checked = true;
      } else if (keyName.equals("lfdecimal2")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(-0.43), (Double) jReader.nextDouble());
        lfdecimal2Checked = true;
      } else if (keyName.equals("lfdecimal3")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(43), (Double) jReader.nextDouble());
        lfdecimal3Checked = true;
      } else if (keyName.equals("lfdecimal4")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(43E3), (Double) jReader.nextDouble());
        lfdecimal4Checked = true;
      } else if (keyName.equals("lfdecimal6")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(33.12345), (Double) jReader.nextDouble());
        lfdecimal6Checked = true;
      } else if (keyName.equals("lfenum")) {
        assertEquals("enum3", jReader.nextString());
        enumChecked = true;
      } else if (keyName.equals("lfbits")) {
        assertEquals("bit3", jReader.nextString());
        bitsChecked = true;
      } else if (keyName.equals("lfbinary")) {
        assertEquals(
            "AAaacdabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%%-#^",
            jReader.nextString());
        lfbinaryChecked = true;
      } else if (keyName.equals("lfempty")) {
        jReader.beginArray();
        jReader.nextNull();
        jReader.endArray();
        lfemptyChecked = true;
      } else if (keyName.startsWith("lfunion")) {
        checkLfUnion(jReader, keyName, peek);
      } else {
        assertTrue("Key " + keyName + " doesn't exists in yang file.", false);
      }
    }
    Collections.sort(loadedLfs);
    String expectedLfsStr =
        "[int16Max, int16Min, int32Max, int32Min, int64Max, int64Min, int8Max, int8Min, uint16Max, uint32Max, uint8Max]";
    String actualLfsStr = loadedLfs.toString();
    assertEquals("Some leaves are missing", expectedLfsStr, actualLfsStr);
    // assertTrue("For lfdecimal5 wasn't catch error",exceptForDecimal5Raised);
    assertTrue("Enum wasn't checked", enumChecked);
    assertTrue("Bits wasn't checked", bitsChecked);
    assertTrue("Decimal1 wasn't checked", lfdecimal1Checked);
    assertTrue("Decimal2 wasn't checked", lfdecimal2Checked);
    assertTrue("Decimal3 wasn't checked", lfdecimal3Checked);
    assertTrue("Decimal4 wasn't checked", lfdecimal4Checked);
    assertTrue("Decimal5 wasn't checked", lfdecimal6Checked);
    assertTrue("lfbool1 wasn't checked", lfbool1Checked);
    assertTrue("lfbool2 wasn't checked", lfbool2Checked);
    assertTrue("lfstr wasn't checked", lfstrChecked);
    assertTrue("lfstr1 wasn't checked", lfstr1Checked);
    assertTrue("lfbinary wasn't checked", lfbinaryChecked);
    assertTrue("lfempty wasn't checked", lfemptyChecked);
    // assertTrue("lfref1 wasn't checked", lfref1Checked);

    jReader.endObject();
  }
예제 #8
0
  public void nextLevel() {
    boolean loaded = false;
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    this.level++;

    AssetManager am = getResources().getAssets();

    try {
      List<String> allTutoLevels =
          new LinkedList<String>(Arrays.asList(am.list("levels/tutorial")));

      // if(addMsg){
      //    allTutoLevels.addAll(Arrays.asList(am.list("msg")));
      // }

      Log.d(TAG, allTutoLevels.toString());

      for (String name : allTutoLevels) {
        if (name.startsWith(this.level + ".")) {
          BufferedReader br =
              new BufferedReader(new InputStreamReader(am.open("levels/tutorial/" + name)));
          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
          loaded = true;
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (!loaded) {
      Random r = new Random();

      List<String> allLevels = new ArrayList<>();

      try {
        allLevels = Arrays.asList(am.list("levels"));
      } catch (IOException e) {
      }

      if (r.nextBoolean() && !allLevels.isEmpty() && allLevels.size() != allDoneLevels.size()) {
        try {
          int nLevel;
          do {
            nLevel = r.nextInt(allLevels.size());
          } while (allDoneLevels.contains(allLevels.get(nLevel)));

          String name = allLevels.get(nLevel);
          BufferedReader br = new BufferedReader(new InputStreamReader(am.open("levels/" + name)));

          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          allDoneLevels.add(name);

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        } catch (IOException e) {
          this.game.initGame(
              level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        }
      } else {
        this.game.initGame(
            level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
      }
    }

    // am.close();

    boardView.setGame(this.game);
    boardView.invalidate();
    boardView.getHowdyShadeView().invalidate();

    Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();

    Log.i(
        TAG,
        "Max tiles : "
            + (boardView.getMeasuredWidth() / 60) * (boardView.getMeasuredHeight() / 60));
  }
예제 #9
0
  private void loadArgs(String[] args) throws ParameterProblem {

    logger.debug("Parsing command line arguments");
    final CommandLineParser parser = new PosixParser();

    final Opts opts = new Opts();
    final CommandLine line;
    try {
      line = parser.parse(opts.getOptions(), args);
    } catch (ParseException e) {
      throw new ParameterProblem(e.getMessage(), e);
    }

    // figure action first
    AdminAction theAction = null;
    for (AdminAction a : AdminAction.values()) {
      if (line.hasOption(a.option())) {
        if (theAction == null) {
          theAction = a;
        } else {
          throw new ParameterProblem("You may only specify a single action");
        }
      }
    }

    if (theAction == null) {
      throw new ParameterProblem("You must specify an action");
    }

    this.action = theAction;
    logger.debug("Action: " + theAction);

    // short circuit for --help arg
    if (theAction == AdminAction.Help) {
      return;
    }

    // then action-specific arguments
    if (theAction == AdminAction.AddNodes || theAction == AdminAction.UpdateNodes) {
      this.hosts = parseHosts(line.getOptionValue(theAction.option()));

      if (line.hasOption(Opts.MEMORY)) {
        final String memString = line.getOptionValue(Opts.MEMORY);
        if (memString == null || memString.trim().length() == 0) {
          throw new ParameterProblem("Node memory value is empty");
        }
        this.nodeMemory = parseMemory(memString);
        this.nodeMemoryConfigured = true;
      }

      if (line.hasOption(Opts.NETWORKS)) {
        this.nodeNetworks = line.getOptionValue(Opts.NETWORKS);
      }

      if (line.hasOption(Opts.POOL)) {
        String pool = line.getOptionValue(Opts.POOL);
        if (pool == null || pool.trim().length() == 0) {
          throw new ParameterProblem("Node pool value is empty");
        }
        this.nodePool = pool.trim();
      }

      final boolean active = line.hasOption(Opts.ACTIVE);
      final boolean inactive = line.hasOption(Opts.INACTIVE);

      if (active && inactive) {
        throw new ParameterProblem(
            "You cannot specify both " + Opts.ACTIVE_LONG + " and " + Opts.INACTIVE_LONG);
      }

      if (active) {
        this.nodeActiveConfigured = true;
      }
      if (inactive) {
        this.nodeActive = false;
        this.nodeActiveConfigured = true;
      }

    } else if (theAction == AdminAction.RemoveNodes) {
      this.hosts = parseHosts(line.getOptionValue(theAction.option()));
    } else if (theAction == AdminAction.ListNodes) {
      final String hostArg = line.getOptionValue(AdminAction.ListNodes.option());
      if (hostArg != null) {
        this.hosts = parseHosts(hostArg);
      }
    } else if (theAction == AdminAction.PoolAvailability) {
      if (line.hasOption(Opts.POOL)) {
        final String pool = line.getOptionValue(Opts.POOL);
        if (pool == null || pool.trim().length() == 0) {
          throw new ParameterProblem("Pool name value is empty");
        }
        this.nodePool = pool;
      }
      if (line.hasOption(Opts.FREE)) {
        this.inUse = RemoteNodeManagement.FREE_ENTRIES;
      }
      if (line.hasOption(Opts.USED)) {
        this.inUse = RemoteNodeManagement.USED_ENTRIES;
      }
    }

    // finally everything else
    if (!line.hasOption(Opts.CONFIG)) {
      throw new ParameterProblem(Opts.CONFIG_LONG + " option is required");
    }
    String config = line.getOptionValue(Opts.CONFIG);
    if (config == null || config.trim().length() == 0) {
      throw new ParameterProblem("Config file path is invalid");
    }
    super.configPath = config.trim();

    final boolean batchMode = line.hasOption(Opts.BATCH);
    final boolean json = line.hasOption(Opts.JSON);

    final Reporter.OutputMode mode;
    if (batchMode && json) {
      throw new ParameterProblem(
          "You cannot specify both " + Opts.BATCH_LONG + " and " + Opts.JSON_LONG);
    } else if (batchMode) {
      mode = Reporter.OutputMode.Batch;
    } else if (json) {
      mode = Reporter.OutputMode.Json;
    } else {
      mode = Reporter.OutputMode.Friendly;
    }

    final String[] fields;
    if (line.hasOption(Opts.REPORT)) {
      fields = parseFields(line.getOptionValue(Opts.REPORT), theAction);
    } else {
      fields = theAction.fields();
    }

    String delimiter = null;
    if (line.hasOption(Opts.DELIMITER)) {
      delimiter = line.getOptionValue(Opts.DELIMITER);
    }

    this.reporter = new Reporter(mode, fields, delimiter);

    if (line.hasOption(Opts.OUTPUT)) {
      final String filename = line.getOptionValue(Opts.OUTPUT);
      final File f = new File(filename);
      try {
        this.outStream = new FileOutputStream(f);
      } catch (FileNotFoundException e) {
        throw new ParameterProblem(
            "Specified output file could not be opened for writing: " + f.getAbsolutePath(), e);
      }
    } else {
      this.outStream = System.out;
    }

    final List leftovers = line.getArgList();
    if (leftovers != null && !leftovers.isEmpty()) {
      throw new ParameterProblem(
          "There are unrecognized arguments, check -h to make "
              + "sure you are doing the intended thing: "
              + leftovers.toString());
    }
  }
예제 #10
0
  private CIJobStatus configureJob(CIJob job, String jobType) throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method CIManagerImpl.createJob(CIJob job)");
    }
    try {
      cli = getCLI(job);
      List<String> argList = new ArrayList<String>();
      argList.add(jobType);
      argList.add(job.getName());

      String jenkinsTemplateDir = Utility.getJenkinsTemplateDir();
      String configFilePath = jenkinsTemplateDir + job.getRepoType() + HYPHEN + CONFIG_XML;
      if (debugEnabled) {
        S_LOGGER.debug("configFilePath ...  " + configFilePath);
      }

      File configFile = new File(configFilePath);
      ConfigProcessor processor = new ConfigProcessor(configFile);
      customizeNodes(processor, job);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      if (debugEnabled) {
        S_LOGGER.debug("argList " + argList.toString());
      }
      int result = cli.execute(argList, processor.getConfigAsStream(), System.out, baos);

      String message = "Job created successfully";
      if (result == -1) {
        byte[] byteArray = baos.toByteArray();
        message = new String(byteArray);
      }
      if (debugEnabled) {
        S_LOGGER.debug("message " + message);
      }
      // when svn is selected credential value has to set
      if (SVN.equals(job.getRepoType())) {
        setSvnCredential(job);
      }

      setMailCredential(job);
      return new CIJobStatus(result, message);
    } catch (IOException e) {
      throw new PhrescoException(e);
    } catch (JDOMException e) {
      throw new PhrescoException(e);
    } finally {
      if (cli != null) {
        try {
          cli.close();
        } catch (IOException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        } catch (InterruptedException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        }
      }
    }
  }
예제 #11
0
  /**
   * Reads the geometry and connectivity.
   *
   * @param filename the location of the gjf file
   */
  public GJFfile(String filename) {
    super(filename);

    // read geometry
    String name = "";
    List<Atom> contents = new ArrayList<>();
    SimpleWeightedGraph<Atom, DefaultWeightedEdge> connectivity =
        new SimpleWeightedGraph<>(DefaultWeightedEdge.class);
    int blanks = 0;
    boolean lastBlank = false;
    boolean inGeometryBlock = false;
    for (List<String> line : fileContents) {
      // keep track of how many blanks we have seen
      if (line.size() == 1 && line.get(0).length() == 0) {
        if (lastBlank == false) {
          blanks++;
          lastBlank = true;
        }
        continue;
      } else lastBlank = false;

      // read the metadata
      if (blanks == 1) {
        for (String s : line) {
          String[] fields = s.split("@");
          if (fields.length != 3) continue;
          String identifier = fields[1].toLowerCase();
          String value = fields[2];
          // System.out.println(s);
          // System.out.println(identifier + " : " + value);

          if (identifier.equals("o1")) O1Number = Integer.parseInt(value);
          else if (identifier.equals("o2")) O2Number = Integer.parseInt(value);
          else if (identifier.equals("n3")) N3Number = Integer.parseInt(value);
          else if (identifier.equals("cl1")) Cl1Number = Integer.parseInt(value);
          else if (identifier.equals("su2")) Su2Number = Integer.parseInt(value);
          else if (identifier.equals("ol3")) Ol3Number = Integer.parseInt(value);
          else if (identifier.equals("mem")) mem = Integer.parseInt(value);
          else if (identifier.equals("nprocshared")) nprocshared = Integer.parseInt(value);
          else if (identifier.equals("method")) method = value;
          else if (identifier.equals("basis")) basis = value;
          else System.out.println("unrecognized entry: " + s);
        }

        continue;
      } else if (blanks != 2) continue;

      // deal with the charge and multiplicity card (by ignoring it)
      if (line.size() == 2 && inGeometryBlock == false) {
        inGeometryBlock = true;
        continue;
      }

      if (line.size() != 4 && inGeometryBlock == false)
        throw new IllegalArgumentException(
            "unexpected text in geometry block in " + filename + ":\n" + line.toString());

      // create atom
      // tinker atom types will be nonsense, of course
      Atom newAtom =
          new Atom(
              line.get(0),
              new Vector3D(
                  Double.parseDouble(line.get(1)),
                  Double.parseDouble(line.get(2)),
                  Double.parseDouble(line.get(3))),
              1);
      contents.add(newAtom);
      connectivity.addVertex(newAtom);
    }

    // read connectivity
    blanks = 0;
    lastBlank = false;
    for (List<String> line : fileContents) {
      // read the fourth block of text
      if (line.size() == 1 && line.get(0).length() == 0) {
        if (lastBlank == false) {
          blanks++;
          lastBlank = true;
        }
        continue;
      } else lastBlank = false;

      // only read connectivity lines
      if (blanks != 3) continue;

      Atom fromAtom = contents.get(Integer.parseInt(line.get(0)) - 1);
      for (int i = 1; i < line.size(); i += 2) {
        int toAtomIndex = Integer.parseInt(line.get(i)) - 1;
        Atom toAtom = contents.get(toAtomIndex);
        double bondOrder = Double.parseDouble(line.get(i + 1));
        DefaultWeightedEdge thisEdge = connectivity.addEdge(fromAtom, toAtom);
        connectivity.setEdgeWeight(thisEdge, bondOrder);
      }
    }

    // create the molecule
    molecule = new Molecule(name, contents, connectivity, 0.0);
  }
예제 #12
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      JSONParser parser = new JSONParser();
      String originalRouteJsonString = request.getParameter("originalroutejsontext");
      JSONObject originalRouteJsonObject = (JSONObject) parser.parse(originalRouteJsonString);
      JSONObject routes = (JSONObject) ((JSONArray) originalRouteJsonObject.get("routes")).get(0);
      JSONArray legs = (JSONArray) routes.get("legs");
      JSONArray steps = (JSONArray) ((JSONObject) legs.get(0)).get("steps");

      String routeID = request.getParameter("routeid");
      // System.out.println("Route steps loaded in a JSONArray...size is " + steps.size());

      List<Double> stepLats = new ArrayList<Double>();
      List<Double> stepLngs = new ArrayList<Double>();

      for (int i = 0; i < steps.size(); i++) {
        JSONObject temp = (JSONObject) ((JSONObject) steps.get(i)).get("end_location");
        // System.out.println("Lat of end_location of step " + i + " " + temp.get("lat"));
        stepLats.add(Double.parseDouble(temp.get("lat").toString()));
        stepLngs.add(Double.parseDouble(temp.get("lng").toString()));
      }
      // System.out.println("All steps set with size " + stepLngs.size() + " and " +
      // stepLats.size());

      // System.out.println("Skipping route boxer...");
      // RouteBoxer routeBoxer = new RouteBoxer(stepLats, stepLngs,
      // Double.parseDouble(request.getParameter("radius")));

      // if(routeBoxer.getFlag())
      //  throw new RuntimeException("Could not create boxes for the route");

      // List<Double> boxLats = routeBoxer.getLats();
      // List<Double> boxLngs = routeBoxer.getLngs();

      // System.out.println("Calculated boxes with number of lats " + boxLats.size() + " and number
      // of lngs " + boxLngs.size());

      double r = Double.parseDouble(request.getParameter("radius").toString());
      int radius = r > RADIUS_TO_LOOK_FOR_PLACES ? RADIUS_TO_LOOK_FOR_PLACES : (int) r;

      String[] types = request.getParameter("keywords").split(",");
      System.out.println("Size of types is " + types.length);

      JSONObject finalPlacesJSONObject = new JSONObject();

      for (int j = 0; j < types.length; j++) {
        JSONArray jsonArrayForType = new JSONArray();

        for (int i = 0; i < stepLats.size(); i++) {
          JSONObject placesAroundLocationJSONObject =
              (JSONObject)
                  parser.parse(
                      GoogleMap.getPlacesAroundLocation(
                          stepLats.get(i), stepLngs.get(i), radius, types[j]));
          JSONArray placesAroundLocationJSONArray =
              (JSONArray) placesAroundLocationJSONObject.get("results");

          if (!placesAroundLocationJSONArray.isEmpty()) {
            jsonArrayForType.addAll(placesAroundLocationJSONArray);
          }
        }
        finalPlacesJSONObject.put(types[j], jsonArrayForType);
      }
      List<String> place_ids = new ArrayList<String>();

      finalPlacesJSONObject = removeDuplicatePlaces(finalPlacesJSONObject);
      finalPlacesJSONObject =
          filterPlacesRandomly(finalPlacesJSONObject, FINAL_PLACES_NUMBER_PER_REQUEST, place_ids);

      // System.out.println("MAGIC " + place_ids.toString());
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
      MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();

      // add places as a property of original route entity
      Entity originalRouteEntity =
          datastore.get(KeyFactory.createKey("Route", Long.parseLong(routeID)));
      Text placesJsonAsText = new Text(finalPlacesJSONObject.toJSONString());
      originalRouteEntity.setProperty("placesJSON", placesJsonAsText);
      datastore.put(originalRouteEntity);
      // System.out.println("SUCCESS written places to datastore");

      // add task for fetching place reviews to queue
      QueueFactory.getDefaultQueue()
          .add(
              TaskOptions.Builder.withUrl("/waypointsreview")
                  .param("places", place_ids.toString()));

      System.out.println("Task to get reviews added to queue");
      // We cache the route entity
      String cacheKey = "route-" + routeID;
      syncCache.put(cacheKey, originalRouteEntity);
    } catch (Exception e) {
      System.out.println("ERROR " + e.getMessage());
      e.printStackTrace();
    }
  }