Creates and attaches the annotation index to a resource root, if it has not already been attached
343568
public static void indexResourceRoot(final ResourceRoot resourceRoot) throws DeploymentUnitProcessingException {
        if (resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX) != null) {
            return;
        }

        VirtualFile indexFile = resourceRoot.getRoot().getChild(ModuleIndexBuilder.INDEX_LOCATION);
        if (indexFile.exists()) {
            try {
                IndexReader reader = new IndexReader(indexFile.openStream());
                resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, reader.read());
                ServerLogger.DEPLOYMENT_LOGGER.tracef("Found and read index at: %s", indexFile);
                return;
            } catch (Exception e) {
                ServerLogger.DEPLOYMENT_LOGGER.cannotLoadAnnotationIndex(indexFile.getPathName());
            }
        }

        // if this flag is present and set to false then do not index the resource
        Boolean shouldIndexResource = resourceRoot.getAttachment(Attachments.INDEX_RESOURCE_ROOT);
        if (shouldIndexResource != null && !shouldIndexResource) {
            return;
        }

        final List<String> indexIgnorePathList = resourceRoot.getAttachment(Attachments.INDEX_IGNORE_PATHS);
        final Set<String> indexIgnorePaths;
        if (indexIgnorePathList != null && !indexIgnorePathList.isEmpty()) {
            indexIgnorePaths = new HashSet<String>(indexIgnorePathList);
        } else {
            indexIgnorePaths = null;
        }

        final VirtualFile virtualFile = resourceRoot.getRoot();
        final Indexer indexer = new Indexer();
        try {
            final VisitorAttributes visitorAttributes = new VisitorAttributes();
            visitorAttributes.setLeavesOnly(true);
            visitorAttributes.setRecurseFilter(new VirtualFileFilter() {
                public boolean accepts(VirtualFile file) {
                    return indexIgnorePaths == null || !indexIgnorePaths.contains(file.getPathNameRelativeTo(virtualFile));
                }
            });

            final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", visitorAttributes));
            for (VirtualFile classFile : classChildren) {
                InputStream inputStream = null;
                try {
                    inputStream = classFile.openStream();
                    indexer.index(inputStream);
                } catch (Exception e) {
                    ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(classFile.getPathNameRelativeTo(virtualFile), virtualFile.getPathName(), e);
                } finally {
                    VFSUtils.safeClose(inputStream);
                }
            }
            final Index index = indexer.complete();
            resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, index);
            ServerLogger.DEPLOYMENT_LOGGER.tracef("Generated index for archive %s", virtualFile);
        } catch (Throwable t) {
            throw ServerLogger.ROOT_LOGGER.deploymentIndexingFailed(t);
        }
    }
1212371
private void indexDocument(HelpModule helpModule, Resource resource) throws Exception {
        String title = getTitle(resource);
        
        try (InputStream is = resource.getInputStream()) {
            Document document = new Document();
            document.add(new TextField("module", helpModule.getLocalizedId(), Store.YES));
            document.add(new TextField("source", helpModule.getTitle(), Store.YES));
            document.add(new TextField("title", title, Store.YES));
            document.add(new TextField("url", resource.getURL().toString(), Store.YES));
            document.add(new TextField("content", tika.parseToString(is), Store.NO));
            writer.addDocument(document);
        }
    }
575773
private void createIndex(long idleTime) {
        try {
            this.sessions.createIndex(
                    new Document(SESSION_TTL, 1),
                    new IndexOptions()
                    .expireAfter(idleTime, TimeUnit.SECONDS)
                    .name(SESSION_INDEX_NAME));
        } catch (MongoException ex) {//update idle time
            this.sessions.dropIndex(SESSION_INDEX_NAME);
            this.sessions.createIndex(
                    new Document(SESSION_TTL, 1),
                    new IndexOptions()
                    .expireAfter(idleTime, TimeUnit.SECONDS)
                    .name(SESSION_INDEX_NAME));
        }
    }
1318645
function saveAnnotations(target, context, newAnnos, callback) {
  if (!annotations || annotations.length < 1) {
    GLOBAL.error('trying to save 0 annotations');
    callback();
    return;
  }
  GLOBAL.svc.indexer.retrieveByURI(target, function(err, res) {
    if (err) {
     callback(err);
      return;
    }

    if (!res._source) {
      callback({error: 'target doesn\'t exist'});
      return;
    }
    var cItem = res._source;
    var desc = { uri: target, annotations: newAnnos, title: cItem.title, state: cItem.state };
    context.updating = true;
    indexContentItem(desc, context, function(err, res, rItem) {
      if (err) {
        console.log('saveAnnotations err'.red, err);
      }
      callback(err, res, rItem);
    });
  });
}
216728
@Override
  public final void attachNars(final File baseDir, final ArchiverManager archiverManager,
      final MavenProjectHelper projectHelper, final MavenProject project) throws MojoExecutionException {
    if (getNoArchDirectory(baseDir, project.getArtifactId(), project.getVersion()).exists()) {
      attachNar(archiverManager, projectHelper, project, NarConstants.NAR_NO_ARCH,
          getNoArchDirectory(baseDir, project.getArtifactId(), project.getVersion()), "*/**");
    }

    // list all directories in basedir, scan them for classifiers
    final String[] subDirs = baseDir.list();
    for (int i = 0; subDirs != null && i < subDirs.length; i++) {
      final String artifactIdVersion = project.getArtifactId() + "-" + project.getVersion();

      // skip entries not belonging to this project
      if (!subDirs[i].startsWith(artifactIdVersion)) {
        continue;
      }

      final String classifier = subDirs[i].substring(artifactIdVersion.length() + 1);

      // skip noarch here
      if (classifier.equals(NarConstants.NAR_NO_ARCH)) {
        continue;
      }

      final File dir = new File(baseDir, subDirs[i]);
      attachNar(archiverManager, projectHelper, project, classifier, dir, "*/**");
    }
  }
1282189
public void createMapping(String indexName, String mappingName, ArrayList<XContentBuilder> mappingSource) {
        IndicesExistsResponse existsResponse = this.client.admin().indices().prepareExists(indexName).execute()
                .actionGet();
        //If the index does not exists, it will be created without options
        if (!existsResponse.isExists()) {
            if (!createSingleIndex(indexName)) {
                throw new ElasticsearchException("Failed to create " + indexName
                        + " index.");
            }
        }
        BulkRequestBuilder bulkRequest = this.client.prepareBulk();
        for (int i = 0; i < mappingSource.size(); i++) {
            int aux = i + 1;

            IndexRequestBuilder res = this.client
                    .prepareIndex(indexName, mappingName, String.valueOf(aux)).setSource(mappingSource.get(i));
            bulkRequest.add(res);
        }
        bulkRequest.execute();
    }
1337042
public static void attachLocalCoordinateAxes(Node node, float size, AssetManager assetManager, Node rootNode) {
        
        Node n = new Node();
        n.setLocalTranslation(node.getWorldTranslation());
        rootNode.attachChild(n);
        
        Arrow arrow = new Arrow(node.getWorldRotation().mult(Vector3f.UNIT_X).normalize().mult(size));
        arrow.setLineWidth(4); // make arrow thicker
        putShape(arrow, ColorRGBA.Red, assetManager, n);

        arrow = new Arrow(node.getWorldRotation().mult(Vector3f.UNIT_Y).normalize().mult(size));
        arrow.setLineWidth(4); // make arrow thicker
        putShape(arrow, ColorRGBA.Green, assetManager, n);

        arrow = new Arrow(node.getWorldRotation().mult(Vector3f.UNIT_Z).normalize().mult(size));
        arrow.setLineWidth(4); // make arrow thicker
        putShape(arrow, ColorRGBA.Blue, assetManager, n);
    }
1042655
@Override
	public void annotateRemove(String oid) throws IndexerException {
		log.debug("Deleting " + oid + " from Anotar index");
		try {
			anotar.deleteByQuery("rootUri:\"" + oid + "\"");
			anotar.commit();
		} catch (SolrServerException sse) {
			throw new IndexerException(sse);
		} catch (IOException ioe) {
			throw new IndexerException(ioe);
		}
	}
346865
public void addResourceMetadata(String resourceName,
      ResourceMetadata resourceMetadata) {
    if (resourceMetadataMap.put(resourceName, resourceMetadata) != null) {
      throw new RuntimeException("Resource name " + resourceName +
          " already exists!");
    }
  }
950871
public void addResourceAssignment(ResourceAssignment assignment)
   {
      if (getExistingResourceAssignment(assignment.getResource()) == null)
      {
         m_assignments.add(assignment);
         getParentFile().getResourceAssignments().add(assignment);

         Resource resource = assignment.getResource();
         if (resource != null)
         {
            resource.addResourceAssignment(assignment);
         }
      }
   }
263123
private boolean createIndex(String index, Map<String, Object> defaultSettings) {
        IndicesExistsResponse res = client.admin().indices().prepareExists(index).execute().actionGet();
        boolean created = false;
        if (!res.isExists()) {
            CreateIndexRequestBuilder req = client.admin().indices().prepareCreate(index);
            req.setSettings(defaultSettings);
            created = req.execute().actionGet().isAcknowledged();
            if (!created) {
                throw new RuntimeException("Could not create index [" + index + "]");
            }
        }

        return created;
    }
421562
public void indexSourceTree(final Folder rootFolder) {

		logger.info("Starting indexing of source tree " + rootFolder.getPath());

		final SecurityContext securityContext = rootFolder.getSecurityContext();
		app = StructrApp.getInstance(securityContext);

		structrTypeSolver.parseRoot(rootFolder);

		final CombinedTypeSolver typeSolver = new CombinedTypeSolver();
		typeSolver.add(new ReflectionTypeSolver());
		typeSolver.add(structrTypeSolver);

		facade = JavaParserFacade.get(typeSolver);

		logger.info("Done with indexing of source tree " + rootFolder.getPath());
	}
101986
@Override
    public void initialize(URL location, ResourceBundle resources) {

        DelegatingOutputStreamAppender.setStaticOutputStream(new TextAreaOutputStream(console));

        FxUtils.bindVisible(projectGroup, projectState.isLocking().not());
        FxUtils.bindVisible(genScriptGroup, projectState.isLoaded());
        FxUtils.bindVisible(browsingGroup, projectState.isBrowsing());

        // FxUtils.bindVisible(maximizeButton, windowMaximized.not());
        // FxUtils.bindVisible(minimizeButton, windowMaximized);

        messageView.setTextArea(console);
        StdoutListenerContainer.getInstance().getStdoutListeners()
                .add(new TextAreaStdoutListener(console));
        StdoutListenerContainer.getInstance().getStderrListeners()
                .add(new TextAreaStdoutListener(console));

        testToolbarController.initialize(messageView, fileTreeController, projectState,
                editorTabController, editorTabController, editorTabController);
        testToolbarController.testService = testService;
        sampleToolbarController.initialize(messageView, testToolbarController, projectState);
        diffEvidenceToolbarController.initialize(messageView, fileTreeController, projectState);

        fileTreeController.setTestRunnable(testToolbarController);
        fileTreeController.fileOpenable = editorTabController;
        fileTreeController.scriptService = scriptService;

        editorTabController.setTabs(editorTab);
        editorTabController.setScriptService(scriptService);
        editorTabController.initialize();
        FxUtils.bindDisable(saveButton, editorTabController.getEmpty());
        FxUtils.bindDisable(saveAsButton, editorTabController.getEmpty());

        menuBarController.setProjectState(projectState);
        menuBarController.setAppController(this);
        menuBarController.setEditorTabController(editorTabController);
        menuBarController.setTestToolbarController(testToolbarController);
        menuBarController.setDiffEvidenceToolbarController(diffEvidenceToolbarController);
        menuBarController.setSampleToolbarController(sampleToolbarController);
        menuBarController.initialize();
    }
308133
protected void buildIndexMap(RootDoc root)  {
        PackageDoc[] packages = root.specifiedPackages();
        ClassDoc[] classes = root.classes();
        if (!classesOnly) {
            if (packages.length == 0) {
                Set<PackageDoc> set = new HashSet<PackageDoc>();
                PackageDoc pd;
                for (int i = 0; i < classes.length; i++) {
                    pd = classes[i].containingPackage();
                    if (pd != null && pd.name().length() > 0) {
                        set.add(pd);
                    }
                }
                adjustIndexMap(set.toArray(packages));
            } else {
                adjustIndexMap(packages);
            }
        }
        adjustIndexMap(classes);
        if (!classesOnly) {
            for (int i = 0; i < classes.length; i++) {
                if (shouldAddToIndexMap(classes[i])) {
                    putMembersInIndexMap(classes[i]);
                }
            }
        }
        sortIndexMap();
    }
1013019
void add(int index, IonValueLite child)
        throws ContainedValueException, NullPointerException
    {
        if ((index < 0) || (index > get_child_count()))
        {
            throw new IndexOutOfBoundsException();
        }
        checkForLock();
        validateNewChild(child);

        add_child(index, child);
        patch_elements_helper(index + 1);

        assert((index >= 0)
               && (index < get_child_count())
               && (child == get_child(index))
               && (child._elementid() == index));
    }
799323
public void addCreatedResource(Location location, Resource resource) {
        resourceList.add(resource);
        locationToResourceMap.put(location, resource);
    }
238540
@Override
    public T setResourceAdapterXML(Asset resource) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource must be specified");
        return addAsManifestResource(resource, "ra.xml");
    }