use of org.alfresco.repo.dictionary.DictionaryDAO in project alfresco-remote-api by Alfresco.
the class AbstractEnterpriseOpenCMISTCKTest method overrideVersionableAspectProperties.
protected void overrideVersionableAspectProperties(ApplicationContext ctx) {
final DictionaryDAO dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
dictionaryDAO.removeModel(QName.createQName("cm:contentmodel"));
M2Model contentModel = M2Model.createModel(getClass().getClassLoader().getResourceAsStream("alfresco/model/contentModel.xml"));
M2Aspect versionableAspect = contentModel.getAspect("cm:versionable");
M2Property prop = versionableAspect.getProperty("cm:initialVersion");
prop.setDefaultValue(Boolean.FALSE.toString());
prop = versionableAspect.getProperty("cm:autoVersion");
prop.setDefaultValue(Boolean.FALSE.toString());
prop = versionableAspect.getProperty("cm:autoVersionOnUpdateProps");
prop.setDefaultValue(Boolean.FALSE.toString());
dictionaryDAO.putModel(contentModel);
}
use of org.alfresco.repo.dictionary.DictionaryDAO in project alfresco-repository by Alfresco.
the class SiteServiceImplTest method testCustomSiteType.
/**
* Creates a site with a custom type, and ensures that
* it behaves correctly.
*/
@SuppressWarnings("deprecation")
@Test
public void testCustomSiteType() {
final String CS_URI = "http://example.com/site";
final String CS_PFX = "cs";
// Setup our custom site type
DictionaryDAO dictionaryDAO = (DictionaryDAO) this.applicationContext.getBean("dictionaryDAO");
M2Model model = M2Model.createModel("cm:CustomSiteModel");
model.createNamespace(CS_URI, CS_PFX);
// Import the usual suspects too
model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, NamespaceService.DICTIONARY_MODEL_PREFIX);
model.createImport(SiteModel.SITE_MODEL_URL, SiteModel.SITE_MODEL_PREFIX);
// Custom type
M2Type customType = model.createType("cs:customSite");
customType.setTitle("customSite");
customType.setParentName(SiteModel.SITE_MODEL_PREFIX + ":" + SiteModel.TYPE_SITE.getLocalName());
M2Property customProp = customType.createProperty("cs:customSiteProp");
customProp.setTitle("customSiteProp");
customProp.setType("d:text");
dictionaryDAO.putModel(model);
// Get our custom type, to check it's in there properly
final QName customTypeQ = QName.createQName("cs", "customSite", namespaceService);
TypeDefinition td = dictionaryService.getType(customTypeQ);
assertNotNull(td);
// Create a site
SiteInfo site = siteService.createSite("custom", "custom", "Custom", "Custom", SiteVisibility.PUBLIC);
// Check the roles on it
List<String> roles = siteService.getSiteRoles();
assertEquals(7, roles.size());
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONSUMER));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONTRIBUTOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_COLLABORATOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
roles = siteService.getSiteRoles(site.getShortName());
assertEquals(7, roles.size());
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONSUMER));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONTRIBUTOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_COLLABORATOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
// Swap the type
nodeService.setType(site.getNodeRef(), customTypeQ);
// Check again
roles = siteService.getSiteRoles();
assertEquals(7, roles.size());
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONSUMER));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONTRIBUTOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_COLLABORATOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
roles = siteService.getSiteRoles(site.getShortName());
assertEquals(7, roles.size());
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONSUMER));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONTRIBUTOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_COLLABORATOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
// Alter the permissions for the custom site
PermissionService testPermissionService = spy((PermissionService) this.applicationContext.getBean("permissionServiceImpl"));
Set<String> customPerms = new HashSet<String>();
customPerms.add(SiteServiceImpl.SITE_MANAGER);
customPerms.add("CUSTOM");
when(testPermissionService.getSettablePermissions(customTypeQ)).thenReturn(customPerms);
// Check it changed for the custom site, but not normal
SiteServiceImpl siteServiceImpl = (SiteServiceImpl) this.applicationContext.getBean("siteService");
siteServiceImpl.setPermissionService(testPermissionService);
roles = siteService.getSiteRoles();
assertEquals(7, roles.size());
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONSUMER));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONTRIBUTOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_COLLABORATOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
roles = siteService.getSiteRoles(site.getShortName());
assertEquals(2, roles.size());
assertEquals(true, roles.contains("CUSTOM"));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
// Put the permissions back
siteServiceImpl.setPermissionService(permissionService);
roles = siteService.getSiteRoles();
assertEquals(7, roles.size());
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONSUMER));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONTRIBUTOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_COLLABORATOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
roles = siteService.getSiteRoles(site.getShortName());
assertEquals(7, roles.size());
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONSUMER));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_CONTRIBUTOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_COLLABORATOR));
assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER));
}
use of org.alfresco.repo.dictionary.DictionaryDAO in project alfresco-repository by Alfresco.
the class RhinoScriptTest method setUp.
/*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
ctx = ApplicationContextHelper.getApplicationContext();
transactionService = (TransactionService) ctx.getBean("transactionComponent");
contentService = (ContentService) ctx.getBean("contentService");
nodeService = (NodeService) ctx.getBean("nodeService");
scriptService = (ScriptService) ctx.getBean("scriptService");
serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
BaseNodeServiceTest.loadModel(ctx);
}
use of org.alfresco.repo.dictionary.DictionaryDAO in project alfresco-repository by Alfresco.
the class ConcurrentNodeServiceSearchTest method setUp.
protected void setUp() throws Exception {
ctx = ApplicationContextHelper.getApplicationContext();
DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/systemModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
nodeService = (NodeService) ctx.getBean("dbNodeService");
transactionService = (TransactionService) ctx.getBean("transactionComponent");
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
// create a first store directly
UserTransaction tx = transactionService.getUserTransaction();
tx.begin();
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
rootNodeRef = nodeService.getRootNode(storeRef);
tx.commit();
}
use of org.alfresco.repo.dictionary.DictionaryDAO in project alfresco-repository by Alfresco.
the class IntegrityTest method setUp.
public void setUp() throws Exception {
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
// load the test model
InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/integrity/IntegrityTest_model.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
integrityChecker.setEnabled(true);
integrityChecker.setFailOnViolation(true);
integrityChecker.setTraceOn(true);
// we want to count the correct number of errors
integrityChecker.setMaxErrorsPerTransaction(100);
MetadataEncryptor encryptor = (MetadataEncryptor) ctx.getBean("metadataEncryptor");
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
nodeService = serviceRegistry.getNodeService();
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
// begin a transaction
TransactionService transactionService = serviceRegistry.getTransactionService();
txn = transactionService.getUserTransaction();
txn.begin();
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
if (!nodeService.exists(storeRef)) {
nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
}
rootNodeRef = nodeService.getRootNode(storeRef);
allProperties = new PropertyMap();
allProperties.put(TEST_PROP_TEXT_A, "ABC");
allProperties.put(TEST_PROP_TEXT_B, "DEF");
allProperties.put(TEST_PROP_INT_A, "123");
allProperties.put(TEST_PROP_INT_B, "456");
allProperties.put(TEST_PROP_ENCRYPTED_A, "ABC");
allProperties.put(TEST_PROP_ENCRYPTED_B, "DEF");
allProperties = encryptor.encrypt(allProperties);
}
Aggregations