use of org.apache.jackrabbit.spi.QValueFactory in project jackrabbit by apache.
the class Spi2davRepositoryServiceFactory method createRepositoryService.
public RepositoryService createRepositoryService(Map<?, ?> parameters) throws RepositoryException {
if (parameters == null) {
throw new RepositoryException("Parameter " + PARAM_REPOSITORY_URI + " missing");
}
String uri;
if (parameters.get(PARAM_REPOSITORY_URI) == null) {
throw new RepositoryException("Parameter " + PARAM_REPOSITORY_URI + " missing");
} else {
uri = parameters.get(PARAM_REPOSITORY_URI).toString();
}
IdFactory idFactory;
Object param = parameters.get(PARAM_ID_FACTORY);
if (param != null && param instanceof IdFactory) {
idFactory = (IdFactory) param;
} else {
idFactory = IdFactoryImpl.getInstance();
}
NameFactory nameFactory;
param = parameters.get(PARAM_NAME_FACTORY);
if (param != null && param instanceof NameFactory) {
nameFactory = (NameFactory) param;
} else {
nameFactory = NameFactoryImpl.getInstance();
}
PathFactory pathFactory;
param = parameters.get(PARAM_PATH_FACTORY);
if (param != null && param instanceof PathFactory) {
pathFactory = (PathFactory) param;
} else {
pathFactory = PathFactoryImpl.getInstance();
}
QValueFactory vFactory;
param = parameters.get(PARAM_QVALUE_FACTORY);
if (param != null && param instanceof QValueFactory) {
vFactory = (QValueFactory) param;
} else {
vFactory = QValueFactoryImpl.getInstance();
}
int itemInfoCacheSize = ItemInfoCacheImpl.DEFAULT_CACHE_SIZE;
param = parameters.get(PARAM_ITEMINFO_CACHE_SIZE);
if (param != null) {
try {
itemInfoCacheSize = Integer.parseInt(param.toString());
} catch (NumberFormatException e) {
// ignore, use default
}
}
// max connections config
int maximumHttpConnections = 0;
param = parameters.get(PARAM_MAX_CONNECTIONS);
if (param != null) {
try {
maximumHttpConnections = Integer.parseInt(param.toString());
} catch (NumberFormatException e) {
// using default
}
}
if (maximumHttpConnections > 0) {
return new RepositoryServiceImpl(uri, idFactory, nameFactory, pathFactory, vFactory, itemInfoCacheSize, maximumHttpConnections);
} else {
return new RepositoryServiceImpl(uri, idFactory, nameFactory, pathFactory, vFactory, itemInfoCacheSize);
}
}
use of org.apache.jackrabbit.spi.QValueFactory in project jackrabbit by apache.
the class LengthOperand method getValues.
/**
* {@inheritDoc}
*/
public Value[] getValues(ScoreNode sn, EvaluationContext context) throws RepositoryException {
PropertyState ps = property.getPropertyState(sn, context);
if (ps == null) {
return EMPTY;
} else {
ValueFactoryImpl vf = (ValueFactoryImpl) context.getSession().getValueFactory();
QValueFactory qvf = vf.getQValueFactory();
InternalValue[] values = ps.getValues();
Value[] lengths = new Value[values.length];
for (int i = 0; i < lengths.length; i++) {
long len;
int type = values[i].getType();
if (type == PropertyType.NAME) {
len = vf.createValue(qvf.create(values[i].getName())).getString().length();
} else if (type == PropertyType.PATH) {
len = vf.createValue(qvf.create(values[i].getPath())).getString().length();
} else {
len = Util.getLength(values[i]);
}
lengths[i] = vf.createValue(len);
}
return lengths;
}
}
use of org.apache.jackrabbit.spi.QValueFactory in project jackrabbit by apache.
the class AbstractJCR2SPITest method getDescriptors.
protected Map<String, QValue[]> getDescriptors() throws RepositoryException {
Map<String, QValue[]> descriptorKeys = new HashMap<String, QValue[]>();
QValueFactory qvf = QValueFactoryImpl.getInstance();
descriptorKeys.put(Repository.REP_NAME_DESC, new QValue[] { qvf.create("Mock Repository", PropertyType.STRING) });
descriptorKeys.put(Repository.REP_VENDOR_DESC, new QValue[] { qvf.create("Apache Software Foundation", PropertyType.STRING) });
descriptorKeys.put(Repository.REP_VENDOR_URL_DESC, new QValue[] { qvf.create("http://www.apache.org/", PropertyType.STRING) });
descriptorKeys.put(Repository.REP_VERSION_DESC, new QValue[] { qvf.create("2.0", PropertyType.STRING) });
descriptorKeys.put(Repository.SPEC_NAME_DESC, new QValue[] { qvf.create("Content Repository API for Java(TM) Technology Specification", PropertyType.STRING) });
descriptorKeys.put(Repository.SPEC_VERSION_DESC, new QValue[] { qvf.create("2.0", PropertyType.STRING) });
return descriptorKeys;
}
use of org.apache.jackrabbit.spi.QValueFactory in project jackrabbit by apache.
the class DavPropertyTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
repoURI = helper.getProperty(ServiceStubImpl.PROP_REPOSITORY_URI);
rs = (RepositoryServiceImpl) helper.getRepositoryService();
si = helper.getAdminSessionInfo();
NamespaceResolver nsResolver = new AbstractNamespaceResolver() {
public String getURI(String prefix) {
return ("jcr".equals(prefix)) ? "http://www.jcp.org/jcr/1.0" : prefix;
}
public String getPrefix(String uri) {
return ("http://www.jcp.org/jcr/1.0".equals(uri)) ? "jcr" : uri;
}
};
resolver = new DefaultNamePathResolver(nsResolver);
try {
rs.getNodeInfo(si, getNodeId(testPath));
} catch (RepositoryException e) {
Batch b = rs.createBatch(si, getNodeId("/"));
b.addNode(getNodeId("/"), resolver.getQName("test"), NameConstants.NT_UNSTRUCTURED, null);
QValueFactory qvf = rs.getQValueFactory();
b.addProperty(getNodeId("/test"), resolver.getQName("prop"), qvf.create("value", PropertyType.STRING));
b.addProperty(getNodeId("/test"), resolver.getQName("propMV"), new QValue[] { qvf.create(1), qvf.create(2) });
rs.submit(b);
}
}
use of org.apache.jackrabbit.spi.QValueFactory in project jackrabbit by apache.
the class RepositoryStubImpl method createService.
protected RepositoryService createService(String uri) throws RepositoryException {
IdFactory idFactory = IdFactoryImpl.getInstance();
NameFactory nFactory = NameFactoryImpl.getInstance();
PathFactory pFactory = PathFactoryImpl.getInstance();
QValueFactory vFactory = QValueFactoryImpl.getInstance();
return new RepositoryServiceImpl(uri, idFactory, nFactory, pFactory, vFactory);
}
Aggregations