use of org.apache.jackrabbit.core.query.QueryManagerImpl in project jackrabbit by apache.
the class WorkspaceImpl method getQueryManager.
/**
* {@inheritDoc}
*/
public synchronized QueryManager getQueryManager() throws RepositoryException {
// check state of this instance
sanityCheck();
if (queryManager == null) {
SearchManager searchManager;
try {
searchManager = context.getRepository().getSearchManager(wspConfig.getName());
if (searchManager == null) {
String msg = "no search manager configured for this workspace";
log.debug(msg);
throw new RepositoryException(msg);
}
} catch (NoSuchWorkspaceException nswe) {
// should never get here
String msg = "internal error: failed to instantiate query manager";
log.debug(msg);
throw new RepositoryException(msg, nswe);
}
queryManager = new QueryManagerImpl(context, searchManager);
}
return queryManager;
}
use of org.apache.jackrabbit.core.query.QueryManagerImpl in project jackrabbit by apache.
the class NodeImpl method getWeakReferences.
/**
* {@inheritDoc}
*/
public PropertyIterator getWeakReferences() throws RepositoryException {
// check state of this instance
sanityCheck();
// shortcut if node isn't referenceable
if (!isNodeType(NameConstants.MIX_REFERENCEABLE)) {
return PropertyIteratorAdapter.EMPTY;
}
Value ref = getSession().getValueFactory().createValue(this, true);
List<Property> props = new ArrayList<Property>();
QueryManagerImpl qm = (QueryManagerImpl) getSession().getWorkspace().getQueryManager();
for (Node n : qm.getWeaklyReferringNodes(this)) {
for (PropertyIterator it = n.getProperties(); it.hasNext(); ) {
Property p = it.nextProperty();
if (p.getType() == PropertyType.WEAKREFERENCE) {
Collection<Value> refs;
if (p.isMultiple()) {
refs = Arrays.asList(p.getValues());
} else {
refs = Collections.singleton(p.getValue());
}
if (refs.contains(ref)) {
props.add(p);
}
}
}
}
return new PropertyIteratorAdapter(props);
}
Aggregations