public ModuleIdentityRepository(ModuleLoader moduleLoader) { if (moduleLoader == null) throw MESSAGES.illegalArgumentNull("moduleLoader"); this.moduleLoader = moduleLoader; }
URLResource(URL contentURL) { if (contentURL == null) throw MESSAGES.illegalArgumentNull("contentURL"); this.contentURL = contentURL; }
public MemoryRepositoryStorage(XRepository repository) { if (repository == null) throw MESSAGES.illegalArgumentNull("repository"); this.repository = repository; }
private AttributeValue(Type type, Object value) { if (type == null) throw MESSAGES.illegalArgumentNull("type"); if (value == null) throw MESSAGES.illegalArgumentNull("value"); this.type = type; this.value = value; Class<? extends Object> valueClass = value.getClass(); this.listType = List.class.isAssignableFrom(valueClass); }
@Override public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> reqs) { if (reqs == null) throw MESSAGES.illegalArgumentNull("reqs"); Map<Requirement, Collection<Capability>> result = new HashMap<Requirement, Collection<Capability>>(); for (Requirement req : reqs) { Collection<Capability> providers = findProviders(req); result.put(req, providers); } return result; }
public AbstractPersistentRepository(RepositoryStorageFactory factory) { if (factory == null) throw MESSAGES.illegalArgumentNull("factory"); this.storage = factory.create(this); }
@Override public synchronized XResource getResource(XIdentityCapability icap) { if (icap == null) throw MESSAGES.illegalArgumentNull("icap"); Collection<XIdentityCapability> result = new ArrayList<XIdentityCapability>(); synchronized (capabilityCache) { Set<XCapability> icaps = getCachedCapabilities(icap.getNamespace(), icap.getName()); for (XCapability aux : icaps) { XIdentityCapability iaux = aux.adapt(XIdentityCapability.class); if (icap.getAttributes().equals(iaux.getAttributes())) { result.add(iaux); } } } return result.size() == 1 ? result.iterator().next().getResource() : null; }
public FileBasedRepositoryStorage(XRepository repository, File storageDir, ConfigurationPropertyProvider propProvider) { super(repository); if (storageDir == null) throw MESSAGES.illegalArgumentNull("storageDir"); if (propProvider == null) throw MESSAGES.illegalArgumentNull("propProvider"); this.storageDir = storageDir; String filename = propProvider.getProperty(XRepository.PROPERTY_REPOSITORY_STORAGE_FILE, REPOSITORY_XML_NAME); repoFile = new File(storageDir.getAbsolutePath() + File.separator + filename).getAbsoluteFile(); // Initialize repository content if (repoFile.exists()) { RepositoryReader reader; try { reader = RepositoryXMLReader.create(new FileInputStream(repoFile)); } catch (IOException ex) { throw MESSAGES.cannotInitializeRepositoryReader(ex); } String incatt = reader.getRepositoryAttributes().get(Attribute.INCREMENT.getLocalName()); Long increment = new Long(incatt != null ? incatt : "0"); XResource res = reader.nextResource(); while(res != null) { addResourceInternal(res, false); res = reader.nextResource(); } long delta = increment - getResourceIndex().get(); getResourceIndex().addAndGet(delta); reader.close(); } }
@Override public synchronized boolean removeResource(XResource res) throws RepositoryStorageException { if (res == null) throw MESSAGES.illegalArgumentNull("resource"); boolean found = false; synchronized (capabilityCache) { for (Capability cap : res.getCapabilities(null)) { XCapability xcap = (XCapability) cap; String namespace = cap.getNamespace(); String nsvalue = (String) xcap.getAttribute(namespace); Iterator<XCapability> capit = getCachedCapabilities(namespace, nsvalue).iterator(); while (capit.hasNext()) { Resource auxres = capit.next().getResource(); if (res == auxres) { capit.remove(); found = true; } } } LOGGER.debugf("Resource removed: %s", res); } return found; }
@Override public Collection<Capability> findProviders(Requirement req) { if (req == null) throw MESSAGES.illegalArgumentNull("req"); // Try to find the providers in the storage List<Capability> providers = new ArrayList<Capability>(); providers.addAll(storage.findProviders(req)); // Try to find the providers in the delegates if (providers.isEmpty()) { for (XRepository delegate : delegates) { Collection<Capability> caps = delegate.findProviders(req); if (!caps.isEmpty()) { // Add the delegate resources to the storage for (Capability cap : caps) { XResource res = (XResource) cap.getResource(); XIdentityCapability icap = res.getIdentityCapability(); XResource storageResource = storage.getResource(icap); if (storageResource == null) { storageResource = storage.addResource(res); } providers.add(storageResource.getIdentityCapability()); } break; } } } return Collections.unmodifiableList(providers); }
private synchronized XResource addResourceInternal(XResource res, boolean writeXML) throws RepositoryStorageException { if (res == null) throw MESSAGES.illegalArgumentNull("resource"); XIdentityCapability icap = res.getIdentityCapability(); if (XResource.MAVEN_IDENTITY_NAMESPACE.equals(icap.getNamespace())) throw MESSAGES.cannotAddMavenResourceToStorage(null, res); String moduleId = (String) icap.getAttribute(XResource.MODULE_IDENTITY_NAMESPACE); if (res.isAbstract() || moduleId != null) { return addAbstractResource(res, writeXML); } else { return addContentResource(res, writeXML); } }
private Collection<Resource> findProvidersImpl(RequirementExpression re) { if (re == null) throw MESSAGES.illegalArgumentNull("re"); if (re instanceof IdentityExpression) { return findIdentityExpression((IdentityExpression) re); } else if (re instanceof AndExpression) { return findAndExpression((AndExpression) re); } else if (re instanceof OrExpression) { return findOrExpression((OrExpression) re); } else if (re instanceof NotExpression) { return findNotExpression((NotExpression) re); } throw MESSAGES.malformedRequirementExpression(re); }
@Override public synchronized XResource addResource(XResource res) throws RepositoryStorageException { if (res == null) throw MESSAGES.illegalArgumentNull("resource");