sascha@165: /* sascha@165: * Copyright (c) 2011 by Intevation GmbH sascha@165: * sascha@165: * This program is free software under the LGPL (>=v2.1) sascha@165: * Read the file LGPL.txt coming with the software for details sascha@165: * or visit http://www.gnu.org/licenses/ if it does not exist. sascha@165: */ sascha@165: package de.intevation.artifactdatabase; sascha@165: sascha@165: import de.intevation.artifacts.User; sascha@165: import de.intevation.artifacts.UserFactory; sascha@165: sascha@165: import org.w3c.dom.Document; sascha@165: sascha@165: public class LazyBackendUser sascha@165: implements User sascha@165: { sascha@165: protected UserFactory factory; sascha@165: protected Backend backend; sascha@165: protected String identifier; sascha@165: protected User user; sascha@165: protected Object context; sascha@165: sascha@165: public LazyBackendUser( sascha@165: String identifier, sascha@233: UserFactory factory, sascha@165: Backend backend, sascha@165: Object context sascha@165: ) { sascha@165: this.identifier = identifier; sascha@165: this.factory = factory; sascha@165: this.backend = backend; sascha@165: this.context = context; sascha@165: } sascha@165: sascha@165: protected User getUser() { sascha@165: if (user == null) { sascha@165: user = backend.getUser(identifier, factory, context); sascha@165: if (user == null) { sascha@165: throw new IllegalStateException("loading user failed"); sascha@165: } sascha@165: } sascha@165: return user; sascha@165: } sascha@165: sascha@165: public String identifier() { sascha@165: return getUser().identifier(); sascha@165: } sascha@165: sascha@165: public String getName() { sascha@165: return getUser().getName(); sascha@165: } sascha@165: sascha@165: public void setName(String name) { sascha@165: getUser().setName(name); sascha@165: } sascha@165: sascha@165: public void setIdentifier(String identifier) { sascha@165: getUser().setIdentifier(identifier); sascha@165: } sascha@165: sascha@165: public Document getRole() { sascha@165: return getUser().getRole(); sascha@165: } sascha@165: sascha@165: public void setRole(Document document) { sascha@165: getUser().setRole(document); sascha@165: } sascha@165: } sascha@165: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :