Search in sources :

Example 1 with TransactionServiceImpl

use of org.alfresco.repo.transaction.TransactionServiceImpl in project alfresco-repository by Alfresco.

the class SysAdminParamsImpl method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    // Set the transaction read-write state by veto
    // There is no need to attempt to check the dictionary or any other component as they will handle
    // their own vetoes (MNT-14579)
    // No logging is required here: it is done in the TransactionService code, already
    TransactionServiceImpl transactionService = (TransactionServiceImpl) ctx.getBean("transactionService");
    transactionService.setAllowWrite(allowWrite, VETO);
}
Also used : TransactionServiceImpl(org.alfresco.repo.transaction.TransactionServiceImpl)

Example 2 with TransactionServiceImpl

use of org.alfresco.repo.transaction.TransactionServiceImpl in project alfresco-repository by Alfresco.

the class ThumbnailServiceImplParameterTest method initMockObjects.

@Before
public void initMockObjects() {
    renditionService = new RenditionServiceImpl() {

        @Override
        public RenditionDefinition loadRenditionDefinition(QName renditionDefinitionName) {
            // We're intentionally returning null for this test.
            return null;
        }
    };
    renditionService.setActionService(mockActionService);
    renditionService.setServiceRegistry(new MockedTestServiceRegistry());
    renditionService.setRenditionService2(mockRenditionService2);
    when(mockRenditionService2.isCreatedByRenditionService2(any(), any())).thenReturn(false);
    ThumbnailServiceImpl thumbs = new ThumbnailServiceImpl() {

        @Override
        public NodeRef getThumbnailByName(NodeRef node, QName contentProperty, String thumbnailName) {
            return null;
        }

        /**
         * In this test the thumbnailRef will be null, so we need to ensure
         * it is not dereferenced here.
         */
        @Override
        public NodeRef getThumbnailNode(ChildAssociationRef thumbnailRef) {
            return null;
        }
    };
    thumbs.setRenditionService(renditionService);
    thumbs.setThumbnailRegistry(new ThumbnailRegistry() {

        @Override
        public ThumbnailRenditionConvertor getThumbnailRenditionConvertor() {
            return new ThumbnailRenditionConvertor();
        }
    });
    thumbs.setNodeService(mock(NodeService.class));
    TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl() {

        @Override
        public boolean getAllowWrite() {
            return true;
        }

        @Override
        public boolean isReadOnly() {
            return false;
        }

        @Override
        public RetryingTransactionHelper getRetryingTransactionHelper() {
            RetryingTransactionHelper rth = new RetryingTransactionHelper() {

                @Override
                public <R> R doInTransaction(RetryingTransactionCallback<R> cb, boolean readOnly, boolean requiresNew) {
                    try {
                        return cb.execute();
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            };
            return rth;
        }
    };
    thumbs.setTransactionService(transactionServiceImpl);
    thumbnailService = thumbs;
}
Also used : RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) QName(org.alfresco.service.namespace.QName) TransactionServiceImpl(org.alfresco.repo.transaction.TransactionServiceImpl) NodeService(org.alfresco.service.cmr.repository.NodeService) RenditionServiceImpl(org.alfresco.repo.rendition.RenditionServiceImpl) MockedTestServiceRegistry(org.alfresco.repo.rendition.MockedTestServiceRegistry) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RenditionDefinition(org.alfresco.service.cmr.rendition.RenditionDefinition) Before(org.junit.Before)

Example 3 with TransactionServiceImpl

use of org.alfresco.repo.transaction.TransactionServiceImpl in project alfresco-repository by Alfresco.

the class DescriptorServiceTest method testReadOnlyLicenseLoad_ALF10110.

@Test
public void testReadOnlyLicenseLoad_ALF10110() throws Exception {
    QName vetoName = QName.createQName("{test}veto");
    TransactionServiceImpl txnService = (TransactionServiceImpl) applicationContext.getBean("TransactionService");
    ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    DescriptorService descriptorService = registry.getDescriptorService();
    // Veto writes
    try {
        txnService.setAllowWrite(false, vetoName);
        // Now reload the license
        descriptorService.loadLicense();
    } finally {
        txnService.setAllowWrite(true, vetoName);
    }
}
Also used : QName(org.alfresco.service.namespace.QName) TransactionServiceImpl(org.alfresco.repo.transaction.TransactionServiceImpl) ServiceRegistry(org.alfresco.service.ServiceRegistry) DescriptorService(org.alfresco.service.descriptor.DescriptorService) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Aggregations

TransactionServiceImpl (org.alfresco.repo.transaction.TransactionServiceImpl)3 QName (org.alfresco.service.namespace.QName)2 MockedTestServiceRegistry (org.alfresco.repo.rendition.MockedTestServiceRegistry)1 RenditionServiceImpl (org.alfresco.repo.rendition.RenditionServiceImpl)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 RenditionDefinition (org.alfresco.service.cmr.rendition.RenditionDefinition)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 NodeService (org.alfresco.service.cmr.repository.NodeService)1 DescriptorService (org.alfresco.service.descriptor.DescriptorService)1 BaseSpringTest (org.alfresco.util.BaseSpringTest)1 Before (org.junit.Before)1 Test (org.junit.Test)1