// look up and apply coarts for w to each sign in result @SuppressWarnings("unchecked") private void applyCoarts(Word w, SignHash result) throws LexException { List<Sign> inputSigns = new ArrayList<Sign>(result.asSignSet()); result.clear(); List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size()); // for each surface attr, lookup coarts and apply to input signs, storing results in output // signs for (Iterator<Pair<String, String>> it = w.getSurfaceAttrValPairs(); it.hasNext(); ) { Pair<String, String> p = it.next(); String attr = (String) p.a; if (!_indexedCoartAttrs.contains(attr)) continue; String val = (String) p.b; Word coartWord = Word.createWord(attr, val); SignHash coartResult = getSignsFromWord(coartWord, null, null, null); for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) { Sign coartSign = it2.next(); // apply to each input for (int j = 0; j < inputSigns.size(); j++) { Sign sign = inputSigns.get(j); grammar.rules.applyCoart(sign, coartSign, outputSigns); } } // switch output to input for next iteration inputSigns.clear(); inputSigns.addAll(outputSigns); outputSigns.clear(); } // add results back result.addAll(inputSigns); }
// look up and apply coarts for given rels to each sign in result private void applyCoarts(List<String> coartRels, Collection<Sign> result) { List<Sign> inputSigns = new ArrayList<Sign>(result); result.clear(); List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size()); // for each rel, lookup coarts and apply to input signs, storing results in output signs for (Iterator<String> it = coartRels.iterator(); it.hasNext(); ) { String rel = it.next(); Collection<String> preds = (Collection<String>) _coartRelsToPreds.get(rel); if (preds == null) continue; // not expected Collection<Sign> coartResult = getSignsFromRelAndPreds(rel, preds); if (coartResult == null) continue; for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) { Sign coartSign = it2.next(); // apply to each input for (int j = 0; j < inputSigns.size(); j++) { Sign sign = inputSigns.get(j); grammar.rules.applyCoart(sign, coartSign, outputSigns); } } // switch output to input for next iteration inputSigns.clear(); inputSigns.addAll(outputSigns); outputSigns.clear(); } // add results back result.addAll(inputSigns); }
/** * Used to set form fields * * @param formFields * @param replaceVals * @param removeList * @param addList * @return */ public static boolean setFormParams( List<NameValuePairString> formFields, List<NameValuePairString> replaceVals, List<String> removeList, List<NameValuePairString> addList) { // campi da rimuovere if (removeList != null) for (NameValuePairString nvp : formFields) { for (String removeKey : removeList) { if (removeKey.equals(nvp.getKey())) { formFields.remove(nvp); continue; } } } // replace values if (replaceVals != null) for (NameValuePairString nvp : formFields) { for (NameValuePairString repl : replaceVals) { if (nvp.getKey().equals(repl.getKey())) { nvp.setValue(repl.getValue()); } } } // addMap name value pairs if (addList != null) for (NameValuePairString nvp : addList) { formFields.add(nvp); } // rimuoviamo campi con chiave nulla, non so perchè ma ne pesco ArrayList<NameValuePairString> temp = new ArrayList<NameValuePairString>(); for (NameValuePairString nvp : formFields) { if (nvp.getKey().length() > 0) { temp.add(nvp); } else { log.info("beccata chiave nulla, valore: " + nvp.getValue()); } } formFields.clear(); formFields.addAll(temp); return true; }
public static File[] getHighestJarVersions( File[] files, String[] version_out, String[] id_out, // currently the version of last versioned jar found... boolean discard_non_versioned_when_versioned_found) { // WARNING!!!! // don't use Debug/lglogger here as we can be called before AZ has been initialised List res = new ArrayList(); Map version_map = new HashMap(); for (int i = 0; i < files.length; i++) { File f = files[i]; String name = f.getName().toLowerCase(); if (name.endsWith(".jar")) { int cvs_pos = name.lastIndexOf("_cvs"); int sep_pos; if (cvs_pos <= 0) sep_pos = name.lastIndexOf("_"); else sep_pos = name.lastIndexOf("_", cvs_pos - 1); if (sep_pos == -1 || sep_pos == name.length() - 1 || !Character.isDigit(name.charAt(sep_pos + 1))) { // not a versioned jar res.add(f); } else { String prefix = name.substring(0, sep_pos); String version = name.substring(sep_pos + 1, (cvs_pos <= 0) ? name.length() - 4 : cvs_pos); String prev_version = (String) version_map.get(prefix); if (prev_version == null) { version_map.put(prefix, version); } else { if (PluginUtils.comparePluginVersions(prev_version, version) < 0) { version_map.put(prefix, version); } } } } } // If any of the jars are versioned then the assumption is that all of them are // For migration purposes (i.e. on the first real introduction of the update versioning // system) we drop all non-versioned jars from the set if (version_map.size() > 0 && discard_non_versioned_when_versioned_found) { res.clear(); } // fix a problem we had with the rating plugin. It went out as rating_x.jar when it should // have been azrating_x.jar. If there are any azrating entries then we remove any rating ones // to avoid load problems if (version_map.containsKey("azrating")) { version_map.remove("rating"); } Iterator it = version_map.keySet().iterator(); while (it.hasNext()) { String prefix = (String) it.next(); String version = (String) version_map.get(prefix); String target = prefix + "_" + version; version_out[0] = version; id_out[0] = prefix; for (int i = 0; i < files.length; i++) { File f = files[i]; String lc_name = f.getName().toLowerCase(); if (lc_name.equals(target + ".jar") || lc_name.equals(target + "_cvs.jar")) { res.add(f); break; } } } File[] res_array = new File[res.size()]; res.toArray(res_array); return (res_array); }
public void run() { // every second, go through all the packets that havent been // ack'd List<RDPConnection> conList = new LinkedList<RDPConnection>(); long lastCounterTime = System.currentTimeMillis(); while (true) { try { long startTime = System.currentTimeMillis(); long interval = startTime - lastCounterTime; if (interval > 1000) { if (Log.loggingNet) { Log.net( "RDPServer counters: activeChannelCalls " + activeChannelCalls + ", selectCalls " + selectCalls + ", transmits " + transmits + ", retransmits " + retransmits + " in " + interval + "ms"); } activeChannelCalls = 0; selectCalls = 0; transmits = 0; retransmits = 0; lastCounterTime = startTime; } if (Log.loggingNet) Log.net("RDPServer.RETRY: startTime=" + startTime); // go through all the rdpconnections and re-send any // unacked packets conList.clear(); lock.lock(); try { // make a copy since the values() collection is // backed by the map Set<RDPConnection> conCol = RDPServer.getAllConnections(); if (conCol == null) { throw new MVRuntimeException("values() returned null"); } conList.addAll(conCol); // make non map backed copy } finally { lock.unlock(); } Iterator<RDPConnection> iter = conList.iterator(); while (iter.hasNext()) { RDPConnection con = iter.next(); long currentTime = System.currentTimeMillis(); // is the connection in CLOSE_WAIT if (con.getState() == RDPConnection.CLOSE_WAIT) { long closeTime = con.getCloseWaitTimer(); long elapsedTime = currentTime - closeTime; Log.net( "RDPRetryThread: con is in CLOSE_WAIT: elapsed close timer(ms)=" + elapsedTime + ", waiting for 30seconds to elapse. con=" + con); if (elapsedTime > 30000) { // close the connection Log.net("RDPRetryThread: removing CLOSE_WAIT connection. con=" + con); removeConnection(con); } else { Log.net( "RDPRetryThread: time left on CLOSE_WAIT timer: " + (30000 - (currentTime - closeTime))); } // con.close(); continue; } if (Log.loggingNet) Log.net( "RDPServer.RETRY: resending expired packets " + con + " - current list size = " + con.unackListSize()); // see if we should send a null packet, but only if con is already open if ((con.getState() == RDPConnection.OPEN) && ((currentTime - con.getLastNullPacketTime()) > 30000)) { con.getLock().lock(); try { RDPPacket nulPacket = RDPPacket.makeNulPacket(); con.sendPacketImmediate(nulPacket, false); con.setLastNullPacketTime(); if (Log.loggingNet) Log.net("RDPServer.retry: sent nul packet: " + nulPacket); } finally { con.getLock().unlock(); } } else { if (Log.loggingNet) Log.net( "RDPServer.retry: sending nul packet in " + (30000 - (currentTime - con.getLastNullPacketTime()))); } con.resend( currentTime - resendTimerMS, // resend cutoff time currentTime - resendTimeoutMS); // giveup time } long endTime = System.currentTimeMillis(); if (Log.loggingNet) Log.net( "RDPServer.RETRY: endTime=" + endTime + ", elapse(ms)=" + (endTime - startTime)); Thread.sleep(250); } catch (Exception e) { Log.exception("RDPServer.RetryThread.run caught exception", e); } } }