Ok it seems that the errors occurs in UserParams file.
Code:
/* */ package megapolis;
/* */
/* */ import com.google.gson.JsonElement;
/* */ import com.google.gson.JsonObject;
/* */ import com.google.gson.JsonParser;
/* */ import com.google.gson.JsonPrimitive;
/* */ import java****.ByteArrayInputStream;
/* */ import java********Exception;
/* */ import java****.OutputStream;
/* */ import java.net.HttpURLConnection;
/* */ import java.net.MalformedURLException;
/* */ import java.net.URL;
/* */ import java.util.LinkedHashMap;
/* */ import java.util.Map.Entry;
/* */ import javax.xml.parsers.DocumentBuilder;
/* */ import javax.xml.parsers.DocumentBuilderFactory;
/* */ import javax.xml.parsers.ParserConfigurationException;
/* */ import org.eclipse.jface.viewers.TreeViewer;
/* */ import org.eclipse.swt.widgets.Button;
/* */ import org.eclipse.swt.widgets.Tree;
/* */ import org.w3c.dom.Document;
/* */ import org.w3c.dom.Element;
/* */ import org.w3c.dom.Node;
/* */ import org.w3c.dom.NodeList;
/* */ import org.w3c.dom.traversal.TreeWalker;
/* */ import org.xml.sax.InputSource;
/* */ import org.xml.sax.SAXException;
/* */
/* */ public class UserParams
/* */ implements HttpOperationStatusEvent
/* */ {
/* */ private String index;
/* */ private boolean needStatusEmpty;
/* 33 */ private static String uuiError = "Update User Info Exceprion: ";
/* */
/* */ public UserParams(String index, boolean needStatusEmpty)
/* */ {
/* 37 */ this.index = index;
/* 38 */ this.needStatusEmpty = needStatusEmpty;
/* */ }
/* */
/* */ public void setNeedClear(boolean needStatausEmpty)
/* */ {
/* 43 */ this.needStatusEmpty = needStatausEmpty;
/* */ }
/* */
/* */ public void getUserStatus()
/* */ {
/* 48 */ HttpURLConnection req = null;
/* */ try
/* */ {
/* 52 */ mainView.userStatResponse.clearAll(true);
/* 53 */ String urlStr = Utils.getAuthHeader(this.index) + "&first_request=true";
/* 54 */ String HttpRef = DataModel.get(this.index).server().getRef();
/* 55 */ URL url = new URL(HttpRef + "get_user_stat");
/* 56 */ req = (HttpURLConnection)url.openConnection();
/* 57 */ req.setRequestProperty("User-Agent", "city-iOS-HD-1.71.2033");
/* 58 */ req.setRequestProperty("Accept", "*/*");
/* 59 */ req.setRequestProperty("Accept-Language", "ru");
/* 60 */ req.setRequestProperty("Accept-Encoding", "gzip, deflate");
/* 61 */ req.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
/* 62 */ req.setRequestProperty("Connection", "keep-alive");
/* 63 */ req.setRequestProperty("Content-Length", String.format("%d", new Object[] { Integer.valueOf(urlStr.length()) }));
/* 64 */ req.setRequestMethod("POST");
/* 65 */ req.setDoOutput(true);
/* 66 */ ProfileChannel.get(this.index).enQueue(new ServerRequest(req, urlStr, this));
/* */ }
/* */ catch (IOException e1)
/* */ {
/* 70 */ e1.printStackTrace();
/* */ }
/* */ }
/* */
/* */ public void HttpEvent(Object status)
/* */ {
/* 77 */ if ((status instanceof byte[]))
/* */ {
/* */ try
/* */ {
/* 81 */ byte[] rspBytes = (byte[])status;
/* */
/* 83 */ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
/* 84 */ DocumentBuilder db = dbf.newDocumentBuilder();
/* 85 */ Document doc = db.parse(new InputSource(new ByteArrayInputStream(rspBytes)));
/* */
/* 87 */ NodeList err = doc.getElementsByTagName("error");
/* 88 */ if ((err != null) && (err.getLength() != 0))
/* */ {
/* 90 */ String logStr = Utils.extractErrorsIfOccured(err);
/* 91 */ Logger.write(DataModel.get(this.index).name() + ": User Status Responce Error: !!!!!!!!\n" + logStr + "\n!!!!!!!!!!!!!!!!!!\n");
/* */ }
/* 94 */ DataModel.getbot(this.index).clear();
/* 95 */ Element country = (Element)((NodeList)doc).item(0);
/* 96 */ Utils.updateStatistics(country, null);
/* */
/* 98 */ String rooms = country.getAttribute("room_information");
/* 99 */ if ((rooms != null) && (rooms.length() > 0))
/* */ {
/* 101 */ JsonParser jp = new JsonParser();
/* 102 */ JsonObject jRoot = jp.parse(rooms).getAsJsonObject();
/* 103 */ if (jRoot != null)
/* */ {
/* 105 */ JsonObject jRooms = jRoot.getAsJsonObject("rooms");
/* 106 */ if (jRooms != null) {
/* 108 */ for (Map.Entry<String, JsonElement> room : jRooms.entrySet())
/* */ {
/* 110 */ JsonObject jo = ((JsonElement)room.getValue()).getAsJsonObject();
/* 111 */ if (jo != null)
/* */ {
/* 113 */ JsonPrimitive jpr = jo.getAsJsonPrimitive("available");
/* 114 */ if ((jpr != null) && (jpr.isBoolean()) && (jpr.getAsBoolean())) {
/* 116 */ Rooms.addRoom(this.index, (String)room.getKey());
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* 123 */ NodeList l = doc.getElementsByTagName("machine_shop_new_art");
/* 124 */ if ((l != null) && (l.getLength() != 0))
/* */ {
/* 126 */ vegetables veg = new vegetables(this.index, Long.valueOf(10037L));
/* 127 */ DataModel.getbot(this.index).addContract(veg);
/* 128 */ LinkedHashMap<Long, Integer> needClean = new LinkedHashMap();
/* 129 */ String logstr = " Machine Shop Available: { ";
/* 130 */ for (int i = 0; i < l.getLength(); i++)
/* */ {
/* 132 */ Element e = (Element)l.item(i);
/* 133 */ Long eLong = new Long(e.getAttribute("id"));
/* 134 */ if (this.needStatusEmpty)
/* */ {
/* 136 */ Integer state = new Integer(e.getAttribute("state"));
/* 137 */ if (state.intValue() != 2) {
/* 139 */ needClean.put(eLong, state);
/* */ }
/* */ }
/* 142 */ DataModel.getbot(this.index).addContractId("fresh_vegetables", eLong);
/* 143 */ logstr = logstr + String.format("%d ", new Object[] { eLong });
/* */ }
/* 145 */ Logger.write(logstr + "}\n");
/* 146 */ if (needClean.size() > 0) {
/* 148 */ cleanContracts(this.index, needClean);
/* */ }
/* */ }
/* 152 */ l = doc.getElementsByTagName("blamco_inc_new_art");
/* 153 */ if ((l != null) && (l.getLength() != 0))
/* */ {
/* 155 */ jalousie jal = new jalousie(this.index, Long.valueOf(10037L));
/* 156 */ DataModel.getbot(this.index).addContract(jal);
/* 157 */ LinkedHashMap<Long, Integer> needClean = new LinkedHashMap();
/* */
/* 159 */ String logstr = " Blamco Available: { ";
/* 160 */ for (int i = 0; i < l.getLength(); i++)
/* */ {
/* 162 */ Element e = (Element)l.item(i);
/* 163 */ Long eLong = new Long(e.getAttribute("id"));
/* 164 */ if (this.needStatusEmpty)
/* */ {
/* 166 */ Integer state = new Integer(e.getAttribute("state"));
/* 167 */ if (state.intValue() != 2) {
/* 169 */ needClean.put(eLong, state);
/* */ }
/* */ }
/* 172 */ DataModel.getbot(this.index).addContractId("jalousie", eLong);
/* 173 */ logstr = logstr + String.format("%d ", new Object[] { eLong });
/* */ }
/* 175 */ Logger.write(logstr + "}\n");
/* 176 */ if (needClean.size() > 0) {
/* 178 */ cleanContracts(this.index, needClean);
/* */ }
/* */ }
/* 182 */ l = doc.getElementsByTagName("bed_and_breakfast_new");
/* 183 */ if ((l != null) && (l.getLength() != 0))
/* */ {
/* 185 */ badandbreakfast bab = new badandbreakfast(this.index);
/* 186 */ DataModel.getbot(this.index).addContract(bab);
/* 187 */ Long maxDelayToStart = Long.valueOf(0L);
/* 188 */ String logstr = " Bad And Breakfast New: { ";
/* 189 */ for (int i = 0; i < l.getLength(); i++)
/* */ {
/* 191 */ Element e = (Element)l.item(i);
/* 192 */ Long eLong = new Long(e.getAttribute("id"));
/* 193 */ if (this.needStatusEmpty)
/* */ {
/* 195 */ Integer state = new Integer(e.getAttribute("state"));
/* 196 */ if (state.intValue() != 2)
/* */ {
/* 198 */ Long ee = new Long(e.getAttribute("process_end"));
/* 199 */ if (maxDelayToStart.longValue() < ee.longValue()) {
/* 201 */ maxDelayToStart = ee;
/* */ }
/* */ }
/* */ }
/* 205 */ DataModel.getbot(this.index).addContractId("bed_and_breakfast_new", eLong);
/* 206 */ logstr = logstr + String.format("%d ", new Object[] { eLong });
/* */ }
/* 208 */ if (maxDelayToStart.longValue() != 0L)
/* */ {
/* 210 */ DataModel.getbot(this.index).setDelayToStart("bed_and_breakfast_new", maxDelayToStart);
/* 211 */ logstr = logstr + " Set StartDelay to " + maxDelayToStart.longValue() / 1000L + " seconds ";
/* */ }
/* 213 */ Logger.write(logstr + "}\n");
/* */ }
/* 216 */ l = doc.getElementsByTagName("log_hut");
/* 217 */ if ((l != null) && (l.getLength() != 0))
/* */ {
/* 219 */ loghut lh = new loghut(this.index);
/* 220 */ DataModel.getbot(this.index).addContract(lh);
/* 221 */ Long maxDelayToStart = Long.valueOf(0L);
/* 222 */ String logstr = " Log Hut Available: { ";
/* 223 */ for (int i = 0; i < l.getLength(); i++)
/* */ {
/* 225 */ Element e = (Element)l.item(i);
/* 226 */ Long eLong = new Long(e.getAttribute("id"));
/* 227 */ if (this.needStatusEmpty)
/* */ {
/* 229 */ Integer state = new Integer(e.getAttribute("state"));
/* 230 */ if (state.intValue() != 2)
/* */ {
/* 232 */ Long ee = new Long(e.getAttribute("process_end"));
/* 233 */ if (maxDelayToStart.longValue() < ee.longValue()) {
/* 235 */ maxDelayToStart = ee;
/* */ }
/* */ }
/* */ }
/* 239 */ DataModel.getbot(this.index).addContractId("loghut", eLong);
/* 240 */ logstr = logstr + String.format("%d ", new Object[] { eLong });
/* */ }
/* 242 */ if (maxDelayToStart.longValue() != 0L)
/* */ {
/* 244 */ DataModel.getbot(this.index).setDelayToStart("loghut", maxDelayToStart);
/* 245 */ logstr = logstr + "Set StartDelay to " + maxDelayToStart.longValue() / 1000L + " seconds ";
/* */ }
/* 247 */ Logger.write(logstr + "}\n");
/* */ }
/* 249 */ NodeList friends = doc.getElementsByTagName("friends");
/* 250 */ FriendCollection pc = ProfileFriends.get(this.index);
/* 251 */ if ((friends != null) && (friends.getLength() > 0)) {
/* 253 */ for (int fIdx = 0; fIdx < friends.getLength(); fIdx++)
/* */ {
/* 255 */ l = friends.item(fIdx).getChildNodes();
/* 257 */ for (int i = 0; i < l.getLength(); i++)
/* */ {
/* 259 */ Element e = (Element)l.item(i);
/* 260 */ if (e.getNodeName().equals("friend"))
/* */ {
/* 261 */ String frId = e.getAttribute("id");
/* 262 */ String frCity = e.getAttribute("city_name");
/* 263 */ String frHelpPoints = e.getAttribute("help_points");
/* 264 */ String frName = e.getAttribute("first_name");
/* */
/* */
/* 267 */ Friend f = new Friend(this.index, frId, frCity, frName, Integer.valueOf(frHelpPoints).intValue());
/* 268 */ pc.add(f);
/* */ }
/* */ }
/* */ }
/* */ }
/* 274 */ NodeList fields = doc.getElementsByTagName("field");
/* 275 */ if ((fields != null) && (fields.getLength() > 0))
/* */ {
/* 277 */ NodeList cityItems = fields.item(0).getChildNodes();
/* 278 */ if ((cityItems != null) && (cityItems.getLength() > 0))
/* */ {
/* 280 */ Houses.clear(this.index);
/* 281 */ Contracts.clear(this.index);
/* 282 */ Leisures.clear(this.index);
/* 283 */ for (int fld = 0; fld < cityItems.getLength(); fld++) {
/* 285 */ if (cityItems.item(fld).getNodeType() != 3)
/* */ {
/* 289 */ Element e = (Element)cityItems.item(fld);
/* 290 */ Object cio = mainView.cityAllItems.get(e.getNodeName());
/* 291 */ if ((cio != null) && ((cio instanceof LinkedHashMap)))
/* */ {
/* 293 */ LinkedHashMap<?, ?> ci = (LinkedHashMap)cio;
/* */
/* 295 */ String keysd = (String)ci.get("shop_department");
/* 296 */ Object contracts = ci.get("contracts");
/* */
/* 298 */ Integer state = Integer.valueOf(e.getAttribute("state"));
/* 299 */ if ((keysd != null) && (keysd.equals("houses")) && (state.intValue() == 2))
/* */ {
/* 301 */ Boolean pick = (Boolean)ci.get("pick");
/* 302 */ if ((pick != null) && (pick.booleanValue())) {
/* 304 */ Houses.add(this.index, e.getAttribute("id"), e.getAttribute("state"));
/* */ }
/* */ }
/* 307 */ if ((keysd != null) && (keysd.equals("leisures")) && (state.intValue() == 5))
/* */ {
/* 309 */ Boolean clean = (Boolean)ci.get("clean");
/* 310 */ if ((clean != null) && (clean.booleanValue())) {
/* 312 */ Leisures.add(this.index, e.getAttribute("id"), e.getAttribute("state"));
/* */ }
/* */ }
/* 315 */ if ((contracts != null) && (state.intValue() == 4)) {
/* 317 */ Contracts.add(this.index, e.getAttribute("id"), e.getAttribute("state"));
/* */ }
/* 319 */ if ((keysd != null) && (keysd.equals("buildsite")) && (isLeisure(ci)) && (state.intValue() == 5)) {
/* 321 */ Leisures.add(this.index, e.getAttribute("id"), e.getAttribute("state"));
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* 337 */ if ((Houses.isNeedCollect(this.index)) || (Leisures.isNeedCollect(this.index)) || (Contracts.isNeedCollect(this.index))) {
/* 339 */ Logger.write("Ready to Collect: Houses:" + Houses.size(this.index) + " Leisures:" + Leisures.size(this.index) + " Contracts:" + Contracts.size(this.index) + "\n");
/* */ }
/* 341 */ final TreeWalker walker = Utils.getTreeWalker(doc);
/* 342 */ final boolean doCollect = Utils.doCollect(this.index);
/* 343 */ Utils.asyncExec(new DisplayRun()
/* */ {
/* */ public void doIt()
/* */ {
/* 348 */ mainView.treeViewer.setInput(walker);
/* 349 */ mainView.treeViewer.refresh();
/* 350 */ mainView.friendsTreeViewer.setInput(ProfileFriends.get(UserParams.this.index).friends());
/* 351 */ mainView.friendsTreeViewer.refresh();
/* 352 */ if (doCollect) {
/* 354 */ mainView.btnpickObjects.setEnabled(true);
/* */ } else {
/* 358 */ mainView.btnpickObjects.setEnabled(false);
/* */ }
/* */ }
/* */ });
/* 363 */ if (!this.needStatusEmpty) {
/* */ return;
/* */ }
/* 365 */ if (DataModel.getbot(this.index).size() == 0) {
/* */ return;
/* */ }
/* 367 */ DataModel.getbot(this.index).start();
/* */ }
/* */ catch (IOException e)
/* */ {
/* 373 */ Logger.write(uuiError + e.getMessage() + "\n");
/* 374 */ e.printStackTrace();
/* */ }
/* */ catch (ParserConfigurationException e)
/* */ {
/* 378 */ Logger.write(uuiError + e.getMessage() + "\n");
/* 379 */ e.printStackTrace();
/* */ }
/* */ catch (SAXException e)
/* */ {
/* 383 */ Logger.write(uuiError + e.getMessage() + "\n");
/* 384 */ e.printStackTrace();
/* */ }
/* */ }
/* 387 */ else if ((status instanceof IOException))
/* */ {
/* 389 */ IOException e = (IOException)status;
/* 390 */ Logger.write(uuiError + e.getMessage() + "\n");
/* 391 */ e.printStackTrace();
/* */ }
/* */ }
/* */
/* */ private boolean isLeisure(LinkedHashMap<?, ?> ci)
/* */ {
/* 397 */ Object sto = ci.get("states");
/* 398 */ Boolean clean = (Boolean)ci.get("clean");
/* 399 */ if ((sto == null) || (clean == null) || (!clean.booleanValue())) {
/* 401 */ return false;
/* */ }
/* 403 */ if ((sto instanceof LinkedHashMap))
/* */ {
/* 406 */ LinkedHashMap<Integer, Integer> states = (LinkedHashMap)sto;
/* 407 */ Integer from = (Integer)states.get(Integer.valueOf(1));
/* 408 */ if ((from != null) && (from.intValue() == 4))
/* */ {
/* 410 */ from = (Integer)states.get(Integer.valueOf(2));
/* 411 */ if ((from != null) && (from.intValue() == 4))
/* */ {
/* 413 */ from = (Integer)states.get(Integer.valueOf(4));
/* 414 */ if ((from != null) && (from.intValue() == 5))
/* */ {
/* 416 */ from = (Integer)states.get(Integer.valueOf(5));
/* 417 */ if ((from != null) && (from.intValue() == 4)) {
/* 419 */ return true;
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* 425 */ return false;
/* */ }
/* */
/* 428 */ private static String clcError = "Clean Contracts Exception: ";
/* */
/* */ private void cleanContracts(String idx, LinkedHashMap<Long, Integer> needClean)
/* */ {
/* 431 */ HttpURLConnection req = null;
/* */ try
/* */ {
/* 434 */ long uxtime = System.currentTimeMillis() / 1000L;
/* 435 */ long tdBase = needClean.size() - 1;
/* 436 */ int localIndex = 0;int i = 0;
/* 437 */ String urlStr = Utils.getAuthHeader(this.index);
/* 438 */ String log = new String();
/* 439 */ String roomId = Utils.getRoomId(this.index);
/* 440 */ for (Long id : needClean.keySet())
/* */ {
/* 442 */ int state = ((Integer)needClean.get(id)).intValue();
/* 443 */ log = log + id + "(" + state + ") ";
/* 444 */ switch (state)
/* */ {
/* */ case 3:
/* 447 */ urlStr = urlStr + "&" + Utils.createCmdIdTime(localIndex++, "cancel", id.longValue(), uxtime - (tdBase - i), roomId);
/* 448 */ break;
/* */ case 4:
/* 452 */ urlStr = urlStr + "&" + Utils.createCmdIdTime(localIndex++, "pick", id.longValue(), uxtime - (tdBase - i), roomId);
/* 453 */ break;
/* */ case 6:
/* 456 */ urlStr = urlStr + "&" + Utils.createCmdIdTime(localIndex++, "tick", id.longValue(), uxtime - (tdBase - i) - 2L, roomId);
/* 457 */ urlStr = urlStr + "&" + Utils.createCmdIdTime(localIndex++, "pick", id.longValue(), uxtime - (tdBase - i) - 1L, roomId);
/* 458 */ urlStr = urlStr + "&" + Utils.createCmdIdTime(localIndex++, "clean", id.longValue(), uxtime - (tdBase - i), roomId);
/* */ }
/* 461 */ i++;
/* */ }
/* 463 */ urlStr = urlStr + "&live_update=true";
/* 464 */ Logger.write("CLEAR CONTRACTS { " + log + "}" + "\n");
/* 465 */ String HttpRef = DataModel.get(idx).server().getRef();
/* 466 */ URL url = new URL(HttpRef + "check_and_perform");
/* 467 */ req = (HttpURLConnection)url.openConnection();
/* 468 */ req.setRequestProperty("User-Agent", "city-iOS-HD-1.71.2033");
/* 469 */ req.setRequestProperty("Accept", "*/*");
/* 470 */ req.setRequestProperty("Accept-Language", "ru");
/* 471 */ req.setRequestProperty("Accept-Encoding", "gzip, deflate");
/* 472 */ req.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
/* 473 */ req.setRequestProperty("Connection", "keep-alive");
/* 474 */ req.setRequestProperty("Content-Length", String.format("%d", new Object[] { Integer.valueOf(urlStr.length()) }));
/* 475 */ req.setRequestMethod("POST");
/* 476 */ req.setDoOutput(true);
/* 477 */ req.connect();
/* 478 */ OutputStream data = req.getOutputStream();
/* 479 */ data.write(urlStr.getBytes("UTF-8"));
/* 480 */ data.flush();
/* 481 */ byte[] rspBytes = Utils.getResponse(req);
/* */
/* 483 */ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
/* 484 */ DocumentBuilder db = dbf.newDocumentBuilder();
/* 485 */ Document doc = db.parse(new InputSource(new ByteArrayInputStream(rspBytes)));
/* 486 */ NodeList err = doc.getElementsByTagName("error");
/* 487 */ if ((err != null) && (err.getLength() != 0))
/* */ {
/* 489 */ String logstr = Utils.extractErrorsIfOccured(err);
/* 490 */ Logger.write(logstr + "\n");
/* */ }
/* */ }
/* */ catch (MalformedURLException e)
/* */ {
/* 496 */ Logger.write(clcError + e.getMessage() + "\n");
/* 497 */ e.printStackTrace();
/* */ }
/* */ catch (IOException e)
/* */ {
/* 501 */ Logger.write(clcError + e.getMessage() + "\n");
/* 502 */ e.printStackTrace();
/* */ }
/* */ catch (ParserConfigurationException e)
/* */ {
/* 506 */ Logger.write(clcError + e.getMessage() + "\n");
/* 507 */ e.printStackTrace();
/* */ }
/* */ catch (SAXException e)
/* */ {
/* 511 */ Logger.write(clcError + e.getMessage() + "\n");
/* 512 */ e.printStackTrace();
/* */ }
/* */ finally
/* */ {
/* 516 */ if (req != null) {
/* 518 */ req.disconnect();
/* */ }
/* */ }
/* */ }
/* */ }
/* Location: C:\Users\johnn\Desktop\megapolis_1.0.0.201403200124\
* Qualified Name: megapolis.UserParams
* JD-Core Version: 0.7.0.1
*/