RepositoryOption repositoryOption = repo.getOptions(); Integer maxNumOfIndexes = CMSConsts.MAX_INDEXES_PER_META_CLASS; if (repositoryOption != null && repositoryOption.getMaxNumOfIndexes() != null) {
setDbo.put(Repository.REPOSITORY_FIELD_TYPE_NAME, repo.getAccessType().name()); if (repo.getOptions() != null) { setDbo.put(Repository.REPOSITORY_FIELD_OPTIONS_NAME, repositoryOptionConverter.toBson(repo.getOptions()));
RepositoryOption repoOption = repoInst.getOptions(); repoOption.setMaxDocumentSize(524288L); repoOption.setMaxIndexedArraySize(5000);
RepositoryOption repoOption = repoInst.getOptions(); repoOption.setMaxDocumentSize(524288L); repoOption.setMaxIndexedArraySize(5000);
@AfterClass public static void tear() { cleanTestData(); Repository repository = repoService.getRepository(RAPTOR_REPO); repository.getOptions().setMaxIndexedArraySize(null); repoService.updateRepository(repository); ServiceFactory.clearServiceCaches(); }
public void checkSystemLimitation(IEntity entity, IEntity foundEntity, EntityContext context, PersistenceContext persistenceContext, Operation op) { if (!Operation.DELETE.equals(op)) { if (Operation.MODIFY.equals(op)) { ModifyAction modifyAction = context.getModifyAction(); if (modifyAction != null && (ModifyAction.DELETEFIELD.equals(modifyAction) || ModifyAction.PULLFIELD .equals(modifyAction))) { return; } } Repository repo = entityHelper.getRepository(persistenceContext); RepositoryOption options = repo.getOptions(); Long maxDocumentSize = options.getMaxDocumentSize(); if (maxDocumentSize != null) { entityHelper.checkDocumentSize(op, entity, foundEntity, maxDocumentSize); } Integer maxIndexedArraySize = options.getMaxIndexedArraySize(); if (maxIndexedArraySize != null) { checkIndexedArraySize(entity, foundEntity, context, persistenceContext, op, maxIndexedArraySize); } } }
@Test(expected = CmsDalException.class) @Ignore public void testCheckDocumentSize() { Long maxDocumentSize = 10L; RepositoryOption option = new RepositoryOption(); option.setMaxDocumentSize(maxDocumentSize); Repository repo = repoService.getRepository(RAPTOR_REPO); RepositoryOption oldOption = repo.getOptions(); repo.setOptions(option); IEntityService spy = PowerMockito.spy(entityService); try { PowerMockito.doReturn(repo).when(spy, "getRepository", Mockito.any(PersistenceContext.class)); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } IEntity room = newEntity(raptorMetaService, "room-testCheckDocumentSize", "Room", IBranch.DEFAULT_BRANCH); spy.create(room, context); // reset repositoryOption repo.setOptions(oldOption); }
@Test public void testCheckSystemLimitByAddInnerToExistingHostEntity() { int maxIndexedArraySize = 3; RepositoryOption option = new RepositoryOption(); option.setMaxIndexedArraySize(maxIndexedArraySize); Repository repo = repoService.getRepository(RAPTOR_REPO); RepositoryOption oldOption = repo.getOptions(); repo.setOptions(option); IEntity room = newEntity(raptorMetaService, "room51", "Room", IBranch.DEFAULT_BRANCH); room.setId("room51"); String roomOid = entityService.create(room, context); Assert.assertEquals("room51", roomOid); IEntity door = newEntity(raptorMetaService, "door511", "Door", IBranch.DEFAULT_BRANCH); door.setId("door511"); String path = "Room!room51!path"; context.setPath(path); String doorOid = entityService.create(door, context); Assert.assertEquals("door511", doorOid); repo.setOptions(oldOption); }
@Test(expected = IllegalIndexException.class) public void testValidateForUpdateField_indexSize2() { int defaultSystemMaxIndexSize = CMSConsts.MAX_INDEXES_PER_META_CLASS; MetaClass mClass = new MetaClass(); mClass.setName("TestIndexSize"); mClass.setRepository(RAPTOR_PAAS); MetaOption metaOption = mClass.getOptions(); int maxIndexSizePerRepo = defaultSystemMaxIndexSize + 1; repo.getOptions().setMaxNumOfIndexes(maxIndexSizePerRepo); for (int i = 0; i <= maxIndexSizePerRepo; i++) { MetaAttribute attr = new MetaAttribute(); attr.setName("field" + i); IndexInfo index = new IndexInfo("index" + i); metaOption.addIndex(index); } IMetadataService metaService = repo.getMetadataService(); try { metaService.createMetaClass(mClass, new MetadataContext()); } catch (IllegalIndexException e) { throw e; } finally { repo.getOptions().setMaxNumOfIndexes(null); } }
RepositoryOption repoOption = repoInst.getOptions(); repoOption.setMaxDocumentSize(524288L); repoOption.setMaxIndexedArraySize(5000);
@Test public void testModifyInner() { int maxIndexedArraySize = 3; RepositoryOption option = new RepositoryOption(); option.setMaxIndexedArraySize(maxIndexedArraySize); Repository repo = repoService.getRepository(RAPTOR_REPO); RepositoryOption oldOption = repo.getOptions(); repo.setOptions(option); EntityContext context = newEntityContext(); IEntity door11 = buildQueryEntity(RAPTOR_REPO, IBranch.DEFAULT_BRANCH, "Door", "door11"); door11.setId("door11"); entityService.modify(door11, door11, context); repo.setOptions(oldOption); }
public Repository createRepository(CMSPriority p, Repository repo) { checkServerState(p, true); RepositoryOption repositoryOption = repo.getOptions(); if (null == repositoryOption.getMaxDocumentSize()) { repositoryOption.setMaxDocumentSize((Long) dbConfig.get(CMSDBConfig.DEFAULT_SYS_LIMIT_MAX_DOCUMENT_SIZE));
@Test public void testPushFieldToEmptyList() { int maxIndexedArraySize = 3; RepositoryOption option = new RepositoryOption(); option.setMaxIndexedArraySize(maxIndexedArraySize); Repository repo = repoService.getRepository(RAPTOR_REPO); RepositoryOption oldOption = repo.getOptions(); repo.setOptions(option); String fieldName = "preManifestRef"; EntityContext context = newEntityContext(); JsonEntity newApp = new JsonEntity(raptorMetaService.getMetaClass("ApplicationService")); newApp.setId("ApplicationService001"); newApp.setBranchId(IBranch.DEFAULT_BRANCH); entityService.create(newApp, context); newApp.addFieldValue(fieldName, "test1"); context.setModifyAction(ModifyAction.PUSHFIELD); entityService.modifyField(newApp, newApp, fieldName, context); repo.setOptions(oldOption); }