Project

General

Profile

MUC-specific UserRepository?

Justin Posey
Added about 5 years ago

Is it possible to configure MUC to use a different UserRepository than that of core Tigase? Thanks!


Replies (9)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 5 years ago

Yes, it is possible. Somebody from our team will provide you with example settings later tomorrow.

Added by Wojciech Kapcia TigaseTeam about 5 years ago

I assume that by different UserRepository you mean different URI of the repository?

You can configure both where MUC stores rooms and their configuration as well as where the history is stored with following properties accordingly:

muc/muc-repo-class[S]=<same_types_as_UserRepository>
muc/muc-repo-url[S]=jdbc:URI
muc/history-db[S]=<same_types_as_UserRepository>
muc/history-db-uri[S]=jdbc:URI
(1)

Added by Justin Posey about 5 years ago

Thanks, Wojciech. In our case, we have an entirely different implementation of the UserRepository that interacts with a different type of data store. It sounds like we just want to do this:

muc/muc-repo-class[S]=com.example.MucUserRepository

I'll give that a try now.

(1)

Added by Justin Posey about 5 years ago

Hi Wojciech, after making that change, the custom MUC repository does not get loaded on startup.

--user-db=tigase.db.DummyRepository
muc/muc-repo-class[S]=com.example.MucUserRepository

Any ideas?

(1)

Added by Wojciech Kapcia TigaseTeam about 5 years ago

Are there any exceptions in the logs? Could you share logs with debug for muc and database enabled (i.e. @--debug=muc,db@)?

Added by HaXkil The about 5 years ago

Hi Wojciech. It seems to me, that there are two potential places, where MUC component can wire repository using "muc-repo-class" property.

One is getDefaults in MUCComponent class :

public Map<String, Object> getDefaults(Map<String, Object> params) {
...
        //By default use the same repository as all other components:
        String repo_class = (params.get(GEN_USER_DB) != null) ? (String) params.get(GEN_USER_DB) : DERBY_REPO_CLASS_PROP_VAL;
        String repo_uri = (params.get(GEN_USER_DB_URI) != null) ? (String) params.get(GEN_USER_DB_URI)
                : DERBY_REPO_URL_PROP_VAL;

        props.put(MUC_REPO_CLASS_PROP_KEY, repo_class);
        props.put(MUC_REPO_URL_PROP_KEY, repo_uri);
...
}

So on this step global data repository defined by "GEN_USER_DB" is inserted to props collection.

Another place is setProperties(..) method. (I've put my comments inline)

public void setProperties(Map<String, Object> props) {
    ...

        if (userRepository == null) {  // This condition is true. 
            userRepository = (UserRepository) props.get(SHARED_USER_REPO_PROP_KEY);      // in my case props always contains shared-user-repo=tigase.db.UserRepositoryMDImpl which is global repository equals to value configured in "user-db" property
                                                                                     // init.properties does not have "shared-user-repo" property 

            try {
                if (userRepository == null) {  // this is always false

                    String cls_name = (String) props.get(MUC_REPO_CLASS_PROP_KEY);
                    String res_uri = (String) props.get(MUC_REPO_URL_PROP_KEY);

                    this.userRepository = RepositoryFactory.getUserRepository(cls_name, res_uri, null);
                    userRepository.initRepository(res_uri, null);
                }

                dao = new MucDAO(this.componentConfig, this.userRepository);
                mucRepository = createMucRepository(this.componentConfig, dao);
            } 
            ...
        }
        ...
}

So finally MUC component ends up with userRepository=tigase.db.UserRepositoryMDImpl, whose def property points to global repository instead pointing to repository, defined by "muc-repo-class" property.

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 5 years ago

Hi,

setProperties(...) method is what matters. Indeed, from the code it looks like there is a mistake in the MUC component code. A correct code should first try to get repository using MUC_REPO_CLASS_PROP_KEY and MUC_REPO_URL_PROP_KEY properties. If the MUC specific repository is not available then it should try to get the shared, global repo. We will fix the code, in the meantime I suggest you could modify code you use until a fixed version is available in our repo.

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 5 years ago

Created a bug report for this: #1718

(1)

Added by Justin Posey about 5 years ago

Thanks, Artur. May we get an ETA on resolving that bug?

    (1-9/9)