use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.
the class DocumentBundlingTest method setUpBundlor.
@Before
public void setUpBundlor() throws CommitFailedException {
store = builderProvider.newBuilder().setDocumentStore(ds).setAsyncDelay(0).memoryCacheSize(0).getNodeStore();
NodeState registryState = BundledTypesRegistry.builder().forType("app:Asset").include("jcr:content").include("jcr:content/metadata").include("jcr:content/renditions").include("jcr:content/renditions/**").build();
NodeBuilder builder = store.getRoot().builder();
new InitialContent().initialize(builder);
BundlingConfigInitializer.INSTANCE.initialize(builder);
builder.getChildNode("jcr:system").getChildNode(DOCUMENT_NODE_STORE).getChildNode(BUNDLOR).setChildNode("app:Asset", registryState.getChildNode("app:Asset"));
merge(builder);
store.runBackgroundOperations();
journalDisabledProp = System.getProperty(SYS_PROP_DISABLE_JOURNAL);
}
use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.
the class UserInitializerTest method testAdminConfiguration.
/**
* @since OAK 1.0 The configuration defines if the password of the
* admin user is being set.
*/
@Test
public void testAdminConfiguration() throws Exception {
Map<String, Object> userParams = new HashMap();
userParams.put(UserConstants.PARAM_ADMIN_ID, "admin");
userParams.put(UserConstants.PARAM_OMIT_ADMIN_PW, true);
ConfigurationParameters params = ConfigurationParameters.of(UserConfiguration.NAME, ConfigurationParameters.of(userParams));
SecurityProvider sp = SecurityProviderBuilder.newBuilder().with(params).build();
final ContentRepository repo = new Oak().with(new InitialContent()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(sp).createContentRepository();
ContentSession cs = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {
@Override
public ContentSession run() throws Exception {
return repo.login(null, null);
}
});
try {
Root root = cs.getLatestRoot();
UserConfiguration uc = sp.getConfiguration(UserConfiguration.class);
UserManager umgr = uc.getUserManager(root, NamePathMapper.DEFAULT);
Authorizable adminUser = umgr.getAuthorizable("admin");
assertNotNull(adminUser);
Tree adminTree = root.getTree(adminUser.getPath());
assertTrue(adminTree.exists());
assertNull(adminTree.getProperty(UserConstants.REP_PASSWORD));
} finally {
cs.close();
}
// login as admin should fail
ContentSession adminSession = null;
try {
adminSession = repo.login(new SimpleCredentials("admin", new char[0]), null);
fail();
} catch (LoginException e) {
// success
} finally {
if (adminSession != null) {
adminSession.close();
}
}
}
use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.
the class HybridIndexTest method createRepository.
@Override
protected ContentRepository createRepository() {
IndexCopier copier;
try {
copier = new IndexCopier(executorService, temporaryFolder.getRoot());
} catch (IOException e) {
throw new RuntimeException(e);
}
MountInfoProvider mip = defaultMountInfoProvider();
nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
nrtIndexFactory.setAssertAllResourcesClosed(true);
LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
luceneIndexProvider = new LuceneIndexProvider(tracker);
queue = new DocumentQueue(100, tracker, sameThreadExecutor());
LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
editorProvider.setIndexingQueue(queue);
LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
nodeStore = new MemoryNodeStore();
Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) luceneIndexProvider).with((Observer) luceneIndexProvider).with(localIndexObserver).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).with(optionalEditorProvider).with(new NodeCounterEditorProvider()).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
wb = oak.getWhiteboard();
return oak.createContentRepository();
}
use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.
the class LucenePropertyIndexTest method createRepository.
@Override
protected ContentRepository createRepository() {
IndexCopier copier = createIndexCopier();
editorProvider = new LuceneIndexEditorProvider(copier, new ExtractedTextCache(10 * FileUtils.ONE_MB, 100));
provider = new LuceneIndexProvider(copier);
queryIndexProvider = new ResultCountingIndexProvider(provider);
nodeStore = new MemoryNodeStore();
return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with(queryIndexProvider).with((Observer) provider).with(editorProvider).with(optionalEditorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).createContentRepository();
}
use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.
the class InitializerTest method testInitializerSegment.
@Test
public void testInitializerSegment() throws CommitFailedException, IOException {
NodeStore store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
NodeBuilder builder = store.getRoot().builder();
new InitialContent().initialize(builder);
SecurityProvider provider = SecurityProviderBuilder.newBuilder().with(ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME, ConfigurationParameters.of(ImmutableMap.of("anonymousId", "anonymous", "adminId", "admin", "usersPath", "/home/users", "groupsPath", "/home/groups", "defaultDepth", "1"))))).build();
WorkspaceInitializer workspaceInitializer = provider.getConfiguration(UserConfiguration.class).getWorkspaceInitializer();
if (workspaceInitializer instanceof QueryIndexProviderAware) {
((QueryIndexProviderAware) workspaceInitializer).setQueryIndexProvider(new CompositeQueryIndexProvider(new PropertyIndexProvider(), new NodeTypeIndexProvider()));
}
workspaceInitializer.initialize(builder, "default");
builder.getNodeState();
}
Aggregations