Search in sources :

Example 1 with LSIDAuthority

use of eu.etaxonomy.cdm.model.common.LSIDAuthority in project cdmlib by cybertaxonomy.

the class AuthorityControllerTest method setUp.

@Before
public void setUp() {
    try {
        lsid = new LSID("urn:lsid:example.org:taxonconcept:1");
    } catch (MalformedLSIDException e) {
    }
    try {
        lsidAuthority = new LSIDAuthority("fred.org");
    } catch (MalformedLSIDException e) {
    }
    authorityService = org.easymock.classextension.EasyMock.createMock(LSIDAuthorityService.class);
    authorityController = new AuthorityController();
    source = new Object();
    expiringResponse = new ExpiringResponse(source, null);
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) LSIDAuthorityService(eu.etaxonomy.cdm.api.service.lsid.LSIDAuthorityService) MalformedLSIDException(com.ibm.lsid.MalformedLSIDException) TestedObject(org.unitils.inject.annotation.TestedObject) LSIDAuthority(eu.etaxonomy.cdm.model.common.LSIDAuthority) ExpiringResponse(com.ibm.lsid.ExpiringResponse) Before(org.junit.Before)

Example 2 with LSIDAuthority

use of eu.etaxonomy.cdm.model.common.LSIDAuthority in project cdmlib by cybertaxonomy.

the class FullCoverageDataGenerator method createSupplemental.

private void createSupplemental(List<CdmBase> cdmBases) {
    Reference ref = ReferenceFactory.newBook();
    Annotation annotation = Annotation.NewDefaultLanguageInstance("annotation");
    ref.addAnnotation(annotation);
    handleAnnotatableEntity(annotation);
    Credit credit = Credit.NewInstance(Person.NewInstance(), "refCredit", "rc", Language.DEFAULT());
    ref.addCredit(credit);
    handleAnnotatableEntity(credit);
    Rights rights = Rights.NewInstance("My rights", Language.GERMAN());
    ref.addRights(rights);
    handleAnnotatableEntity(rights);
    // Others
    try {
        LSIDAuthority lsidAuthority = new LSIDAuthority("My authority");
        lsidAuthority.addNamespace("lsidNamespace", TaxonName.class);
        cdmBases.add(lsidAuthority);
    } catch (MalformedLSIDException e) {
        e.printStackTrace();
    }
    User user = User.NewInstance("myUser", "12345");
    Group group = Group.NewInstance("MyGroup");
    group.addMember(user);
    CdmAuthority authority = CdmAuthority.NewInstance(PermissionClass.TAXONNAME, "a property", Operation.CREATE, UUID.fromString("f1653cb8-5956-429e-852a-4a3b57893f49"));
    group.addAuthority(authority);
    Role role = Role.NewInstance("my role");
    user.addAuthority(role);
    cdmBases.add(user);
    cdmBases.add(group);
    cdmBases.add(authority);
    cdmBases.add(ref);
}
Also used : Role(eu.etaxonomy.cdm.model.permission.Role) Group(eu.etaxonomy.cdm.model.permission.Group) Rights(eu.etaxonomy.cdm.model.media.Rights) Credit(eu.etaxonomy.cdm.model.common.Credit) User(eu.etaxonomy.cdm.model.permission.User) MalformedLSIDException(com.ibm.lsid.MalformedLSIDException) Reference(eu.etaxonomy.cdm.model.reference.Reference) IntextReference(eu.etaxonomy.cdm.model.common.IntextReference) CdmAuthority(eu.etaxonomy.cdm.model.permission.CdmAuthority) LSIDAuthority(eu.etaxonomy.cdm.model.common.LSIDAuthority) Annotation(eu.etaxonomy.cdm.model.common.Annotation)

Example 3 with LSIDAuthority

use of eu.etaxonomy.cdm.model.common.LSIDAuthority in project cdmlib by cybertaxonomy.

the class LsidRegistryImpl method init.

@PostConstruct
public void init() {
    registry = new HashMap<>();
    TransactionStatus txStatus = transactionManager.getTransaction(txDefinition);
    for (LSIDAuthority lsidAuthority : lsidAuthorityDao.list(null, null)) {
        for (String namespace : lsidAuthority.getNamespaces().keySet()) {
            Class<? extends IIdentifiableEntity> clazz = lsidAuthority.getNamespaces().get(namespace);
            boolean foundDao = false;
            for (IIdentifiableDao identifiableDao : identifiableDaos) {
                if (clazz.equals(identifiableDao.getType())) {
                    foundDao = true;
                    registry.put(lsidAuthority.getAuthority() + ":" + namespace, identifiableDao);
                    break;
                }
            }
            if (!foundDao) {
                log.warn("Did not find DAO serving classes of type " + clazz + " for authority " + lsidAuthority.getAuthority() + " with namespace " + namespace);
            }
        }
    }
    transactionManager.commit(txStatus);
}
Also used : IIdentifiableDao(eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao) TransactionStatus(org.springframework.transaction.TransactionStatus) LSIDAuthority(eu.etaxonomy.cdm.model.common.LSIDAuthority) PostConstruct(javax.annotation.PostConstruct)

Aggregations

LSIDAuthority (eu.etaxonomy.cdm.model.common.LSIDAuthority)3 MalformedLSIDException (com.ibm.lsid.MalformedLSIDException)2 ExpiringResponse (com.ibm.lsid.ExpiringResponse)1 LSIDAuthorityService (eu.etaxonomy.cdm.api.service.lsid.LSIDAuthorityService)1 Annotation (eu.etaxonomy.cdm.model.common.Annotation)1 Credit (eu.etaxonomy.cdm.model.common.Credit)1 IntextReference (eu.etaxonomy.cdm.model.common.IntextReference)1 LSID (eu.etaxonomy.cdm.model.common.LSID)1 Rights (eu.etaxonomy.cdm.model.media.Rights)1 CdmAuthority (eu.etaxonomy.cdm.model.permission.CdmAuthority)1 Group (eu.etaxonomy.cdm.model.permission.Group)1 Role (eu.etaxonomy.cdm.model.permission.Role)1 User (eu.etaxonomy.cdm.model.permission.User)1 Reference (eu.etaxonomy.cdm.model.reference.Reference)1 IIdentifiableDao (eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao)1 PostConstruct (javax.annotation.PostConstruct)1 Before (org.junit.Before)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TestedObject (org.unitils.inject.annotation.TestedObject)1