Пример #1
0
  private void initAuthUserInfo(HttpURLConnection conn, String userInfo) {
    String user;
    String password;
    if (userInfo != null) { // get the user and password
      // System.out.println("UserInfo= " + userInfo );
      int delimiter = userInfo.indexOf(':');
      if (delimiter == -1) {
        user = ParseUtil.decode(userInfo);
        password = null;
      } else {
        user = ParseUtil.decode(userInfo.substring(0, delimiter++));
        password = ParseUtil.decode(userInfo.substring(delimiter));
      }

      String plain = user + ":";
      byte[] nameBytes = plain.getBytes();
      byte[] passwdBytes = password.getBytes();

      // concatenate user name and password bytes and encode them
      byte[] concat = new byte[nameBytes.length + passwdBytes.length];

      System.arraycopy(nameBytes, 0, concat, 0, nameBytes.length);
      System.arraycopy(passwdBytes, 0, concat, nameBytes.length, passwdBytes.length);
      String auth = "Basic " + new String(Base64.encode(concat));
      conn.setRequestProperty("Authorization", auth);
      if (dL > 0) d("Adding auth " + auth);
    }
  }
 /*.................................................................................................................*/
 public void fromString(String description, MesquiteInteger stringPos, int format) {
   hasDefaultValues = false;
   ParseUtil.getToken(description, stringPos); // RMatrix
   ParseUtil.getToken(description, stringPos); // =
   ParseUtil.getToken(description, stringPos); // (
   for (int i = 0; i < getNumStates(); i++) {
     String s = ParseUtil.getToken(description, stringPos);
     if (s.equalsIgnoreCase(")") || StringUtil.blank(s)) return;
     setStateFreq(i, MesquiteDouble.fromString(s));
   }
   checkNormality(getStateFrequencies());
 }
 /*.................................................................................................................*/
 public Snapshot getSnapshot(MesquiteFile file) {
   Snapshot temp = new Snapshot();
   temp.addLine("setRunningFilePath " + ParseUtil.tokenize(runningFilePath));
   if (outputFilePaths != null) {
     String files = " ";
     for (int i = 0; i < outputFilePaths.length; i++) {
       files += " " + ParseUtil.tokenize(outputFilePaths[i]);
     }
     temp.addLine("setOutputFilePaths " + files);
   }
   return temp;
 }
Пример #4
0
  @Override
  public Node parse(Token token) throws IOException {
    AttrNode node = null;
    if (ExpressionParser.START.contains(token.type())) {
      node = new AttrNode(startLine());
      token = tokenizer().peek();
      Token var = tokenizer().current();
      if (ATTR.contains(token.type())) {
        boolean first = true;
        while (ATTR.contains(token.type())) {
          Node n = null;
          if (tokenizer().peek().type() == TokenType.LEFT_PAREN) {
            CallParser call = new CallParser(this);
            n = call.parse(var);
          } else if (ExpressionParser.START.contains(var.type())) {
            if (first) {
              n = ParseUtil.value(var);
              first = false;
            } else {
              n = ParseUtil.var(var);
            }
          } else {
            error(ErrorCode.INVALID_EXPR);
          }

          if (n != null) {
            node.add(n);
            token = tokenizer().next();
            if (ATTR.contains(token.type())) {
              var = tokenizer().next();
            }
          }
        }
      } else if (tokenizer().current().type() == TokenType.LEFT_BRACKET) {
        ArrayParser arrp = new ArrayParser(this);
        Node n = arrp.parse(tokenizer().current());
        node.add(n);
      } else {
        node.add(ParseUtil.value(tokenizer().current()));
        tokenizer().next();
      }

    } else {
      error(ErrorCode.INVALID_EXPR);
    }

    return node;
  }
Пример #5
0
        @Override
        public void parse(String line, ParseState state) throws ParseException {
          super.parse(line, state);

          final Matcher matcher = match(Constants.EXT_X_VERSION_PATTERN, line);

          if (state.getCompatibilityVersion() != ParseState.NONE) {
            throw ParseException.create(
                ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES, getTag(), line);
          }

          final int compatibilityVersion = ParseUtil.parseInt(matcher.group(1), getTag());

          if (compatibilityVersion < Playlist.MIN_COMPATIBILITY_VERSION) {
            throw ParseException.create(
                ParseExceptionType.INVALID_COMPATIBILITY_VERSION, getTag(), line);
          }

          if (compatibilityVersion > Constants.MAX_COMPATIBILITY_VERSION) {
            throw ParseException.create(
                ParseExceptionType.UNSUPPORTED_COMPATIBILITY_VERSION, getTag(), line);
          }

          state.setCompatibilityVersion(compatibilityVersion);
        }
  public void actionPerformed(ActionEvent e) {

    // --SEND/GET UPDATE(s) FROM SERVER-- Called whenever timer goes off (every 5 sec.)

    // ==== SEND ALL OF THE MESSAGES WE HAVE ====
    comm.sendOutboxMessages();
    // ==== SEND A REQUEST FOR A UNIVERSAL UPDATE ====
    comm.sendMessage("REQUEST");
    // ==== RECIEVE THE UNIVERSE/ROSTER/MARKET UPDATES ====
    ArrayList<String> responses = comm.getAllMessages();
    // ==== HERE IS WHERE WE UNPACK THE UPDATES FROM THE SERVER ====
    for (int q = 0; q < responses.size(); q++) {
      String header = responses.get(q).substring(0, 4);

      if (header.equals("UNIV")) {
        theUniverse.unpack(responses.get(q));
        Debug.msg("Unpacked a Universe");
        theDisplay.updateDisplay();
      } else if (header.equals("ROST")) {
        Roster.unpack(responses.get(q));
      } else if (header.equals("MARK")) {
        theMarket.unpack(responses.get(q));
      } else if (header.equals("SERV")) {
        Vector inParsed = ParseUtil.parseStringBySign(responses.get(q), '-');
        myPlayerNum = Integer.parseInt((String) inParsed.elementAt(1));
      } else Debug.msg("Unknown header recieved in ClientMain.actionPerformed() ");
    }
  }
 @Override
 public ModulePart deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
     throws JsonParseException {
   JsonObject jsonObject = json.getAsJsonObject();
   if (!jsonObject.has("type")) {
     return ParseUtil.throwIfDebug("Invalid module part");
   }
   String type = jsonObject.get("type").getAsString();
   switch (type) {
     case "figure-group":
       return context.deserialize(json, FigureGroup.class);
     case "module-body":
       return context.deserialize(json, ModuleBody.class);
     default:
       return ParseUtil.throwIfDebug("Unrecognized ModulePart with type: " + type);
   }
 }
        @Override
        public void parse(String line, ParseState state) throws ParseException {
          super.parse(line, state);

          final Matcher matcher = match(Constants.EXTINF_PATTERN, line);

          state.getMedia().trackInfo =
              new TrackInfo(ParseUtil.parseFloat(matcher.group(1), getTag()), matcher.group(2));
        }
 TimeZoneJSONImpl(JSONObject jSONObject) throws TwitterException {
   try {
     UTC_OFFSET = ParseUtil.getInt("utc_offset", jSONObject);
     NAME = jSONObject.getString("name");
     TZINFO_NAME = jSONObject.getString("tzinfo_name");
   } catch (JSONException jsone) {
     throw new TwitterException(jsone);
   }
 }
  public void unpack(String data) {

    Vector inParsed = ParseUtil.parseStringBySign(data, PARSE_CHAR);
    String header = (String) inParsed.elementAt(0);
    if (header.equals("SHIP")) {
      playerNum = Integer.parseInt((String) inParsed.elementAt(1));
      numShips = Integer.parseInt((String) inParsed.elementAt(2));
      destX = Integer.parseInt((String) inParsed.elementAt(3));
      destY = Integer.parseInt((String) inParsed.elementAt(4));
    }
  }
Пример #11
0
 <T> void parseAttributes(
     String line, T builder, ParseState state, Map<String, ? extends AttributeParser<T>> handlers)
     throws ParseException {
   for (Attribute attribute : ParseUtil.parseAttributeList(line, getTag())) {
     if (handlers.containsKey(attribute.name)) {
       handlers.get(attribute.name).parse(attribute, builder, state);
     } else {
       throw ParseException.create(ParseExceptionType.INVALID_ATTRIBUTE_NAME, getTag(), line);
     }
   }
 }
 private void appendElementString(StringBuilder sb, String localName, XmlPullParser atts) {
   sb.append("<");
   sb.append(localName);
   for (int i = 0; i < atts.getAttributeCount(); i++) {
     sb.append(" ");
     sb.append(atts.getAttributeName(i));
     sb.append("='");
     sb.append(ParseUtil.escape(atts.getAttributeValue(i)));
     sb.append("'");
   }
   sb.append(">");
 }
Пример #13
0
        @Override
        public void parse(String line, ParseState state) throws ParseException {
          super.parse(line, state);

          final Matcher matcher = match(Constants.EXT_X_TARGETDURATION_PATTERN, line);

          if (state.getMedia().targetDuration != null) {
            throw ParseException.create(
                ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES, getTag(), line);
          }

          state.getMedia().targetDuration = ParseUtil.parseInt(matcher.group(1), getTag());
        }
Пример #14
0
        @Override
        public void parse(String line, ParseState state) throws ParseException {
          super.parse(line, state);

          final Matcher matcher = match(Constants.EXT_X_MEDIA_SEQUENCE_PATTERN, line);

          if (state.getMedia().mediaSequenceNumber != null) {
            throw ParseException.create(
                ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES, getTag(), line);
          }

          state.getMedia().mediaSequenceNumber = ParseUtil.parseInt(matcher.group(1), getTag());
        }
 void startElement() {
   String localName = atts.getName();
   String id = ParseUtil.getStringAttr("id", atts);
   if (id != null) {
     IdRecording ir = new IdRecording(id);
     idRecordingStack.push(ir);
   }
   if (idRecordingStack.size() > 0) {
     IdRecording ir = idRecordingStack.lastElement();
     ir.level++;
     // appendElementString(ir.sb, atts.getNamespace(), localName, atts.getName(), atts);
     appendElementString(ir.sb, localName, atts);
   }
 }
Пример #16
0
        @Override
        public void parse(String line, ParseState state) throws ParseException {
          super.parse(line, state);

          final Matcher matcher = match(Constants.EXT_X_PLAYLIST_TYPE_PATTERN, line);

          if (state.getMedia().playlistType != null) {
            throw ParseException.create(
                ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES, getTag(), line);
          }

          state.getMedia().playlistType =
              ParseUtil.parseEnum(matcher.group(1), PlaylistType.class, getTag());
        }
Пример #17
0
  /**
   * @see HttpServlet#doPost(javax.servlet.http.HttpServletRequest request,
   *     javax.servlet.http.HttpServletResponse response)
   */
  @SuppressWarnings("unchecked")
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    String sImageID = ParseUtil.checkNull(request.getParameter("img"));

    if (!Utility.isNullOrEmpty(sImageID)) {
      UploadRequestBean uploadRequestBean = new UploadRequestBean();
      uploadRequestBean.setUploadId(sImageID);

      UploadFile uploadFile = new UploadFile();
      UploadResponseBean uploadResponseBean = uploadFile.getUploadFileInfo(uploadRequestBean);

      if (uploadResponseBean != null) {}
    }
  }
  private void init(JSONObject json) throws TwitterException {
    try {
      JSONArray indicesArray = json.getJSONArray("indices");
      setStart(indicesArray.getInt(0));
      setEnd(indicesArray.getInt(1));

      if (!json.isNull("name")) {
        this.name = json.getString("name");
      }
      if (!json.isNull("screen_name")) {
        this.screenName = json.getString("screen_name");
      }
      id = ParseUtil.getLong("id", json);
    } catch (JSONException jsone) {
      throw new TwitterException(jsone);
    }
  }
Пример #19
0
  @Override
  protected Integer doInBackground(String... params) {

    String command = params[0];
    if (command.equals(COMMAND_BACKUP)) {

      Log.d("BackupData", "===>begin backup selfdefine fav tvlist");

      File backupFile =
          new File(Environment.getExternalStorageDirectory(), "/kekePlayer/selfDefineTVList.txt");
      try {
        FileOutputStream fos = new FileOutputStream(backupFile);
        OutputStreamWriter ow = new OutputStreamWriter(fos, "GBK");
        BufferedWriter bw = new BufferedWriter(ow);
        try {
          // 备份数据库内的自定义的收藏频道
          List<POUserDefChannel> infos = ChannelListBusiness.getAllDefFavChannels();
          for (POUserDefChannel info : infos) {
            ArrayList<String> urls = info.getAllUrl();
            for (String url : urls) {
              //							bw.write(info.name + "," + url + "\n");
              bw.append(info.name + "," + url + "\n");
            }
          }
          bw.flush();
        } finally {
          bw.close();
          ow.close();
          fos.close();
          Log.d("BackupData", "===>backup selfdefine fav tvlist success");
        }
      } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return null;
    } else if (command.equals(COMMAND_RESTORE)) {
      Log.d("BackupData", "===>restore backup selfdefine fav tvlist");

      String path =
          Environment.getExternalStorageDirectory().getPath() + "/kekePlayer/selfDefineTVList.txt";
      File listFile = new File(path);
      if (listFile.exists()) {
        List<ChannelInfo> infos = ParseUtil.parseDef(path);
        // 重新创建自定义收藏频道数据库表格
        try {
          ChannelListBusiness.buildSeflDefDatabase(infos);
          Log.d("BackupData", "===>restore selfdefine fav tvlist success");
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      return null;
    } else {
      Log.e("BackupData", "===>invalide command");
      return null;
    }
  }
  /*.................................................................................................................*/
  public Object doCommand(String commandName, String arguments, CommandChecker checker) {
    Tree trt = treeDisplay.getTree();
    MesquiteTree t = null;
    if (trt instanceof MesquiteTree) t = (MesquiteTree) trt;
    if (checker.compare(
        this.getClass(),
        "Adjust tool has touched branch",
        "[branch number][x coordinate touched][y coordinate touched][modifiers]",
        commandName,
        "touchedPositionAdjust")) {
      if (t == null) return null;
      MesquiteInteger io = new MesquiteInteger(0);
      int node = MesquiteInteger.fromString(arguments, io);
      int x = MesquiteInteger.fromString(arguments, io);
      int y = MesquiteInteger.fromString(arguments, io);
      String mod = ParseUtil.getRemaining(arguments, io);

      Point newOnLine = treeDisplay.getTreeDrawing().projectionOnLine(node, x, y);
      originalX = newOnLine.x;
      originalY = newOnLine.y;
      // lastX= newOnLine.x;
      // lastY = newOnLine.y;
      Graphics g = null;
      if (GraphicsUtil.useXORMode(null, false)) {
        g = treeDisplay.getGraphics();
        g.setXORMode(Color.white);
        g.setColor(Color.red);
      }
      // double bX = treeDisplay.getTreeDrawing().lineBaseX[node];
      // double bY = treeDisplay.getTreeDrawing().lineBaseY[node];
      // Math.sqrt((originalY-bY)*(originalY-bY) + (originalX-bX)*(originalX-bX));
      lastBL = tree.getBranchLength(node);
      double shortestAbove = MesquiteDouble.unassigned;
      for (int daughter = t.firstDaughterOfNode(node);
          t.nodeExists(daughter);
          daughter = t.nextSisterOfNode(daughter))
        shortestAbove = MesquiteDouble.minimum(shortestAbove, tree.getBranchLength(daughter));
      if (shortestAbove == MesquiteDouble.unassigned) upperLimit = MesquiteDouble.infinite;
      else if (MesquiteDouble.isCombinable(lastBL)) upperLimit = shortestAbove + lastBL;
      else upperLimit = shortestAbove + 1.0;
      int ibX = treeDisplay.getTreeDrawing().lineBaseX[node];
      int ibY = treeDisplay.getTreeDrawing().lineBaseY[node];
      lastX = treeDisplay.getTreeDrawing().lineTipX[node];
      lastY = treeDisplay.getTreeDrawing().lineTipY[node];
      if (GraphicsUtil.useXORMode(null, false)) {
        drawThickLine(g, ibX, ibY, lastX, lastY);
        for (int daughter = t.firstDaughterOfNode(node);
            t.nodeExists(daughter);
            daughter = t.nextSisterOfNode(daughter))
          drawThickLine(
              g,
              treeDisplay.getTreeDrawing().lineTipX[daughter],
              treeDisplay.getTreeDrawing().lineTipY[daughter],
              lastX,
              lastY);
        g.fillOval(
            lastX - ovalRadius,
            lastY - ovalRadius,
            ovalRadius + ovalRadius,
            ovalRadius + ovalRadius);
        try {
          g.drawString(MesquiteDouble.toString(lastBL), lastX + 10, lastY);
        } catch (InternalError e) { // workaround for bug on windows java 1.7.
        } catch (Throwable e) {
        }
        lineOn = true;
        g.dispose();
      }
    } else if (checker.compare(
        this.getClass(),
        "Adjust tool has been dropped",
        "[branch number][x coordinate dropped][y coordinate dropped]",
        commandName,
        "droppedPositionAdjust")) {
      if (t == null) return null;
      if (editorOn) return null;
      MesquiteInteger io = new MesquiteInteger(0);
      int node = MesquiteInteger.fromString(arguments, io);
      int x = MesquiteInteger.fromString(arguments, io);
      int y = MesquiteInteger.fromString(arguments, io);
      if (lineOn) {
        Point newOnLine = treeDisplay.getTreeDrawing().projectionOnLine(node, x, y);
        double bX = treeDisplay.getTreeDrawing().lineBaseX[node];
        double bY = treeDisplay.getTreeDrawing().lineBaseY[node];
        double tX = treeDisplay.getTreeDrawing().lineTipX[node];
        double tY = treeDisplay.getTreeDrawing().lineTipY[node];
        double lengthLine =
            Math.sqrt((originalY - bY) * (originalY - bY) + (originalX - bX) * (originalX - bX));
        double bL;
        if (lengthLine != 0) {
          double extension =
              Math.sqrt(
                      (newOnLine.y - bY) * (newOnLine.y - bY)
                          + (newOnLine.x - bX) * (newOnLine.x - bX))
                  / lengthLine;
          if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node)) bL = extension;
          else bL = t.getBranchLength(node) * extension;
        } else bL = 1;

        if (bL > upperLimit) bL = upperLimit;
        else if (bL < lowerLimit) bL = lowerLimit;
        double oldBL = t.getBranchLength(node);
        if (!MesquiteDouble.isCombinable(oldBL)) oldBL = 1.0;
        t.setBranchLength(node, bL, false);
        double difference = oldBL - t.getBranchLength(node);
        for (int daughter = t.firstDaughterOfNode(node);
            t.nodeExists(daughter);
            daughter = t.nextSisterOfNode(daughter))
          if (MesquiteDouble.isCombinable(t.getBranchLength(daughter)))
            t.setBranchLength(daughter, t.getBranchLength(daughter) + difference, false);
        t.notifyListeners(this, new Notification(MesquiteListener.BRANCHLENGTHS_CHANGED));
        Graphics g = treeDisplay.getGraphics();
        g.setPaintMode();
        g.dispose();
        treeDisplay.pleaseUpdate(true);
        lineOn = false;
      }
    } else if (checker.compare(
        this.getClass(),
        "Adjust tool is being dragged",
        "[branch number][x coordinate][y coordinate]",
        commandName,
        "draggedPositionAdjust")) {
      if (t == null) return null;
      if (editorOn) return null;
      MesquiteInteger io = new MesquiteInteger(0);
      int node = MesquiteInteger.fromString(arguments, io);
      int x = MesquiteInteger.fromString(arguments, io);
      int y = MesquiteInteger.fromString(arguments, io);
      if (lineOn) {
        Point newOnLine = treeDisplay.getTreeDrawing().projectionOnLine(node, x, y);
        // WARNING":  This shouldn't result in length increase if simple click and release with no
        // drag; must subtract original X, Y
        Graphics g = null;
        if (GraphicsUtil.useXORMode(null, false)) {
          g = treeDisplay.getGraphics();
          g.setXORMode(Color.white);
          g.setColor(Color.red);
        }
        // g.fillOval(lastX-ovalRadius, lastY-ovalRadius, ovalRadius + ovalRadius, ovalRadius +
        // ovalRadius);
        // g.fillOval(newOnLine.x-ovalRadius, newOnLine.y -ovalRadius, ovalRadius + ovalRadius,
        // ovalRadius + ovalRadius);

        // g.drawLine(originalX, originalY, lastX, lastY);
        // g.drawLine(originalX, originalY, newOnLine.x, newOnLine.y);

        //				if decreasing, & unassigned involved: push unassigned down and assign values to
        // unassigned above; if increasing, push unassigne up
        int ibX = treeDisplay.getTreeDrawing().lineBaseX[node];
        int ibY = treeDisplay.getTreeDrawing().lineBaseY[node];
        int itX = treeDisplay.getTreeDrawing().lineTipX[node];
        int itY = treeDisplay.getTreeDrawing().lineTipY[node];

        double bX = ibX;
        double bY = ibY;
        double tX = itX;
        double tY = itY;
        double lengthLine =
            Math.sqrt((originalY - bY) * (originalY - bY) + (originalX - bX) * (originalX - bX));
        if (lengthLine != 0) {
          if (GraphicsUtil.useXORMode(null, false)) {
            if (MesquiteTrunk.isMacOSX()
                && MesquiteTrunk.getJavaVersionAsDouble() >= 1.5
                && MesquiteTrunk.getJavaVersionAsDouble() < 1.6) // due to a JVM bug
            g.fillRect(lastX, lastY - 20, 100, 20);
            g.drawString(MesquiteDouble.toString(lastBL), lastX + 10, lastY);
            if (MesquiteTrunk.isMacOSX()
                && MesquiteTrunk.getJavaVersionAsDouble() >= 1.5
                && MesquiteTrunk.getJavaVersionAsDouble() < 1.6) // due to a JVM bug
            g.fillRect(lastX, lastY - 20, 100, 20);
          }
          double extension =
              Math.sqrt(
                      (newOnLine.y - bY) * (newOnLine.y - bY)
                          + (newOnLine.x - bX) * (newOnLine.x - bX))
                  / lengthLine;
          double bL;
          if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node)) bL = extension;
          else bL = t.getBranchLength(node) * extension;
          if (bL > upperLimit) {
            bL = upperLimit;
            if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node))
              extension = upperLimit;
            else extension = upperLimit / t.getBranchLength(node);
          } else if (bL < lowerLimit) {
            bL = lowerLimit;
            if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node))
              extension = lowerLimit;
            else extension = lowerLimit / t.getBranchLength(node);
          }
          lastBL = bL;
          if (GraphicsUtil.useXORMode(null, false)) {
            drawThickLine(g, ibX, ibY, lastX, lastY);
            for (int daughter = t.firstDaughterOfNode(node);
                t.nodeExists(daughter);
                daughter = t.nextSisterOfNode(daughter))
              drawThickLine(
                  g,
                  treeDisplay.getTreeDrawing().lineTipX[daughter],
                  treeDisplay.getTreeDrawing().lineTipY[daughter],
                  lastX,
                  lastY);
            g.fillOval(
                lastX - ovalRadius,
                lastY - ovalRadius,
                ovalRadius + ovalRadius,
                ovalRadius + ovalRadius);
          }
          int newX = ibX + (int) (extension * (tX - bX));
          int newY = ibY + (int) (extension * (tY - bY));
          if (GraphicsUtil.useXORMode(null, false)) {
            g.drawString(MesquiteDouble.toString(bL), newX + 10, newY);
            drawThickLine(g, ibX, ibY, newX, newY);
            for (int daughter = t.firstDaughterOfNode(node);
                t.nodeExists(daughter);
                daughter = t.nextSisterOfNode(daughter))
              drawThickLine(
                  g,
                  treeDisplay.getTreeDrawing().lineTipX[daughter],
                  treeDisplay.getTreeDrawing().lineTipY[daughter],
                  newX,
                  newY);
            g.fillOval(
                newX - ovalRadius,
                newY - ovalRadius,
                ovalRadius + ovalRadius,
                ovalRadius + ovalRadius);
          }
          lastX = newX;
          lastY = newY;
        }

        // lastX= newOnLine.x;
        // lastY = newOnLine.y;
      }
    }
    return null;
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    RespObjectProc responseObject = new RespObjectProc();
    JSONObject jsonResponseObj = new JSONObject();
    ArrayList<Text> arrOkText = new ArrayList<Text>();
    ArrayList<Text> arrErrorText = new ArrayList<Text>();
    RespConstants.Status responseStatus = RespConstants.Status.ERROR;

    try {

      if (!DataSecurityChecker.isInsecureInputResponse(request)) {
        UserBean loggedInUserBean =
            (UserBean) request.getSession().getAttribute(Constants.USER_LOGGED_IN_BEAN);

        if (loggedInUserBean != null && !Utility.isNullOrEmpty(loggedInUserBean.getUserId())) {

          String sUploadId = ParseUtil.checkNull(request.getParameter("upload_id"));
          if (!Utility.isNullOrEmpty(sUploadId)) {

            AccessUsers accessUser = new AccessUsers();
            ParentTypeBean parentTypeBean = accessUser.getParentTypeBeanFromUser(loggedInUserBean);
            if (parentTypeBean != null && parentTypeBean.isUserAVendor()) {
              UploadRequestBean uploadRequestBean = new UploadRequestBean();
              uploadRequestBean.setUploadId(sUploadId);

              UploadFile uploadFile = new UploadFile();
              UploadResponseBean uploadResponseBean =
                  uploadFile.getUploadFileInfo(uploadRequestBean);

              if (uploadResponseBean != null) {
                UploadBean uploadBean = uploadResponseBean.getUploadBean();

                SharedFilesRequestBean sharedFilesRequestBean = new SharedFilesRequestBean();
                sharedFilesRequestBean.setUploadId(sUploadId);

                AccessSharedFiles accessSharedFiles = new AccessSharedFiles();
                SharedFilesBean sharedFilesBean =
                    accessSharedFiles.getSharedFilesFromUploadId(sharedFilesRequestBean);
                if (sharedFilesBean != null) {

                  sharedFilesRequestBean.setSharedFileId(sharedFilesBean.getSharedFilesId());

                  Folder folder = new Folder();
                  boolean isFileDeleted =
                      folder.deleteS3File(uploadBean.getFilename(), uploadBean.getPath());

                  BuildSharedFiles buildSharedFiles = new BuildSharedFiles();
                  buildSharedFiles.deleteSharedFiles(sharedFilesRequestBean);

                  jsonResponseObj.put("is_deleted", true);
                  jsonResponseObj.put("deleted_upload_id", sUploadId);

                  Text okText = new OkText("The file was deleted successfully", "status_mssg");
                  arrOkText.add(okText);
                  responseStatus = RespConstants.Status.OK;
                }

              } else {
                Text errorText =
                    new ErrorText("The file you are trying to delete does not exist.", "err_mssg");
                arrErrorText.add(errorText);

                responseStatus = RespConstants.Status.ERROR;
              }
            } else {
              Text errorText =
                  new ErrorText(
                      "You are not allowed to perform this action. Please contact your support representative.",
                      "err_mssg");
              arrErrorText.add(errorText);

              responseStatus = RespConstants.Status.ERROR;
            }

          } else {
            Text errorText =
                new ErrorText(
                    "We were unable to delete the file. Please select a valid file", "err_mssg");
            arrErrorText.add(errorText);

            responseStatus = RespConstants.Status.ERROR;
          }

        } else {
          appLogging.info(
              "Invalid request in Proc Page (loggedInUserBean)"
                  + ParseUtil.checkNullObject(loggedInUserBean));
          Text errorText =
              new ErrorText(
                  "Oops!! We were unable to process your request at this time. Please try again later.(loadFileGroup - 002)",
                  "err_mssg");
          arrErrorText.add(errorText);

          responseStatus = RespConstants.Status.ERROR;
        }

      } else {
        appLogging.info(
            "Insecure Parameters used in this Proc Page "
                + Utility.dumpRequestParameters(request).toString()
                + " --> "
                + this.getClass().getName());
        Text errorText =
            new ErrorText(
                "Please use valid parameters. We have identified insecure parameters in your form.",
                "account_num");
        arrErrorText.add(errorText);
        responseStatus = RespConstants.Status.ERROR;
      }

    } catch (Exception e) {
      appLogging.info(
          "An exception occurred in the Proc Page " + ExceptionHandler.getStackTrace(e));
      Text errorText =
          new ErrorText(
              "Oops!! We were unable to process your request at this time. Please try again later.(loadFileGroup - 001)",
              "err_mssg");
      arrErrorText.add(errorText);

      responseStatus = RespConstants.Status.ERROR;
    }

    responseObject.setErrorMessages(arrErrorText);
    responseObject.setOkMessages(arrOkText);
    responseObject.setResponseStatus(responseStatus);
    responseObject.setJsonResponseObj(jsonResponseObj);

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(responseObject.getJson().toString());
  }
 /*.................................................................................................................*/
 public Snapshot getSnapshot(MesquiteFile file) {
   Snapshot temp = new Snapshot();
   temp.addLine("setUsername " + ParseUtil.tokenize(username));
   return temp;
 }
Пример #23
0
  private void init(JSONObject json) throws TwitterException {
    id = ParseUtil.getLong("id", json);
    name = ParseUtil.getRawString("name", json);
    fullName = ParseUtil.getRawString("full_name", json);
    slug = ParseUtil.getRawString("slug", json);
    description = ParseUtil.getRawString("description", json);
    subscriberCount = ParseUtil.getInt("subscriber_count", json);
    memberCount = ParseUtil.getInt("member_count", json);
    uri = ParseUtil.getRawString("uri", json);
    mode = "public".equals(ParseUtil.getRawString("mode", json));
    following = ParseUtil.getBoolean("following", json);
    createdAt = ParseUtil.getDate("created_at", json);

    try {
      if (!json.isNull("user")) {
        user = new UserJSONImpl(json.getJSONObject("user"));
      }
    } catch (JSONException jsone) {
      throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone);
    }
  }