use of javax.jcr.ValueFactory in project jackrabbit by apache.
the class RepositoryImpl method initSecurityManager.
/**
* Creates the {@link org.apache.jackrabbit.core.security.JackrabbitSecurityManager SecurityManager}
* of this <code>Repository</code> and adds it to the repository context.
*
* @throws RepositoryException if an error occurs.
*/
private synchronized void initSecurityManager() throws RepositoryException {
SecurityManagerConfig smc = getConfig().getSecurityConfig().getSecurityManagerConfig();
if (smc == null) {
log.debug("No configuration entry for SecurityManager. Using org.apache.jackrabbit.core.security.simple.SimpleSecurityManager");
securityMgr = new SimpleSecurityManager();
} else {
securityMgr = smc.newInstance(JackrabbitSecurityManager.class);
}
log.info("SecurityManager = " + securityMgr.getClass());
context.setSecurityManager(securityMgr);
String workspaceName = getConfig().getDefaultWorkspaceName();
if (smc != null && smc.getWorkspaceName() != null) {
workspaceName = smc.getWorkspaceName();
}
// mark the workspace as 'active' for that it does not get disposed
// by the workspace-janitor
// TODO: There should be a cleaner way to do this
markWorkspaceActive(workspaceName);
// FIXME: Note that this call must be done *after* the security
// manager has been added to the repository context, since the
// initialisation code may invoke code that depends on the presence
// of a security manager. It would be better if this was not the case.
SystemSession systemSession = getSystemSession(workspaceName);
securityMgr.init(this, systemSession);
// initial security specific repository descriptors that are defined
// by JackrabbitRepository
ValueFactory vf = ValueFactoryImpl.getInstance();
boolean hasUserMgt;
try {
securityMgr.getUserManager(systemSession);
hasUserMgt = true;
} catch (RepositoryException e) {
hasUserMgt = false;
}
setDescriptor(JackrabbitRepository.OPTION_USER_MANAGEMENT_SUPPORTED, vf.createValue(hasUserMgt));
boolean hasPrincipalMgt;
try {
securityMgr.getPrincipalManager(systemSession);
hasPrincipalMgt = true;
} catch (RepositoryException e) {
hasPrincipalMgt = false;
}
setDescriptor(JackrabbitRepository.OPTION_PRINCIPAL_MANAGEMENT_SUPPORTED, vf.createValue(hasPrincipalMgt));
setDescriptor(JackrabbitRepository.OPTION_PRIVILEGE_MANAGEMENT_SUPPORTED, vf.createValue(true));
}
use of javax.jcr.ValueFactory in project jackrabbit by apache.
the class RepositoryImpl method initRepositoryDescriptors.
/**
* Initializes the repository descriptors by executing the following steps:
* <ul>
* <li>Sets standard descriptors</li>
* <li>{@link #getCustomRepositoryDescriptors()} is called
* afterwards in order to add custom/overwrite standard repository descriptors.</li>
* </ul>
*
* @throws RepositoryException
*/
protected void initRepositoryDescriptors() throws RepositoryException {
ValueFactory valFactory = ValueFactoryImpl.getInstance();
Value valTrue = valFactory.createValue(true);
Value valFalse = valFactory.createValue(false);
setDescriptor(Repository.REP_NAME_DESC, "Jackrabbit");
setDescriptor(Repository.REP_VENDOR_DESC, "Apache Software Foundation");
setDescriptor(Repository.REP_VENDOR_URL_DESC, "http://jackrabbit.apache.org/");
setDescriptor(Repository.SPEC_NAME_DESC, "Content Repository API for Java(TM) Technology Specification");
setDescriptor(Repository.SPEC_VERSION_DESC, "2.0");
setDescriptor(Repository.IDENTIFIER_STABILITY, Repository.IDENTIFIER_STABILITY_INDEFINITE_DURATION);
setDescriptor(Repository.LEVEL_1_SUPPORTED, valTrue);
setDescriptor(Repository.LEVEL_2_SUPPORTED, valTrue);
setDescriptor(Repository.WRITE_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_INHERITANCE, Repository.NODE_TYPE_MANAGEMENT_INHERITANCE_MULTIPLE);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED, valFalse);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED, valTrue);
Value[] types = new Value[] { valFactory.createValue(PropertyType.BINARY), valFactory.createValue(PropertyType.BOOLEAN), valFactory.createValue(PropertyType.DATE), valFactory.createValue(PropertyType.DECIMAL), valFactory.createValue(PropertyType.DOUBLE), valFactory.createValue(PropertyType.LONG), valFactory.createValue(PropertyType.NAME), valFactory.createValue(PropertyType.PATH), valFactory.createValue(PropertyType.REFERENCE), valFactory.createValue(PropertyType.STRING), valFactory.createValue(PropertyType.URI), valFactory.createValue(PropertyType.WEAKREFERENCE), valFactory.createValue(PropertyType.UNDEFINED) };
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_PROPERTY_TYPES, types);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED, valTrue);
setDescriptor(Repository.NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED, valFalse);
setDescriptor(Repository.OPTION_ACCESS_CONTROL_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_JOURNALED_OBSERVATION_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_LIFECYCLE_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_LOCKING_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_QUERY_SQL_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_RETENTION_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_SHAREABLE_NODES_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_SIMPLE_VERSIONING_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_TRANSACTIONS_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_UNFILED_CONTENT_SUPPORTED, valFalse);
setDescriptor(Repository.OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_VERSIONING_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_XML_EXPORT_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_XML_IMPORT_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_ACTIVITIES_SUPPORTED, valTrue);
setDescriptor(Repository.OPTION_BASELINES_SUPPORTED, valTrue);
setDescriptor(Repository.QUERY_FULL_TEXT_SEARCH_SUPPORTED, valTrue);
setDescriptor(Repository.QUERY_JOINS, Repository.QUERY_JOINS_INNER_OUTER);
Value[] languages = new Value[] { valFactory.createValue("javax.jcr.query.JCR-JQOM"), valFactory.createValue("javax.jcr.query.JCR-SQL2") };
setDescriptor(Repository.QUERY_LANGUAGES, languages);
setDescriptor(Repository.QUERY_STORED_QUERIES_SUPPORTED, valTrue);
setDescriptor(Repository.QUERY_XPATH_POS_INDEX, valTrue);
// Disabled since in default configuration document order is not supported.
// See https://issues.apache.org/jira/browse/JCR-1237 for details
setDescriptor(Repository.QUERY_XPATH_DOC_ORDER, valFalse);
// now set customized repository descriptor values (if any exist)
Properties props = getCustomRepositoryDescriptors();
if (props != null) {
for (Object o : props.keySet()) {
String key = (String) o;
setDescriptor(key, props.getProperty(key));
}
}
}
use of javax.jcr.ValueFactory in project jackrabbit-oak by apache.
the class NodeStateCopyUtils method copyProps.
private static void copyProps(NodeState state, Node node) throws RepositoryException {
ValueFactory vf = node.getSession().getValueFactory();
for (PropertyState ps : state.getProperties()) {
String name = ps.getName();
if (name.equals(JcrConstants.JCR_PRIMARYTYPE) || name.equals(OAK_CHILD_ORDER)) {
continue;
}
if (name.equals(JcrConstants.JCR_MIXINTYPES)) {
for (String n : ps.getValue(NAMES)) {
node.addMixin(n);
}
continue;
}
if (ps.isArray()) {
Value[] values = new Value[ps.count()];
for (int i = 0; i < ps.count(); i++) {
values[i] = createValue(vf, ps, i);
}
node.setProperty(name, values, ps.getType().tag());
} else {
node.setProperty(name, createValue(vf, ps, -1), ps.getType().tag());
}
}
}
use of javax.jcr.ValueFactory in project jackrabbit-oak by apache.
the class JsonIndexCommand method runQuery.
private void runQuery(String query, String language, String columnName, boolean quiet, int depth) throws RepositoryException {
ArrayList<String> list = new ArrayList<String>();
columnName = query.startsWith("explain") ? "plan" : columnName;
QueryManager qm = session.getWorkspace().getQueryManager();
Query q = qm.createQuery(query, language);
for (String b : q.getBindVariableNames()) {
ValueFactory vf = session.getValueFactory();
q.bindValue(b, vf.createValue(data.get("$" + b).toString()));
}
QueryResult result = q.execute();
if (depth != 0) {
NodeIterator ni = result.getNodes();
JsopBuilder builder = new JsopBuilder().array();
while (ni.hasNext()) {
Node n = ni.nextNode();
builder.key(n.getPath());
appendNode(builder, n, depth - 1);
}
output.println(JsopBuilder.prettyPrint(builder.endArray().toString()));
return;
}
RowIterator ri = result.getRows();
while (ri.hasNext()) {
Row r = ri.nextRow();
if (columnName != null) {
String x = r.getValue(columnName).getString();
list.add(x);
if (!quiet) {
output.println(x);
}
} else {
String[] columnNames = result.getColumnNames();
for (String cn : columnNames) {
Value v = r.getValue(cn);
String x = v == null ? null : v.getString();
if (columnNames.length == 1) {
list.add(x);
if (!quiet) {
output.println(x);
}
} else {
list.add(x);
if (!quiet) {
output.println(cn + ": " + x);
}
}
}
}
}
data.put("$resultSize", (long) list.size());
data.put("$result", list.toArray(new String[0]));
}
use of javax.jcr.ValueFactory in project jackrabbit by apache.
the class ParserTest method setUp.
protected void setUp() throws Exception {
super.setUp();
NamePathResolver resolver = new DefaultNamePathResolver(new DummyNamespaceResolver());
QueryObjectModelFactoryImpl factory = new QOMF(resolver);
ValueFactory vf = new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), resolver);
parser = new Parser(factory, vf);
}
Aggregations