JarFile get(URL url, boolean useCaches) throws IOException { JarFile result = null; JarFile local_result = null; if (useCaches) { synchronized (this) { result = getCachedJarFile(url); } if (result == null) { local_result = URLJarFile.getJarFile(url); synchronized (this) { result = getCachedJarFile(url); if (result == null) { fileCache.put(url, local_result); urlCache.put(local_result, url); result = local_result; } else { if (local_result != null) { local_result.close(); } } } } } else { result = URLJarFile.getJarFile(url); } if (result == null) throw new FileNotFoundException(url.toString()); return result; }
// get relation sort order, or use defaults private void loadRelationSortOrder(Element relationSortingElt) { // use defaults if no order specified if (relationSortingElt == null) { for (int i = 0; i < defaultRelationSortOrder.length; i++) { _relationIndexMap.put(defaultRelationSortOrder[i], new Integer(i)); } return; } // otherwise load from 'order' attribute String orderAttr = relationSortingElt.getAttributeValue("order"); String[] relSortOrder = orderAttr.split("\\s+"); for (int i = 0; i < relSortOrder.length; i++) { _relationIndexMap.put(relSortOrder[i], new Integer(i)); } }
public void run() { String line; String id = null; seqs = new HashMap<String, StringBuffer>(); try { // System.err.println("quality read start"); // debug while (true) { line = br.readLine(); // FIX ME: update to use reader... if (line == null) break; // EOF if (line.indexOf(">") == 0) { String[] stuff = line.substring(1).split("\\s+"); id = new String(stuff[0]); // HACK, WRONG if line contains comments... } else { // sequence StringBuffer sb = seqs.get(id); if (sb == null) seqs.put(id, sb = new StringBuffer()); sb.append(line); } } data_loaded = true; // System.err.println("quality read end"); // debug } catch (Exception e) { System.err.println("FASTASequenceReader load error: " + e); // debug System.exit(1); } }
/** {@inheritDoc} */ public void initializeFrom(Element element) throws DocumentSerializationException { for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) { Element serviceElement = (TextElement) e.nextElement(); String tagName = (String) serviceElement.getKey(); if (tagName.equals("service")) { try { ModuleClassID moduleClassID = (ModuleClassID) IDFactory.fromURI( new URI( DocumentSerializableUtilities.getString( serviceElement, "moduleClassID", "ERROR"))); try { ServiceMonitorFilter serviceMonitorFilter = MonitorResources.createServiceMonitorFilter(moduleClassID); serviceMonitorFilter.init(moduleClassID); Element serviceMonitorFilterElement = DocumentSerializableUtilities.getChildElement(serviceElement, "serviceFilter"); serviceMonitorFilter.initializeFrom(serviceMonitorFilterElement); serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter); } catch (Exception ex) { if (unknownModuleClassIDs == null) unknownModuleClassIDs = new LinkedList(); unknownModuleClassIDs.add(moduleClassID); } } catch (URISyntaxException jex) { throw new DocumentSerializationException("Can't get ModuleClassID", jex); } } } }
/** * Returns an icon for the specified file. * * @param file file reference * @return icon */ public static Icon file(final IOFile file) { if (file == null) return UNKNOWN; // fallback code for displaying icons final String path = file.path(); final MediaType type = MediaType.get(path); if (type.isXML()) return XML; if (type.isXQuery()) return XQUERY; if (path.contains(IO.BASEXSUFFIX)) return BASEX; // only works with standard dpi (https://bugs.openjdk.java.net/browse/JDK-6817929) if (Prop.WIN && !GUIConstants.large()) { // retrieve system icons (only supported on Windows) final int p = path.lastIndexOf(path, '.'); final String suffix = p == -1 ? null : path.substring(p + 1); Icon icon = null; if (suffix != null) icon = FILES.get(suffix); if (icon == null) { icon = FS.getSystemIcon(file.file()); if (suffix != null) FILES.put(suffix, icon); } return icon; } // default icon chooser return type.isText() ? TEXT : UNKNOWN; }
/** * Returns the specified image as icon. * * @param name name of icon * @return icon */ public static ImageIcon icon(final String name) { ImageIcon ii = ICONS.get(name); if (ii != null) return ii; Image img; if (GUIConstants.scale > 1) { // choose large image or none final URL url = GUIConstants.large() ? BaseXImages.class.getResource("/img/" + name + "_32.png") : null; if (url == null) { // resize low-res image if no hi-res image exists img = get(url(name)); final int w = (int) (img.getWidth(null) * GUIConstants.scale); final int h = (int) (img.getHeight(null) * GUIConstants.scale); final BufferedImage tmp = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); final Graphics2D g2 = tmp.createGraphics(); g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2.drawImage(img, 0, 0, w, h, null); g2.dispose(); img = tmp; } else { img = get(url); } } else { img = get(name); } ii = new ImageIcon(img); ICONS.put(name, ii); return ii; }
public void sendrecv(Request request, Response response, long timeout) throws IOException { synchronized (response_map) { makeKey(request); response.isReceived = false; try { response_map.put(request, response); doSend(request); response.expiration = System.currentTimeMillis() + timeout; while (!response.isReceived) { response_map.wait(timeout); timeout = response.expiration - System.currentTimeMillis(); if (timeout <= 0) { throw new TransportException(name + " timedout waiting for response to " + request); } } } catch (IOException ioe) { if (log.level > 2) ioe.printStackTrace(log); try { disconnect(true); } catch (IOException ioe2) { ioe2.printStackTrace(log); } throw ioe; } catch (InterruptedException ie) { throw new TransportException(ie); } finally { response_map.remove(request); } } }
/** Looks up the local database, creating if necessary. */ private DataSource findDatabaseImpl(String url, String driverName) throws SQLException { try { synchronized (_databaseMap) { DBPool db = _databaseMap.get(url); if (db == null) { db = new DBPool(); db.setVar(url + "-" + _gId++); DriverConfig driver = db.createDriver(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class driverClass = Class.forName(driverName, false, loader); driver.setType(driverClass); driver.setURL(url); db.init(); _databaseMap.put(url, db); } return db; } } catch (RuntimeException e) { throw e; } catch (SQLException e) { throw e; } catch (Exception e) { throw ConfigException.create(e); } }
public ArrayList getPointList(long handId) { ArrayList curList; if (_pointLists.containsKey(handId)) curList = (ArrayList) _pointLists.get(handId); else { curList = new ArrayList(_maxPoints); _pointLists.put(handId, curList); } return curList; }
/** * Add a ServiceMonitorFilter to this MonitorFilter * * @param serviceMonitorFilter Service Specific Filter * @exception MonitorFilterException * @return ServiceMonitorFilter Modified Filter to the capabilities of the service */ public ServiceMonitorFilter addServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter) throws MonitorFilterException { ModuleClassID moduleClassID = serviceMonitorFilter.getModuleClassID(); if (serviceMonitorFilters.get(moduleClassID) != null) throw new MonitorFilterException( "Attempt to add a second Monitor Filter for: " + moduleClassID); serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter); return serviceMonitorFilter; }
public static void main(String[] args) throws Exception { System.out.println("hello world! I am the client"); System.out.println("trying to connect to " + PEER_PORT); Socket toPeer = null; while (toPeer == null) { try { toPeer = new Socket("localhost", PEER_PORT); } catch (UnknownHostException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } // First param: server-address, Second: the port } System.out.println("connected to " + PEER_PORT); OutputStream out = null; try { out = toPeer.getOutputStream(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // PrintStream ps = new PrintStream(out, true); // Second param: auto-flush on write = true ObjectOutputStream oos = new ObjectOutputStream(out); while (true) { HashMap<String, String> dictionary = new HashMap<String, String>(); // TODO: first, send ACK to new client // TODO: pick a new chunk to request // TODO: then send request dictionary.put("type", "request"); dictionary.put("body", "CHUNK_ID"); oos.writeObject(dictionary); // TODO: wait to receive } }
void addTextField(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextField field = new JTextField(); field.setText(sketch.configFile.get(key)); field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height)); fields.put(key, field); panel.add(field); }
public void registerListener(int id, MessageListener m) { HashSet listenerSet = (HashSet) idTable.get(new Integer(id)); if (listenerSet == null) { listenerSet = new HashSet(); idTable.put(new Integer(id), listenerSet); } listenerSet.add(m); log.info("New Listener for id=" + id); }
public long openUdpSocket(InetSocketAddress address) throws IOException { // TODO, don't throw an exception out of here. DatagramChannel dg = DatagramChannel.open(); dg.configureBlocking(false); dg.socket().bind(address); long b = createBinding(); EventableChannel ec = new EventableDatagramChannel(dg, b, mySelector); dg.register(mySelector, SelectionKey.OP_READ, ec); Connections.put(b, ec); return b; }
private static void handleNonDownloadPost(Post post) { for (Picture picture : post.pictures) { if (!Main.pic_pic_hash.containsKey(picture)) { Main.pic_pic_hash.put(picture, picture); Main.pic_post_hash.put(picture, post); } else { if (!post.equals(Main.pic_post_hash.get(picture))) { dup_post_list.put(post, Main.pic_post_hash.get(picture)); } } } }
void addTextArea(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextArea field = new JTextArea(); field.setText(sketch.configFile.get(key)); field.setLineWrap(true); field.setWrapStyleWord(true); fields.put(key, field); JScrollPane scroll = new JScrollPane(field); scroll.setAlignmentX(0.0f); panel.add(scroll); }
public boolean startProxy(long from, long to) { // lazy init for proxy support check quickly in isReadable if (ProxyConnections == null) { ProxyConnections = new HashMap<Long, EventableChannel>(); } EventableChannel target = Connections.get(to); if (target != null) { ProxyConnections.put(from, target); return true; } else { return false; } }
public long attachChannel(SocketChannel sc, boolean watch_mode) { long b = createBinding(); EventableSocketChannel ec = new EventableSocketChannel(sc, b, mySelector); ec.setAttached(); if (watch_mode) ec.setWatchOnly(); Connections.put(b, ec); NewConnections.add(b); return b; }
public long startTcpServer(SocketAddress sa) throws EmReactorException { try { ServerSocketChannel server = ServerSocketChannel.open(); server.configureBlocking(false); server.socket().bind(sa); long s = createBinding(); Acceptors.put(s, server); server.register(mySelector, SelectionKey.OP_ACCEPT, s); return s; } catch (IOException e) { throw new EmReactorException("unable to open socket acceptor: " + e.toString()); } }
private void addMenuToTray() { HashMap categories = new HashMap(); // create menu list Iterator plugins = PluginManager.getInstance().getAvailablePlugins(); plugins = PluginComparator.sortPlugins(plugins); while (plugins.hasNext()) { Plugin p = (Plugin) plugins.next(); JMenu category = (JMenu) categories.get(p.getCategory()); if (category == null) { category = new JMenu(p.getCategory()); categories.put(p.getCategory(), category); // copy menu to real one if (!p.getCategory().equals("Invisible")) this.trayIcon.add(category); } ImageIcon icon = new ImageIcon(); try { icon = new ImageIcon(new URL(p.getDirectory() + p.getIcon())); icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH)); } catch (Exception e) { // error at icon loading } JMenuItem menu = new JMenuItem(p.getTitle(), icon); menu.setName(p.getName()); menu.setToolTipText(p.getToolTip()); menu.addActionListener(this); category.add(menu); } this.trayIcon.addSeparator(); // windows this.trayIcon.add(new WindowMenu(this)); // open main interface JMenuItem menu = new JMenuItem(tr("open")); menu.setName("org.lucane.applications.maininterface"); menu.addActionListener(this); this.trayIcon.add(menu); // exit menu = new JMenuItem(tr("exit")); menu.setName("exit"); menu.addActionListener(this); this.trayIcon.add(menu); }
/** * Retrieves default values from xml. * * @param list the configuration list */ private static void parseDefaults(NodeList list) { for (int i = 0; i < list.getLength(); ++i) { NamedNodeMap mapping = list.item(i).getAttributes(); String attribute = mapping.getNamedItem("attribute").getNodeValue(); String value = mapping.getNamedItem("value").getNodeValue(); try { Default field = Default.fromString(attribute); DEFAULTS.put(field, value); } catch (IllegalArgumentException exc) { logger.warn("Unrecognized default attribute: " + attribute); } } }
protected void saveAuthCache() { try { this_mon.enter(); HashMap map = new HashMap(); Iterator it = auth_cache.values().iterator(); while (it.hasNext()) { authCache value = (authCache) it.next(); if (value.isPersistent()) { try { HashMap entry_map = new HashMap(); entry_map.put("user", value.getAuth().getUserName().getBytes("UTF-8")); entry_map.put("pw", new String(value.getAuth().getPassword()).getBytes("UTF-8")); map.put(value.getKey(), entry_map); } catch (Throwable e) { Debug.printStackTrace(e); } } } COConfigurationManager.setParameter(CONFIG_PARAM, map); } finally { this_mon.exit(); } }
private static void handlePost(Post post) { Main.post_post_hash.put(post, post); for (Picture picture : post.pictures) { Helper.downloadFileFromURLToFileInTemp(picture.thumb_url, picture.thumb_name); picture.md5_id = Helper.createMD5FromFileInTemp(picture.thumb_name); Helper.moveTempImageToStore(picture.thumb_name, new File(Main.blogdir, picture.md5_id)); if (!Main.pic_pic_hash.containsKey(picture)) { Main.pic_pic_hash.put(picture, picture); Main.pic_post_hash.put(picture, post); Helper.downloadFileFromURLToFileInTemp(picture.media_url, picture.media_name); Helper.moveTempImageToStore(picture.media_name, new File(Main.blogdir, picture.md5_id)); } else { if (!post.equals(Main.pic_post_hash.get(picture))) { dup_post_list.put(post, Main.pic_post_hash.get(picture)); } } } }
protected void handleMessage(Message msg) throws Exception { Address dest = msg.getDest(); long len; List tmp; len = msg.size(); // todo: use msg.getLength() instead of msg.getSize() if (len > max_bundle_size) { throw new Exception( "UDP.BundlingOutgoingPacketHandler.handleMessage(): " + "message size (" + len + ") is greater than UDP fragmentation size. " + "Set the fragmentation/bundle size in FRAG and UDP correctly"); } if (total_bytes + len >= max_bundle_size) { if (Trace.trace) { Trace.info( "UDP.BundlingOutgoingPacketHandler.handleMessage()", "sending " + total_bytes + " bytes"); } bundleAndSend(); // send all pending message and clear table total_bytes = 0; } synchronized (msgs) { tmp = (List) msgs.get(dest); if (tmp == null) { tmp = new List(); msgs.put(dest, tmp); } tmp.add(msg); total_bytes += len; } if (!timer_running) { // first message to be bundled startTimer(); } }
void isAcceptable(SelectionKey k) { ServerSocketChannel ss = (ServerSocketChannel) k.channel(); SocketChannel sn; long b; for (int n = 0; n < 10; n++) { try { sn = ss.accept(); if (sn == null) break; } catch (IOException e) { e.printStackTrace(); k.cancel(); ServerSocketChannel server = Acceptors.remove(k.attachment()); if (server != null) try { server.close(); } catch (IOException ex) { } ; break; } try { sn.configureBlocking(false); } catch (IOException e) { e.printStackTrace(); continue; } b = createBinding(); EventableSocketChannel ec = new EventableSocketChannel(sn, b, mySelector); Connections.put(b, ec); NewConnections.add(b); eventCallback(((Long) k.attachment()).longValue(), EM_CONNECTION_ACCEPTED, null, b); } }
public long connectTcpServer(String bindAddr, int bindPort, String address, int port) { long b = createBinding(); try { SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); if (bindAddr != null) sc.socket().bind(new InetSocketAddress(bindAddr, bindPort)); EventableSocketChannel ec = new EventableSocketChannel(sc, b, mySelector); if (sc.connect(new InetSocketAddress(address, port))) { // Connection returned immediately. Can happen with localhost connections. // WARNING, this code is untested due to lack of available test conditions. // Ought to be be able to come here from a localhost connection, but that // doesn't happen on Linux. (Maybe on FreeBSD?) // The reason for not handling this until we can test it is that we // really need to return from this function WITHOUT triggering any EM events. // That's because until the user code has seen the signature we generated here, // it won't be able to properly dispatch them. The C++ EM deals with this // by setting pending mode as a flag in ALL eventable descriptors and making // the descriptor select for writable. Then, it can send UNBOUND and // CONNECTION_COMPLETED on the next pass through the loop, because writable will // fire. throw new RuntimeException("immediate-connect unimplemented"); } else { ec.setConnectPending(); Connections.put(b, ec); NewConnections.add(b); } } catch (IOException e) { // Can theoretically come here if a connect failure can be determined immediately. // I don't know how to make that happen for testing purposes. throw new RuntimeException("immediate-connect unimplemented: " + e.toString()); } return b; }
/** Loads the lexicon and morph files. */ public void init(URL lexiconUrl, URL morphUrl) throws IOException { List<Family> lexicon = null; List<MorphItem> morph = null; List<MacroItem> macroModel = null; // load category families (lexicon), morph forms and macros lexicon = getLexicon(lexiconUrl); Pair<List<MorphItem>, List<MacroItem>> morphInfo = getMorph(morphUrl); morph = morphInfo.a; macroModel = morphInfo.b; // index words; also index stems to words, as default preds // store indexed coarticulation attrs too _words = new GroupMap<Word, MorphItem>(); _predToWords = new GroupMap<String, Word>(); _coartAttrs = new HashSet<String>(); _indexedCoartAttrs = new HashSet<String>(); for (MorphItem morphItem : morph) { Word surfaceWord = morphItem.getSurfaceWord(); _words.put(surfaceWord, morphItem); _predToWords.put(morphItem.getWord().getStem(), surfaceWord); if (morphItem.isCoart()) { Word indexingWord = morphItem.getCoartIndexingWord(); _words.put(indexingWord, morphItem); Pair<String, String> first = indexingWord.getSurfaceAttrValPairs().next(); _indexedCoartAttrs.add(first.a); for (Iterator<Pair<String, String>> it = surfaceWord.getSurfaceAttrValPairs(); it.hasNext(); ) { Pair<String, String> p = it.next(); _coartAttrs.add(p.a); } } } // index entries based on stem+pos _stems = new GroupMap<String, Object>(); _posToEntries = new GroupMap<String, EntriesItem[]>(); // index entries by supertag+pos, for supertagging _stagToEntries = new GroupMap<String, EntriesItem>(); // also index rels and coart rels to preds _relsToPreds = new GroupMap<String, String>(); _coartRelsToPreds = new GroupMap<String, String>(); // and gather list of attributes used per atomic category type _catsToAttrs = new GroupMap<String, String>(); _lfAttrs = new HashSet<String>(); // and remember family and ent, names, for checking excluded list on morph items HashSet<String> familyAndEntryNames = new HashSet<String>(); // index each family for (Family family : lexicon) { familyAndEntryNames.add(family.getName()); EntriesItem[] entries = family.getEntries(); DataItem[] data = family.getData(); // for generic use when we get an unknown stem // from the morphological analyzer if (!family.isClosed()) { _posToEntries.put(family.getPOS(), entries); } // scan through entries for (int j = 0; j < entries.length; j++) { // index EntriesItem eItem = entries[j]; _stagToEntries.put(eItem.getSupertag() + family.getPOS(), eItem); if (eItem.getStem().length() > 0) { _stems.put(eItem.getStem() + family.getPOS(), eItem); } try { // gather features eItem.getCat().forall(gatherAttrs); // record names familyAndEntryNames.add(eItem.getName()); familyAndEntryNames.add(eItem.getQualifiedName()); } catch (RuntimeException exc) { System.err.println("exception for: " + family.getName() + ": " + exc); } } // scan through data for (int j = 0; j < data.length; j++) { DataItem dItem = data[j]; _stems.put( dItem.getStem() + family.getPOS(), new Pair<DataItem, EntriesItem[]>(dItem, entries)); // index non-default preds to words if (!dItem.getStem().equals(dItem.getPred())) { Collection<Word> words = (Collection<Word>) _predToWords.get(dItem.getStem()); if (words == null) { if (!openlex) { System.out.print("Warning: couldn't find words for pred '"); System.out.println(dItem.getPred() + "' with stem '" + dItem.getStem() + "'"); } } else { for (Iterator<Word> it = words.iterator(); it.hasNext(); ) { _predToWords.put(dItem.getPred(), it.next()); } } } } // index rels to preds // nb: this covers relational (eg @x<GenRel>e) and featural (eg @e<tense>past) // elementary predications List<String> indexRels = new ArrayList<String>(3); String familyIndexRel = family.getIndexRel(); if (familyIndexRel.length() > 0) { indexRels.add(familyIndexRel); } for (int j = 0; j < entries.length; j++) { EntriesItem eItem = entries[j]; String indexRel = eItem.getIndexRel(); if (indexRel.length() > 0 && !indexRel.equals(familyIndexRel)) { indexRels.add(indexRel); } } for (Iterator<String> it = indexRels.iterator(); it.hasNext(); ) { String indexRel = it.next(); // nb: not indexing on entries items, b/c some stems are still defaults for (int j = 0; j < data.length; j++) { DataItem dItem = data[j]; _relsToPreds.put(indexRel, dItem.getPred()); } } // index coart rels (features, really) to preds String coartRel = family.getCoartRel(); if (coartRel.length() > 0) { for (int j = 0; j < data.length; j++) { _coartRelsToPreds.put(coartRel, data[j].getPred()); } } } // index the macros _macros = new GroupMap<String, FeatureStructure>(); // nb: could just index MacroItem objects for feature structures too; // this might be a bit cleaner, but life is short _macroItems = new HashMap<String, MacroItem>(); for (MacroItem mi : macroModel) { String macName = mi.getName(); FeatureStructure[] specs = mi.getFeatureStructures(); for (int j = 0; j < specs.length; j++) { _macros.put(macName, specs[j]); } // this is for handling LF part of macros _macroItems.put(macName, mi); } // with morph items, check POS, macro names, excluded list for xref for (MorphItem morphItem : morph) { Word w = morphItem.getWord(); if (!openlex && !_stems.containsKey(w.getStem() + w.getPOS()) && !_posToEntries.containsKey(w.getPOS())) { System.err.println( "Warning: no entries for stem '" + w.getStem() + "' and POS '" + w.getPOS() + "' found for word '" + w + "'"); } String[] macroNames = morphItem.getMacros(); for (int j = 0; j < macroNames.length; j++) { if (!_macroItems.containsKey(macroNames[j])) { System.err.println( "Warning: macro " + macroNames[j] + " not found for word '" + morphItem.getWord() + "'"); } } String[] excludedNames = morphItem.getExcluded(); for (int j = 0; j < excludedNames.length; j++) { if (!familyAndEntryNames.contains(excludedNames[j])) { System.err.println( "Warning: excluded family or entry '" + excludedNames[j] + "' not found for word '" + morphItem.getWord() + "'"); } } } }
private void mapAndTocForFile(File f, File path, String underscore) { // we get the single name of the file and the urlname int under_index2 = f.getName().indexOf("_"); int point_index2 = f.getName().indexOf("."); String named = f.getName().substring(under_index2 + 1, point_index2); String tmp = path.getAbsolutePath() + "Main_pages/fr/"; String url_name = f.getPath().replace("\\", "/").substring(tmp.length()); String targetName = url_name.substring(0, url_name.lastIndexOf(".html")); // now we will add into the map and the toc print.println("<mapID target=\"" + targetName + "\" url=\"pages/" + url_name + "\"/>"); File dir_associated = new File(f.getParent(), named); if ((dir_associated.exists() && dir_associated.isDirectory()) || named.equals("objects")) { print2.println( "<tocitem text=\"" + getTitle(f) + "\" target=\"" + targetName + "\" image=\"tamicon\">"); if (dir_associated.exists()) { // Apres on fait pareil pour tous les sous fichiers File[] sub_files = dir_associated.listFiles(); for (int i = 0; i < sub_files.length; i++) { if (!sub_files[i].getName().equals("CVS") && sub_files[i].isFile()) { if (sub_files[i].getName().endsWith(".html")) mapAndTocForFile(sub_files[i], path, underscore); else { try { copyFile( sub_files[i], new File(path, "pages/" + named + "/" + sub_files[i].getName())); } catch (IOException e) { LOG.error("Error while copying normal files in help " + e); } } } } } if (named.equals("objects")) { // Specialement pour les objets on les rajoute tous File objects_dir = new File( Configuration.instance() .getTangaraPath() .getParentFile() .getAbsolutePath() .replace("\\", "/") + "/objects/"); File[] listfiles = objects_dir.listFiles(); Vector<String> list_names = new Vector<String>(); HashMap<String, String> map = new HashMap<String, String>(); for (int i = 0; i < listfiles.length; i++) { try { if (listfiles[i].getName().endsWith(".jar")) { int point_index = listfiles[i].getName().lastIndexOf("."); String name = listfiles[i].getName().substring(0, point_index); // Copy the pages in the right directory File object_dir = new File(path, "pages/" + name); object_dir.mkdir(); File object_ressource = new File( Configuration.instance() .getTangaraPath() .getParentFile() .getAbsolutePath() .replace("\\", "/") + "/objects/resources/" + name + "/Help"); if (object_ressource.exists()) { File[] list_html_object = object_ressource.listFiles(); for (int e = 0; e < list_html_object.length; e++) { if (list_html_object[e].getName().endsWith(".html")) { int under_index = list_html_object[e].getName().lastIndexOf("_"); if (underscore.equals("") && under_index == -1) copyFile( list_html_object[e], new File(path, "pages/" + name + "/" + list_html_object[e].getName())); else if (!underscore.equals("")) { if (list_html_object[e].getName().contains(underscore)) copyFile( list_html_object[e], new File(path, "pages/" + name + "/" + list_html_object[e].getName())); } } else copyFile( list_html_object[e], new File(path, "pages/" + name + "/" + list_html_object[e].getName())); } // Gets the name of the object in the selected language String name_lang = null; if (underscore.equals("")) name_lang = name; else { name_lang = getLangName(listfiles[i]); } if (name_lang != null) { list_names.add(name_lang); map.put(name_lang, name); // Add to the map file print.println( "<mapID target=\"" + name + "\" url=\"pages/" + name + "/index" + underscore + ".html\" />"); } } } } catch (Exception e2) { LOG.error("Error2 getHelp " + e2); } } // Add to the tam file Collections.sort(list_names); for (String s : list_names) { print2.println( "<tocitem text=\"" + s + "\" target=\"" + map.get(s) + "\" image=\"fileicon\" />"); } } print2.println("</tocitem>"); } else { // pas de sous fichiers print2.println( "<tocitem text=\"" + getTitle(f) + "\" target=\"" + targetName + "\" image=\"fileicon\"/>"); } File parent = new File(path, "pages/" + url_name.substring(0, url_name.lastIndexOf(named) - 3)); if (!parent.exists()) parent.mkdirs(); File in_pages = new File(path, "pages/" + url_name); try { in_pages.createNewFile(); copyFile(f, in_pages); } catch (IOException e3) { LOG.error("Error 3 getHelp " + e3 + " " + f.getName()); } }
static void initializePlugins(@Nullable StartupProgress progress) { configureExtensions(); final IdeaPluginDescriptorImpl[] pluginDescriptors = loadDescriptors(progress); final Class callerClass = ReflectionUtil.findCallerClass(1); assert callerClass != null; final ClassLoader parentLoader = callerClass.getClassLoader(); final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>(); final HashMap<String, String> disabledPluginNames = new HashMap<String, String>(); for (IdeaPluginDescriptorImpl descriptor : pluginDescriptors) { if (descriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID)) { final List<String> modules = descriptor.getModules(); if (modules != null) { ourAvailableModules.addAll(modules); } } if (!shouldSkipPlugin(descriptor, pluginDescriptors)) { result.add(descriptor); } else { descriptor.setEnabled(false); disabledPluginNames.put(descriptor.getPluginId().getIdString(), descriptor.getName()); initClassLoader(parentLoader, descriptor); } } prepareLoadingPluginsErrorMessage(filterBadPlugins(result, disabledPluginNames)); final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap = new HashMap<PluginId, IdeaPluginDescriptorImpl>(); for (final IdeaPluginDescriptorImpl descriptor : result) { idToDescriptorMap.put(descriptor.getPluginId(), descriptor); } final IdeaPluginDescriptor corePluginDescriptor = idToDescriptorMap.get(PluginId.getId(CORE_PLUGIN_ID)); assert corePluginDescriptor != null : CORE_PLUGIN_ID + " not found; platform prefix is " + System.getProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY); for (IdeaPluginDescriptorImpl descriptor : result) { if (descriptor != corePluginDescriptor) { descriptor.insertDependency(corePluginDescriptor); } } mergeOptionalConfigs(idToDescriptorMap); // sort descriptors according to plugin dependencies Collections.sort(result, getPluginDescriptorComparator(idToDescriptorMap)); for (int i = 0; i < result.size(); i++) { ourId2Index.put(result.get(i).getPluginId(), i); } int i = 0; for (final IdeaPluginDescriptorImpl pluginDescriptor : result) { if (pluginDescriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID) || pluginDescriptor.isUseCoreClassLoader()) { pluginDescriptor.setLoader(parentLoader, true); } else { final List<File> classPath = pluginDescriptor.getClassPath(); final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds(); final ClassLoader[] parentLoaders = getParentLoaders(idToDescriptorMap, dependentPluginIds); final ClassLoader pluginClassLoader = createPluginClassLoader( classPath.toArray(new File[classPath.size()]), parentLoaders.length > 0 ? parentLoaders : new ClassLoader[] {parentLoader}, pluginDescriptor); pluginDescriptor.setLoader(pluginClassLoader, true); } pluginDescriptor.registerExtensions(); if (progress != null) { progress.showProgress( "", PLUGINS_PROGRESS_MAX_VALUE + (i++ / (float) result.size()) * 0.35f); } } ourPlugins = pluginDescriptors; }
private void restGotoStep(final PwmRequest pwmRequest, final ConfigGuideBean configGuideBean) throws PwmUnrecoverableException, IOException, ServletException { final String requestedStep = pwmRequest.readParameterAsString("step"); STEP step = null; if (requestedStep != null && requestedStep.length() > 0) { try { step = STEP.valueOf(requestedStep); } catch (IllegalArgumentException e) { /* */ } } final boolean ldapSchemaPermitted = "LDAP".equals(configGuideBean.getFormData().get(PARAM_CR_STORAGE_PREF)) && configGuideBean.getSelectedTemplate() == PwmSettingTemplate.NOVL; if ("NEXT".equals(requestedStep)) { step = configGuideBean.getStep().next(); if (step == STEP.LDAP_SCHEMA && !ldapSchemaPermitted) { step = step.next(); } } else if ("PREVIOUS".equals(requestedStep)) { step = configGuideBean.getStep().previous(); if (step == STEP.LDAP_SCHEMA && !ldapSchemaPermitted) { step = step.previous(); } } if (step == null) { final String errorMsg = "unknown goto step request: " + requestedStep; final ErrorInformation errorInformation = new ErrorInformation(PwmError.CONFIG_FORMAT_ERROR, errorMsg); final RestResultBean restResultBean = RestResultBean.fromError(errorInformation, pwmRequest); LOGGER.error(pwmRequest, errorInformation.toDebugStr()); pwmRequest.outputJsonResult(restResultBean); return; } if (step == STEP.FINISH) { final ContextManager contextManager = ContextManager.getContextManager(pwmRequest); try { writeConfig(contextManager, configGuideBean); } catch (PwmException e) { final RestResultBean restResultBean = RestResultBean.fromError(e.getErrorInformation(), pwmRequest); pwmRequest.outputJsonResult(restResultBean); return; } catch (Exception e) { final RestResultBean restResultBean = RestResultBean.fromError( new ErrorInformation( PwmError.ERROR_UNKNOWN, "error during save: " + e.getMessage()), pwmRequest); pwmRequest.outputJsonResult(restResultBean); return; } final HashMap<String, String> resultData = new HashMap<>(); resultData.put("serverRestart", "true"); pwmRequest.outputJsonResult(new RestResultBean(resultData)); pwmRequest.invalidateSession(); } else { configGuideBean.setStep(step); pwmRequest.outputJsonResult(new RestResultBean()); LOGGER.trace("setting current step to: " + step); } }