/*
(non-Javadoc)

@see org.eclipse.aether.util.listener.AbstractRepositoryListener#artifactInstalled
(org.eclipse.aether.RepositoryEvent)
550898
@Override
    public void artifactInstalled(RepositoryEvent event) {
        log.fine("Installed " + event.getArtifact() + " to " + event.getFile());
    }
577875
public static boolean packageInstalled(@NotNull final Context context, @NotNull final String packageName) {
        final PackageManager packageManager = context.getPackageManager();
        boolean result = false;
        try {
            packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
            result = true;
        } catch (PackageManager.NameNotFoundException ignore) {
        }
        Logger.d("packageInstalled() is ", result, " for ", packageName);
        return result;
    }
370815
public ArtifactResult resolveArtifact(final RepositorySystemSession session, final ArtifactRequest request)
            throws ArtifactResolutionException {
        return system.resolveArtifact(session, request);
    }
1340370
@Override
    protected void configureService(Environment environment, ApplicationContext context) {
        super.configureService(environment, context);
        environment.jersey().register(new ArtifactIdVersionResource(getArtifactId()));
    }
1347425
public final void addArtifact(@NotNull final Artifact artifact) {
        Contract.requireArgNotNull("artifact", artifact);
        if (artifacts == null) {
            artifacts = new ArrayList<>();
        }
        artifacts.add(artifact);
    }
1190690
@Override
  public PackageDescriptor add(String pm, String groupId, String artifactId, String version) {
    PackageCoordinate pkg = PackageCoordinate.newBuilder()
        .withFormat(pm)
        .withNamespace(groupId)
        .withName(artifactId)
        .withVersion(version)
        .build();
    return add(Collections.singletonList(pkg));
  }
138184
public static boolean ensureMavenDependencyAdded(Project project, DependencyInstaller dependencyInstaller, String groupId, String artifactId, String scope) {
        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
        for (Dependency d : dependencies) {
            if (groupId.equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) {
                getLOG().debug("Project already includes:  " + groupId + ":" + artifactId + " for version: " + d.getCoordinate().getVersion());
                return false;
            }
        }

        DependencyBuilder component = DependencyBuilder.create().
                setGroupId(groupId).
                setArtifactId(artifactId);

        if (scope != null) {
            component.setScopeType(scope);
        }

        String version = MavenHelpers.getVersion(groupId, artifactId);
        if (Strings.isNotBlank(version)) {
            component = component.setVersion(version);
            getLOG().debug("Adding pom.xml dependency:  " + groupId + ":" + artifactId + " version: " + version + " scope: " + scope);
        } else {
            getLOG().debug("No version could be found for:  " + groupId + ":" + artifactId);
        }
        dependencyInstaller.install(project, component);
        return true;
    }
511127
private void resolveDependenciesInParallel(List<DependencyNode> nodes) {
        List<ArtifactRequest> artifactRequests = nodes.stream()
                .map(node -> new ArtifactRequest(node.getArtifact(), this.remoteRepositories, null))
                .collect(Collectors.toList());

        try {
            this.resolver.resolveArtifacts(this.session, artifactRequests);
        } catch (ArtifactResolutionException e) {
            // ignore, error will be printed by resolve(ArtifactSpec)
        }
    }
350982
private synchronized void addResolved( Artifact artifact )
    {
        String path =
            artifact.getGroupId().replace( '.', '/' ) + '/' + artifact.getArtifactId() + "/" + artifact.getVersion();
        Map<String, Artifact> artifactMapper = this.children.get( path );
        if ( artifactMapper == null )
        {
            artifactMapper = new HashMap<String, Artifact>();
            this.children.put( path, artifactMapper );
        }
        artifactMapper.put( artifact.getName(), artifact );
        addResolved( path );
    }
532731
@PostConstruct
    public void buildListener() throws RepositoryException {
        LOGGER.debug("Constructing an observer for JCR events...");
        session = getJcrSession(repository.login());
        session.getWorkspace().getObservationManager()
                .addEventListener(this, EVENT_TYPES, "/", true, null, null, false);
        session.save();
    }
375109
@Override
    public void bundleChanged(BundleEvent event) {
        switch (event.getType()) {
            case BundleEvent.INSTALLED:
                processBundle(event.getBundle());
                break;
            case BundleEvent.UNINSTALLED:
                // TODO: remove entries?  how do i know if this bundle's entries have been overridden by another bundle?
                break;
        }
    }
487669
@Override
    protected Artifact createArtifact(final ArtifactItem item) throws MojoExecutionException {
        assert item != null;
        
        if (item.getVersion() == null) {
            throw new MojoExecutionException("Unable to find artifact without version specified: " + item.getGroupId()
                + ":" + item.getArtifactId() + ":" + item.getVersion() + " in either project dependencies or in project dependencyManagement.");
        }
        
        // if version is a range get the highest available version
        if (item.getVersion().trim().startsWith("[") || item.getVersion().trim().startsWith("(") ) {
            try {
                item.setVersion(resolveVersionRange(item.getGroupId(), item.getArtifactId(), item.getType(), item.getVersion()));
            } catch (VersionRangeResolutionException e) {
                throw new MojoExecutionException("Could not get the highest version from the range: " + item.getVersion(), e);
            }
        }
        
        return resolveArtifactItem(item);
    }
285083
static boolean isPackageInstalled(Context context) {
        boolean isInstalled = false;
        if (context != null) {
            try {
                final PackageManager packageManager = context.getPackageManager();
                Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
                if (intent == null) {
                    return false;
                }
                List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

                isInstalled = (list != null && list.size() > 0);
            } catch (Exception e) {
                PrefHelper.LogException("Error obtaining PackageInfo", e);
            }
        }

        return isInstalled;
    }
472595
@Override
    public void touch(final boolean includeMembershipResource, final Calendar createdDate, final String createdUser,
                      final Calendar modifiedDate, final String modifyingUser) throws RepositoryException {
        super.touch(includeMembershipResource, createdDate, createdUser, modifiedDate, modifyingUser);
        if (createdDate != null || createdUser != null || modifiedDate != null || modifyingUser != null) {
            ((FedoraBinaryImpl) getDescribedResource()).touch(false, createdDate, createdUser,
                    modifiedDate, modifyingUser);
        }
    }
873983
public void notifyAddOnUninstalled(final AddOn addOn) {
		if (EventQueue.isDispatchThread()) {
			installedAddOnsModel.removeAddOn(addOn);
			if (latestInfo != null) {
				AddOn availableAddOn = latestInfo.getAddOn(addOn.getId());
				if (availableAddOn != null) {
					uninstalledAddOnsModel.addAddOn(latestInfo.getAddOn(addOn.getId()));
				}
			}
		} else {
			EventQueue.invokeLater(new Runnable() {

				@Override
				public void run() {
					notifyAddOnUninstalled(addOn);
				}
			});
		}
	}
948111
public void addArtifact(final Artifact artifact) {
        if (!artifacts.contains(artifact)) {
            if (promoted) {
                artifact.setPromoted(promoted);
            }

            artifacts.add(artifact);
        }
    }
467026
protected static final org.eclipse.aether.artifact.Artifact createArtifact(Artifact artifact) {
		return new DefaultArtifact(
				artifact.getGroupId(),
				artifact.getArtifactId(),
				artifact.getClassifier(),
				artifact.getType(),
				artifact.getVersion());
	}