예제 #1
1
  public String findDups(String MyString) {
    if (MyString == null) {
      return "";
    }
    String dups = "";

    char[] a;
    Map<Character, Boolean> result = new HashMap<Character, Boolean>();
    Map<Character, Boolean> b = new HashMap<Character, Boolean>();

    a = MyString.toCharArray();

    for (char elm : a) {
      if (b.containsKey(elm)) {
        if (result.containsKey(elm) != true) {
          result.put(elm, true);
        }
      }
      b.put(elm, true);
    }

    for (Character c : result.keySet()) {
      dups = dups + c;
    }
    return dups;
  }
예제 #2
0
  public static Map<String, String> postDataAPI(
      EndPointInfo apiUtilities, Map<String, String> headers) throws IDPTokenManagerException {
    HTTP_METHODS httpMethod = apiUtilities.getHttpMethod();
    String url = apiUtilities.getEndPoint();
    Map<String, String> params = apiUtilities.getRequestParamsMap();

    Map<String, String> responseParams = new HashMap<String, String>();
    HttpClient httpclient = getCertifiedHttpClient();
    String payload = buildPayload(params);

    if (httpMethod.equals(HTTP_METHODS.POST)) {
      HttpPost httpPost = new HttpPost(url);
      HttpPost httpPostWithHeaders = (HttpPost) buildHeaders(httpPost, headers, httpMethod);
      byte[] postData = payload.getBytes();
      try {
        httpPostWithHeaders.setEntity(new ByteArrayEntity(postData));
        HttpResponse response = httpclient.execute(httpPostWithHeaders);
        String status = String.valueOf(response.getStatusLine().getStatusCode());

        responseParams.put(Constants.SERVER_RESPONSE_BODY, getResponseBody(response));
        responseParams.put(Constants.SERVER_RESPONSE_STATUS, status);
        return responseParams;
      } catch (ClientProtocolException e) {
        throw new IDPTokenManagerException("Invalid client protocol.", e);
      } catch (IOException e) {
        responseParams.put(Constants.SERVER_RESPONSE_BODY, "Internal Server Error");
        responseParams.put(Constants.SERVER_RESPONSE_STATUS, Constants.INTERNAL_SERVER_ERROR);
        throw new IDPTokenManagerException("Server connectivity failure.", e);
      }
    }

    return responseParams;
  }
  public void invokeServerOutbound(Source source, OutputStream os) {
    Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();

    Map<String, Object> httpProperties = new HashMap<String, Object>();
    httpProperties.put(HTTP_RESPONSE_CODE, Integer.valueOf(200));
    httpProperties.put(HTTP_RESPONSE_HEADERS, new HashMap<String, List<String>>());

    prepare(httpProperties, /*request=*/ false);

    if (!invokeOutbound(source, attachments)) {
      if (getProtocolException() != null) {
        reverseDirection();
        invokeOutboundFaultHandlers();
      }

      /*
      else if (getRuntimeException() != null) {
        closeServer();
        finish(response.getOutputStream());

        throw getRuntimeException();
      }*/
    }

    // XXX
    closeServer();
    finish(os);
  }
예제 #4
0
  public static void testDetermineMergeParticipantsAndMergeCoords4() {
    Address a = Util.createRandomAddress(),
        b = Util.createRandomAddress(),
        c = Util.createRandomAddress(),
        d = Util.createRandomAddress();
    org.jgroups.util.UUID.add(a, "A");
    org.jgroups.util.UUID.add(b, "B");
    org.jgroups.util.UUID.add(c, "C");
    org.jgroups.util.UUID.add(d, "D");

    View v1 = View.create(a, 1, a, b);
    View v2 = View.create(c, 1, c, d);

    Map<Address, View> map = new HashMap<>();
    map.put(a, v1);
    map.put(b, v1);
    map.put(d, v2);

    StringBuilder sb = new StringBuilder("map:\n");
    for (Map.Entry<Address, View> entry : map.entrySet())
      sb.append(entry.getKey() + ": " + entry.getValue() + "\n");
    System.out.println(sb);

    Collection<Address> merge_participants = Util.determineMergeParticipants(map);
    System.out.println("merge_participants = " + merge_participants);
    assert merge_participants.size() == 3;
    assert merge_participants.contains(a)
        && merge_participants.contains(c)
        && merge_participants.contains(d);

    Collection<Address> merge_coords = Util.determineMergeCoords(map);
    System.out.println("merge_coords = " + merge_coords);
    assert merge_coords.size() == 2;
    assert merge_coords.contains(a) && merge_coords.contains(c);
  }
예제 #5
0
  public void processMethodMapping(
      String className,
      int firstLineNumber,
      int lastLineNumber,
      String methodReturnType,
      String methodName,
      String methodArguments,
      String newMethodName) {
    // Original class name -> obfuscated method names.
    Map methodMap = (Map) classMethodMap.get(className);
    if (methodMap == null) {
      methodMap = new HashMap();
      classMethodMap.put(className, methodMap);
    }

    // Obfuscated method name -> methods.
    Set methodSet = (Set) methodMap.get(newMethodName);
    if (methodSet == null) {
      methodSet = new LinkedHashSet();
      methodMap.put(newMethodName, methodSet);
    }

    // Add the method information.
    methodSet.add(
        new MethodInfo(
            firstLineNumber, lastLineNumber, methodReturnType, methodArguments, methodName));
  }
예제 #6
0
  private int dfsVisit(Pack u, int[] status, boolean wipe, Map<String, PackColor> colours) {
    colours.put(u.getName(), PackColor.GREY);
    int check = checkValues[getPos(u.getName())];

    if (Math.abs(check) != 1) {
      wipe = true;
    }
    List<String> deps = u.getDependants();
    if (deps != null) {
      for (String name : deps) {
        Pack v = nameToPack.get(name);
        if (wipe) {
          status[getPos(v.getName())] = 1;
        }
        if (colours.get(v.getName()) == PackColor.WHITE) {
          final int result = dfsVisit(v, status, wipe, colours);
          if (result != 0) {
            return result;
          }
        }
      }
    }
    colours.put(u.getName(), PackColor.BLACK);
    return 0;
  }
예제 #7
0
  public void initProperties(Grain g) {
    int currentGridRow = FIRST_PROPERTY_ROW;

    propertiesGp.getChildren().remove(FIRST_PROPERTY_ROW + 1, propertiesGp.getChildren().size());
    propertiesCb.clear();
    propertiesTf.clear();

    for (Entry<String, Property> entry : g.getProperties().entrySet()) {
      Property property = entry.getValue();
      String propertyName = entry.getKey();

      propertiesCb.put(propertyName, new CheckBox(property.getDescription()));
      propertiesCb.get(propertyName).setOnAction(eh);
      GridPane.setConstraints(propertiesCb.get(propertyName), 0, currentGridRow);
      propertiesGp.getChildren().add(propertiesCb.get(propertyName));

      propertiesTf.put(propertyName, new TextField(Double.toString(property.getValue())));
      GridPane.setConstraints(propertiesTf.get(propertyName), 1, currentGridRow);
      propertiesGp.getChildren().add(propertiesTf.get(propertyName));

      if (property.isEnabled()) {
        propertiesCb.get(propertyName).setSelected(true);
      } else {
        propertiesTf.get(propertyName).setDisable(true);
      }

      currentGridRow++;
    }
  }
예제 #8
0
  public Map exportToMap() throws IOException {

    Map map = new HashMap();

    Map vuze_map = new HashMap();

    map.put("vuze", vuze_map);

    List list = new ArrayList();

    vuze_map.put("components", list);

    for (int i = 0; i < components.length; i++) {

      VuzeFileComponent comp = components[i];

      Map entry = new HashMap();

      entry.put("type", new Long(comp.getType()));

      entry.put("content", comp.getContent());

      list.add(entry);
    }

    return (map);
  }
  public void summaryAction(HttpServletRequest req, HttpServletResponse res) {
    if (AccountController.redirectIfNoCookie(req, res)) return;

    Map<String, Object> viewData = new HashMap<String, Object>();
    DocumentManager docMan = new DocumentManager();

    try {

      if (req.getParameter("documentId") != null) {
        // Get the document ID
        int docId = Integer.parseInt(req.getParameter("documentId"));
        // Get the document using document id
        Document document = docMan.get(docId);
        // Set title to name of the document
        viewData.put("title", document.getDocumentName());
        // Create List of access records
        List<AccessRecord> accessRecords = new LinkedList<AccessRecord>();
        // Add access records for document to the list
        accessRecords = docMan.getAccessRecords(docId);

        viewData.put("accessRecords", accessRecords);
      } else {
        // Go back to thread page.
      }

    } catch (Exception e) {
      Logger.getLogger("").log(Level.SEVERE, "An error occurred when getting profile user", e);
    }

    view(req, res, "/views/group/Document.jsp", viewData);
  }
  /**
   * Displays a Discussion Thread page
   *
   * <p>- Requires a cookie for the session user - Requires a threadId request parameter for the
   * HTTP GET
   *
   * @param req The HTTP Request
   * @param res The HTTP Response
   */
  public void discussionAction(HttpServletRequest req, HttpServletResponse res) {
    // Ensure there is a cookie for the session user
    if (AccountController.redirectIfNoCookie(req, res)) return;

    Map<String, Object> viewData = new HashMap<>();

    if (req.getMethod() == HttpMethod.Get) {

      // Get the thread
      GroupManager gm = new GroupManager();
      int threadId = Integer.parseInt(req.getParameter("threadId"));
      DiscussionManager discussionManager = new DiscussionManager();
      DiscussionThread thread = discussionManager.getThread(threadId);
      thread.setGroup(gm.get(thread.getGroupId()));
      thread.setPosts(discussionManager.getPosts(threadId));

      // get documents for the thread
      DocumentManager docMan = new DocumentManager();
      viewData.put("documents", docMan.getDocumentsForThread(threadId));

      viewData.put("thread", thread);
      viewData.put("title", "Discussion: " + thread.getThreadName());
      view(req, res, "/views/group/DiscussionThread.jsp", viewData);
    } else {
      httpNotFound(req, res);
    }
  }
예제 #11
0
  /**
   * Not only deserialises the object, also performs adjustments on the timestamps to bring them in
   * alignment with the local time. Reads the current time on the peer node first. If the timestamp
   * of any items in the cache or commands are newer throws and IOException, because that means the
   * object is corrupted. Sets the timestamp of the contribution of the peer (if any) to the current
   * local time.
   */
  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

    name = (String) in.readObject();

    cache = new Hashtable();
    commands = new Hashtable();

    final long max = in.readLong(); // the timestamp that should be maximal
    final long diff = System.currentTimeMillis() - max;
    myContribution = (ContributionBox) in.readObject();
    if (myContribution != null) myContribution.timeStamp = max + diff;

    int cachesize = in.readInt();
    for (int i = 0; i < cachesize; ++i) {
      ContributionBox cb = (ContributionBox) in.readObject();
      if (cb.timeStamp > max)
        throw new IOException("corrupted timestamp in cache: " + cb.timeStamp + " " + max);
      cb.timeStamp += diff;
      cache.put(cb.contributor.name, cb);
    }

    int commandssize = in.readInt();
    for (int i = 0; i < commandssize; ++i) {
      Object comm = in.readObject();
      long time = in.readLong();
      if (time > max) throw new IOException("corrupted timestamp in commands: " + time + " " + max);
      time += diff;
      commands.put(comm, new Long(time));
    }
  }
예제 #12
0
 /*
  * Verify that the provider JAR files are signed properly, which
  * means the signer's certificate can be traced back to a
  * JCE trusted CA.
  * Return null if ok, failure Exception if verification failed.
  */
 static synchronized Exception getVerificationResult(Provider p) {
   Object o = verificationResults.get(p);
   if (o == PROVIDER_VERIFIED) {
     return null;
   } else if (o != null) {
     return (Exception) o;
   }
   if (verifyingProviders.get(p) != null) {
     // this method is static synchronized, must be recursion
     // return failure now but do not save the result
     return new NoSuchProviderException("Recursion during verification");
   }
   try {
     verifyingProviders.put(p, Boolean.FALSE);
     URL providerURL = getCodeBase(p.getClass());
     verifyProviderJar(providerURL);
     // Verified ok, cache result
     verificationResults.put(p, PROVIDER_VERIFIED);
     return null;
   } catch (Exception e) {
     verificationResults.put(p, e);
     return e;
   } finally {
     verifyingProviders.remove(p);
   }
 }
예제 #13
0
  @Override
  protected void setUp() throws Exception {
    tmp = IO.getFile("generated/tmp");
    tmp.mkdirs();

    configuration = new HashMap<String, Object>();
    configuration.put(
        Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
    configuration.put(Constants.FRAMEWORK_STORAGE, new File(tmp, "fwstorage").getAbsolutePath());
    configuration.put(
        Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.osgi.framework.launch;version=1.4");
    framework = new org.apache.felix.framework.FrameworkFactory().newFramework(configuration);
    framework.init();
    framework.start();
    BundleContext context = framework.getBundleContext();

    String[] bundles = {
      "../cnf/repo/osgi.cmpn/osgi.cmpn-4.3.1.jar", "testdata/slf4j-simple-1.7.12.jar",
      "testdata/slf4j-api-1.7.12.jar", "testdata/org.apache.aries.util-1.1.0.jar",
      "testdata/org.apache.aries.jmx-1.1.1.jar", "generated/biz.aQute.remote.test.jmx.jar"
    };

    for (String bundle : bundles) {
      String location = "reference:" + IO.getFile(bundle).toURI().toString();
      Bundle b = context.installBundle(location);
      if (!bundle.contains("slf4j-simple")) {
        b.start();
      }
    }

    super.setUp();
  }
예제 #14
0
 private static void addAllInterfaceTypes(
     Map<ClassDoc, Type> results,
     Type type,
     Type[] interfaceTypes,
     boolean raw,
     Configuration configuration) {
   for (int i = 0; i < interfaceTypes.length; i++) {
     Type interfaceType = interfaceTypes[i];
     ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
     if (!(interfaceClassDoc.isPublic()
         || (configuration != null && isLinkable(interfaceClassDoc, configuration)))) {
       continue;
     }
     if (raw) interfaceType = interfaceType.asClassDoc();
     results.put(interfaceClassDoc, interfaceType);
     List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration);
     for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
       Type superInterface = iter.next();
       results.put(superInterface.asClassDoc(), superInterface);
     }
   }
   if (type instanceof ParameterizedType)
     findAllInterfaceTypes(results, (ParameterizedType) type, configuration);
   else if (((ClassDoc) type).typeParameters().length == 0)
     findAllInterfaceTypes(results, (ClassDoc) type, raw, configuration);
   else findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
 }
예제 #15
0
  // Store the invariant for later printing. Ignore duplicate
  // invariants at the same program point.
  private static boolean store_invariant(
      String predicate, String index, HashedConsequent consequent, String pptname) {
    if (!pptname_to_conditions.containsKey(pptname)) {
      pptname_to_conditions.put(pptname, new HashMap<String, Map<String, HashedConsequent>>());
    }

    Map<String, Map<String, HashedConsequent>> cluster_to_conditions =
        pptname_to_conditions.get(pptname);
    if (!cluster_to_conditions.containsKey(predicate)) {
      cluster_to_conditions.put(predicate, new HashMap<String, HashedConsequent>());
    }

    Map<String, HashedConsequent> conditions = cluster_to_conditions.get(predicate);
    if (conditions.containsKey(index)) {
      HashedConsequent old = conditions.get(index);
      if (old.fakeFor != null && consequent.fakeFor == null) {
        // We already saw (say) "x != y", but we're "x == y", so replace it.
        conditions.remove(index);
        conditions.remove(old.fakeFor);
        conditions.put(index, consequent);
        return true;
      }
      return false;
    } else {
      conditions.put(index, consequent);
      return true;
    }
  }
  public static void toCRAWDAD(LinkTrace links, OutputStream out, double timeMul)
      throws IOException {

    StatefulReader<LinkEvent, Link> linkReader = links.getReader();
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));
    Map<Link, Long> activeContacts = new AdjacencyMap.Links<Long>();

    linkReader.seek(links.minTime());
    for (Link l : linkReader.referenceState()) activeContacts.put(l, links.minTime());
    while (linkReader.hasNext()) {
      for (LinkEvent lev : linkReader.next()) {
        Link l = lev.link();
        if (lev.isUp()) {
          activeContacts.put(l, linkReader.time());
        } else {
          double b = activeContacts.get(l) * timeMul;
          double e = linkReader.time() * timeMul;
          activeContacts.remove(l);
          bw.write(l.id1() + "\t" + l.id2() + "\t" + b + "\t" + e + "\n");
        }
      }
    }
    linkReader.close();
    bw.close();
  }
예제 #17
0
파일: Lexicon.java 프로젝트: ePADD/muse
  /** gets map for all languages */
  public Map<String, String> getCaptionToQueryMap(Collection<Document> docs) {
    // identify all the langs in the docs, and the corresponding lexicons
    Set<String> languages = IndexUtils.allLanguagesInDocs(docs);
    Set<Lexicon1Lang> lexicons = new LinkedHashSet<Lexicon1Lang>();
    for (String lang : languages) {
      Lexicon1Lang lex = languageToLexicon.get(lang);
      if (lex != null) lexicons.add(lex);
      // this lexicon doesn't know about this language
      else log.warn("Warning: no support for " + lang + " in lexicon " + name);
    }

    Map<String, String> result = new LinkedHashMap<String, String>();
    // aggregate results for each lang into result
    for (Lexicon1Lang lex : lexicons) {
      Map<String, String> resultsForThisLang = lex.captionToExpandedQuery;

      for (String caption : resultsForThisLang.keySet()) {
        String queryThisLang = resultsForThisLang.get(caption);
        String query = result.get(caption);
        // if caption doesn't exist already, create a new entry, or else add to the existing set of
        // docs that match this caption
        if (query == null) result.put(caption, queryThisLang);
        else result.put(caption, query + "|" + queryThisLang);
      }
    }
    return result;
  }
예제 #18
0
  /** Read input to test and break down into blocks. See parser-tests/readme.txt */
  private Map readBlocks(Reader input) throws IOException {
    Map blocks = new HashMap();
    LineNumberReader reader = new LineNumberReader(input);
    String line;
    String blockName = null;
    StringBuffer blockContents = null;
    while ((line = reader.readLine()) != null) {
      if (line.startsWith("~~~ ") && line.endsWith(" ~~~")) {
        if (blockName != null) {
          blocks.put(blockName, blockContents.toString());
        }
        blockName = line.substring(4, line.length() - 4);
        blockContents = new StringBuffer();
      } else {
        if (blockName != null) {
          blockContents.append(line);
          blockContents.append('\n');
        }
      }
    }

    if (blockName != null) {
      blocks.put(blockName, blockContents.toString());
    }

    return blocks;
  }
예제 #19
0
  /**
   * Reads image meta data.
   *
   * @param oimage
   * @return
   */
  public static Map<String, String> readImageData(IIOImage oimage) {
    Map<String, String> dict = new HashMap<String, String>();

    IIOMetadata imageMetadata = oimage.getMetadata();
    if (imageMetadata != null) {
      IIOMetadataNode dimNode = (IIOMetadataNode) imageMetadata.getAsTree("javax_imageio_1.0");
      NodeList nodes = dimNode.getElementsByTagName("HorizontalPixelSize");
      int dpiX;
      if (nodes.getLength() > 0) {
        float dpcWidth = Float.parseFloat(nodes.item(0).getAttributes().item(0).getNodeValue());
        dpiX = (int) Math.round(25.4f / dpcWidth);
      } else {
        dpiX = Toolkit.getDefaultToolkit().getScreenResolution();
      }
      dict.put("dpiX", String.valueOf(dpiX));

      nodes = dimNode.getElementsByTagName("VerticalPixelSize");
      int dpiY;
      if (nodes.getLength() > 0) {
        float dpcHeight = Float.parseFloat(nodes.item(0).getAttributes().item(0).getNodeValue());
        dpiY = (int) Math.round(25.4f / dpcHeight);
      } else {
        dpiY = Toolkit.getDefaultToolkit().getScreenResolution();
      }
      dict.put("dpiY", String.valueOf(dpiY));
    }

    return dict;
  }
예제 #20
0
 void installDefaultAccessScopes() {
   decodingAccessScope.put(FIELD_SCOPE, PUBLIC);
   decodingAccessScope.put(PROPERTY_SCOPE, PUBLIC);
   decodingAccessScope.put(CONSTRUCTOR_SCOPE, PUBLIC);
   encodingAccessScope.put(FIELD_SCOPE, PUBLIC);
   encodingAccessScope.put(PROPERTY_SCOPE, PUBLIC);
 }
예제 #21
0
파일: IOUtil.java 프로젝트: 6qat/robomongo
  public static Map<String, Object> readPythonSettings(File file) throws IOException {

    String all = readStringFully(new FileInputStream(file));

    Map<String, Object> map = new TreeMap<String, Object>();

    for (String line : all.split("\n")) {
      line = line.trim();
      if (line.length() == 0) continue;

      String[] pcs = line.split("=");
      if (pcs.length != 2) continue;

      String name = pcs[0].trim();
      String value = pcs[1].trim();

      if (value.startsWith("\"")) {
        map.put(name, value.substring(1, value.length() - 1));
      } else {
        map.put(name, Long.parseLong(value));
      }
    }

    return map;
  }
예제 #22
0
 /**
  * Returns the existing git repositories for the given file path, following the given traversal
  * rule.
  *
  * @param path expected format /file/{Workspace}/{projectName}[/{path}]
  * @return a map of all git repositories found, or <code>null</code> if the provided path format
  *     doesn't match the expected format.
  * @throws CoreException
  */
 public static Map<IPath, File> getGitDirs(IPath path, Traverse traverse) throws CoreException {
   IPath p = path.removeFirstSegments(1); // remove /file
   IFileStore fileStore = NewFileServlet.getFileStore(null, p);
   if (fileStore == null) return null;
   Map<IPath, File> result = new HashMap<IPath, File>();
   File file = fileStore.toLocalFile(EFS.NONE, null);
   // jgit can only handle a local file
   if (file == null) return result;
   switch (traverse) {
     case CURRENT:
       if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) {
         result.put(new Path(""), file); // $NON-NLS-1$
       } else if (RepositoryCache.FileKey.isGitRepository(
           new File(file, Constants.DOT_GIT), FS.DETECTED)) {
         result.put(new Path(""), new File(file, Constants.DOT_GIT)); // $NON-NLS-1$
       }
       break;
     case GO_UP:
       getGitDirsInParents(file, result);
       break;
     case GO_DOWN:
       getGitDirsInChildren(file, p, result);
       break;
   }
   return result;
 }
예제 #23
0
  public List getUserListAT() {

    List<Map> list = new ArrayList<Map>();

    String[][] data = {
      {"3537255778", "Alex Chen"},
      {"2110989338", "Brian Wang"},
      {"3537640807", "David Hsieh"},
      {"5764816553", "James Yu"},
      {"3756404948", "K.C."},
      {"2110994764", "Neil Weinstock"},
      {"6797798390", "Owen Chen"},
      {"3831206627", "Randy Chen"},
      {"6312460903", "Tony Shen"},
      {"2110993498", "Yee Liaw"}
    };

    for (int i = 0; i < data.length; i++) {

      Map map = new HashMap();

      String userRef = data[i][0];
      String userName = data[i][1];

      map.put("userObjectId", userRef);
      map.put("userName", userName);

      list.add(map);
    }

    return list;
  }
 private void processLog(Object obj, long time, String type) {
   Map<String, Object> logItem = new HashMap<String, Object>();
   logItem.put("Time", time);
   logItem.put("logMsg", obj);
   logItem.put("msgType", type);
   this.processLog.add(logItem);
 }
  BuildSession(
      UUID sessionId,
      Channel channel,
      CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage params,
      @Nullable CmdlineRemoteProto.Message.ControllerMessage.FSEvent delta) {
    mySessionId = sessionId;
    myChannel = channel;

    // globals
    Map<String, String> pathVars = new HashMap<String, String>();
    final CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings globals =
        params.getGlobalSettings();
    for (CmdlineRemoteProto.Message.KeyValuePair variable : globals.getPathVariableList()) {
      pathVars.put(variable.getKey(), variable.getValue());
    }

    // session params
    myProjectPath = FileUtil.toCanonicalPath(params.getProjectId());
    String globalOptionsPath = FileUtil.toCanonicalPath(globals.getGlobalOptionsPath());
    myBuildType = convertCompileType(params.getBuildType());
    List<CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope>
        scopes = params.getScopeList();
    List<String> filePaths = params.getFilePathList();
    Map<String, String> builderParams = new HashMap<String, String>();
    for (CmdlineRemoteProto.Message.KeyValuePair pair : params.getBuilderParameterList()) {
      builderParams.put(pair.getKey(), pair.getValue());
    }
    myInitialFSDelta = delta;
    JpsModelLoaderImpl loader =
        new JpsModelLoaderImpl(myProjectPath, globalOptionsPath, pathVars, null);
    myBuildRunner = new BuildRunner(loader, scopes, filePaths, builderParams);
  }
예제 #26
0
  /**
   * @param ctx Kernal context.
   * @param cfg Ignite configuration.
   * @param providers Plugin providers.
   */
  @SuppressWarnings("TypeMayBeWeakened")
  public IgnitePluginProcessor(
      GridKernalContext ctx, IgniteConfiguration cfg, List<PluginProvider> providers) {
    super(ctx);

    ExtensionRegistryImpl registry = new ExtensionRegistryImpl();

    for (PluginProvider provider : providers) {
      GridPluginContext pluginCtx = new GridPluginContext(ctx, cfg);

      if (F.isEmpty(provider.name())) throw new IgniteException("Plugin name can not be empty.");

      if (plugins.containsKey(provider.name()))
        throw new IgniteException("Duplicated plugin name: " + provider.name());

      plugins.put(provider.name(), provider);

      pluginCtxMap.put(provider, pluginCtx);

      provider.initExtensions(pluginCtx, registry);

      if (provider.plugin() == null) throw new IgniteException("Plugin is null.");
    }

    extensions = registry.createExtensionMap();
  }
  private void outputEntry(TraceEntry te) {
    ThreadData td = te.getThread();
    if (td == null) return;

    // System.err.println("TRACE: " + te);

    BdynCallback cb = bdyn_factory.getCallback(te.getEntryLocation());
    if (cb == null) return;

    if (cb.getCallbackType() == CallbackType.CONSTRUCTOR) {
      OutputTask ot = td.getCurrentTransaction();
      if (ot == null) return;
      if (ot.isMainTask() && !BdynFactory.getOptions().useMainTask()) return;
      int i0 = te.getObject1();
      if (i0 != 0) {
        // System.err.println("ASSOC TASK " + i0 + " " + te.getObject2() + " " +
        // ot.getTaskRoot().getDisplayName());
        OutputTask ot1 = object_tasks.get(i0);
        if (ot1 == null) object_tasks.put(i0, ot);
        else if (ot1 != dummy_task && ot1 != ot) object_tasks.put(i0, dummy_task);
      }
      return;
    }

    td.beginTask(te);
    end_time = Math.max(end_time, te.getTime());
  }
  static {
    try {
      Map<String, Method> orderedMethods = new TreeMap<String, Method>();
      for (Method m : MBeanServerConnection.class.getDeclaredMethods()) {
        orderedMethods.put(m.toGenericString(), m);
      }
      Method[] methods = orderedMethods.values().toArray(new Method[orderedMethods.size()]);
      Map<String, Method> asynchMethods = new TreeMap<String, Method>();
      for (Method asynchMethod : AsynchJMXResponseListener.class.getDeclaredMethods()) {
        asynchMethods.put(asynchMethod.getName(), asynchMethod);
      }

      Map<Method, Byte> m2k = new HashMap<Method, Byte>(methods.length);
      Map<Byte, Method> k2m = new HashMap<Byte, Method>(methods.length);
      Map<Byte, Method> k2am = new HashMap<Byte, Method>(methods.length);
      for (int i = 0; i < methods.length; i++) {
        m2k.put(methods[i], (byte) i);
        k2m.put((byte) i, methods[i]);
        Method asynchMethod = asynchMethods.get(methods[i].getName() + "Response");
        if (asynchMethod == null)
          throw new RuntimeException(
              "Failed to find asynch handler for [" + methods[i].toGenericString() + "]",
              new Throwable());
        k2am.put((byte) i, asynchMethod);
      }
      methodToKey = Collections.unmodifiableMap(m2k);
      keyToMethod = Collections.unmodifiableMap(k2m);
      keyToAsynchMethod = Collections.unmodifiableMap(k2am);
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
  public InputStream invokeClientInbound(HttpURLConnection httpConnection) throws IOException {
    // XXX fill this in...
    Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();

    Map<String, Object> httpProperties = new HashMap<String, Object>();
    httpProperties.put(HTTP_RESPONSE_CODE, Integer.valueOf(httpConnection.getResponseCode()));
    httpProperties.put(HTTP_RESPONSE_HEADERS, httpConnection.getHeaderFields());

    prepare(httpProperties, /*request=*/ false);

    if (!invokeInbound(httpConnection.getInputStream(), attachments)) {
      if (getProtocolException() != null) {
        reverseDirection();
        invokeInboundFaultHandlers();

        if (getRuntimeException() != null) throw getRuntimeException();
      } else if (getRuntimeException() != null) {
        closeClient();
        throw getRuntimeException();
      }
    }

    // XXX
    closeClient();
    return finish();
  }
예제 #30
0
  public static Map<String, String> sendPostRequest(
      String url, JSONObject params, Map<String, String> headers) throws IDPTokenManagerException {
    HttpPost httpPost = new HttpPost(url);
    HttpClient httpClient = getCertifiedHttpClient();
    Map<String, String> responseParams = new HashMap<String, String>();

    if (params != null) {
      try {
        httpPost.setEntity(new StringEntity(params.toString()));
      } catch (UnsupportedEncodingException e) {
        throw new IDPTokenManagerException("Invalid encoding type.", e);
      }
    }

    HttpPost httpPostWithHeaders = (HttpPost) buildHeaders(httpPost, headers, HTTP_METHODS.POST);
    try {
      HttpResponse response = httpClient.execute(httpPostWithHeaders);
      String status = String.valueOf(response.getStatusLine().getStatusCode());

      responseParams.put(Constants.SERVER_RESPONSE_BODY, getResponseBody(response));
      responseParams.put(Constants.SERVER_RESPONSE_STATUS, status);

    } catch (ClientProtocolException e) {
      throw new IDPTokenManagerException("Invalid client protocol.", e);
    } catch (IOException e) {
      responseParams.put(Constants.SERVER_RESPONSE_BODY, "Internal Server Error");
      responseParams.put(Constants.SERVER_RESPONSE_STATUS, Constants.INTERNAL_SERVER_ERROR);
      throw new IDPTokenManagerException("Server connectivity failure.", e);
    }

    return responseParams;
  }