By the way, the method name getAllRepositoryNames() suggests it returns names 
of repositories, when in fact in returns the names of the *workspaces*. I 
believe there are more areas in Magnolia where repository and workspace are 
mixed up. Is this something that is already planned to be addressed or should I 
file a JIRA issue for this?

Nils.
________________________________________
Van: Nils Breunese
Verzonden: donderdag 24 februari 2011 11:07
Aan: Magnolia User-List
Onderwerp: Re: [magnolia-user]  RE: Get list of all workspaces

Ronald Ten Berge wrote:

> Maybe the following code (that is being used in ACLSDialogControl) will work:
> SecurityConfiguration securityConf = 
> AdminInterfaceModule.getInstance().getSecurityConfiguration();
> securityConf.getVisibleRepositories();

Thanks, that led me to ContentRepository.getAllRepositoryNames(), which does 
exactly what I was looking for. It allowed me to write this bit of Groovy code 
to look for a UUID in all workspaces, which can come in handy from time to time 
(mainly when error messages throw you a UUID and you'd like to know in which 
workspace it is and what its path is, etc.):

----
import info.magnolia.cms.beans.config.ContentRepository
import info.magnolia.cms.core.Content
import info.magnolia.cms.util.ContentUtil
import info.magnolia.cms.util.DumperUtil

def find(uuid) {
    for (workspace in ContentRepository.getAllRepositoryNames()) {
        Content content = ContentUtil.getContentByUUID(workspace, uuid)
        if (content) {
            return "Found UUID '${uuid}' in workspace '${workspace}': 
${DumperUtil.dump(content)}"
        }
    }
    return "No content found for UUID '${uuid}'"
}

find 'a9ceabd4-a3a1-4234-9354-0c328407ca77'
----

Nils.

------------------------------------------------------------------------
 VPRO   www.vpro.nl
------------------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to