@@ -0,0 +1,2692 @@
+package com.epimorphics.registry.notification;%0A%0Aimport com.epimorphics.appbase.core.App;%0Aimport com.epimorphics.appbase.core.Startup;%0Aimport com.epimorphics.registry.core.Description;%0Aimport com.epimorphics.registry.core.Register;%0Aimport com.epimorphics.registry.core.Registry;%0Aimport com.epimorphics.registry.store.RegisterEntryInfo;%0Aimport com.epimorphics.registry.store.StoreAPI;%0Aimport com.epimorphics.registry.vocab.RegistryVocab;%0Aimport org.apache.jena.rdf.model.Resource;%0Aimport org.apache.jena.rdf.model.Statement;%0Aimport org.apache.jena.vocabulary.DCTerms;%0Aimport org.apache.jena.vocabulary.RDF;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Apublic class TopicRegister implements Startup %7B%0A    private static final String TOPIC_REGISTER = %22/system/topic%22; // relative to base URI%0A%0A    private final Logger log = LoggerFactory.getLogger(MonitorRegister.class);%0A    private Map%3CString, String%3E topicsByUri = new HashMap%3C%3E();%0A%0A    @Override public void startup(App app) %7B%0A        Registry reg = app.getA(Registry.class);%0A        initTopics(reg);%0A    %7D%0A%0A    private synchronized void initTopics(Registry reg) %7B%0A        topicsByUri.clear();%0A%0A        StoreAPI store = reg.getStore();%0A        String uri = reg.getBaseURI() + TOPIC_REGISTER;%0A%0A        store.beginSafeRead();%0A        Description desc = store.getDescription(uri);%0A        if (desc instanceof Register) %7B%0A            Register register = desc.asRegister();%0A            List%3CRegisterEntryInfo%3E members = register.getMembers();%0A            members.forEach(member -%3E addTopic(member, store));%0A        %7D else %7B%0A            log.warn(%22System register %22 + uri + %22 does not exist - unable to register topics.%22);%0A        %7D%0A%0A        store.endSafeRead();%0A    %7D%0A%0A    private void addTopic(RegisterEntryInfo entry, StoreAPI store) %7B%0A        String topicUri = entry.getItemURI();%0A        Resource root = store.getDescription(entry.getEntityURI()).getRoot();%0A        if (root.hasProperty(RDF.type, RegistryVocab.Topic)) %7B%0A            Statement topicNameStmt = root.getProperty(DCTerms.identifier);%0A            if (topicNameStmt == null) %7B%0A                log.warn(%22Unable to configure topic %22 + topicUri + %22: Resource must specify a dct:identifier value.%22);%0A            %7D else %7B%0A                String name = topicNameStmt.getLiteral().getLexicalForm();%0A                topicsByUri.put(topicUri, name);%0A            %7D%0A        %7D else %7B%0A            log.warn(%22Unable to configure topic %22 + topicUri + %22: Resource must have a rdf:type value of reg:Topic.%22);%0A        %7D%0A    %7D%0A%0A    public String getTopicName(String uri) %7B%0A        return topicsByUri.get(uri);%0A    %7D%0A%7D%0A

ADD Topic register component