From 2b4f8623bd4a32b98e109711b7299c8d03831fc8 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Mon, 5 Aug 2013 08:51:42 +0200 Subject: [PATCH] OO-648: fix RS in course preview if a course password is set --- .../course/run/preview/PreviewIdentity.java | 175 ++++++++---------- 1 file changed, 76 insertions(+), 99 deletions(-) diff --git a/src/main/java/org/olat/course/run/preview/PreviewIdentity.java b/src/main/java/org/olat/course/run/preview/PreviewIdentity.java index 2eb4842da47..4f58477183d 100644 --- a/src/main/java/org/olat/course/run/preview/PreviewIdentity.java +++ b/src/main/java/org/olat/course/run/preview/PreviewIdentity.java @@ -35,144 +35,121 @@ import org.olat.core.id.Persistable; import org.olat.core.id.Preferences; import org.olat.core.id.User; import org.olat.core.id.UserConstants; -import org.olat.core.logging.AssertException; /** * Initial Date: 08.02.2005 * * @author Mike Stock */ -final class PreviewIdentity implements Identity { +final class PreviewIdentity implements Identity, User { + + private static final long serialVersionUID = 6582855975941440446L; + + private final Map<String, String> data = new HashMap<String, String>(); + private Map<String, String> envAttrs; + { + data.put(UserConstants.FIRSTNAME, "Jane"); + data.put(UserConstants.LASTNAME, "Doe"); + data.put(UserConstants.EMAIL, "jane.doe@testmail.com"); + } + /** + * @see org.olat.core.commons.persistence.Persistable#getKey() + */ + @Override + public Long getKey() { + return 2l; + } + /** * @see org.olat.core.id.Identity#getName() */ + @Override public String getName() { return "JaneDoe"; } + @Override + public void setName(String loginName) { + // + } + /** * @see org.olat.core.id.Identity#getUser() */ + @Override public User getUser() { - return new User(){ - Map<String, String> data = new HashMap<String, String>(); - private Map<String, String> envAttrs; - { - data.put(UserConstants.FIRSTNAME, "Jane"); - data.put(UserConstants.LASTNAME, "Doe"); - data.put(UserConstants.EMAIL, "jane.doe@testmail.com"); - } - - public Long getKey() { - // TODO Auto-generated method stub - return null; - } - @SuppressWarnings("unused") - public boolean equalsByPersistableKey(Persistable persistable) { - // TODO Auto-generated method stub - return false; - } - - public Date getLastModified() { - // TODO Auto-generated method stub - return null; - } - - public Date getCreationDate() { - // TODO Auto-generated method stub - return null; - } - @SuppressWarnings("unused") - public void setProperty(String propertyName, String propertyValue) { - // TODO Auto-generated method stub - - } - @SuppressWarnings("unused") - public void setPreferences(Preferences prefs) { - // TODO Auto-generated method stub - - } - @SuppressWarnings("unused") - public String getProperty(String propertyName, Locale locale) { - return data.get(propertyName); - } - - public void setIdentityEnvironmentAttributes(Map<String, String> identEnvAttribs) { - this.envAttrs = identEnvAttribs; - } - - public String getPropertyOrIdentityEnvAttribute(String propertyName, Locale locale) { - String retVal = null; - retVal = data.get(propertyName); - if(retVal== null && this.envAttrs != null){ - retVal = envAttrs.get(propertyName); - } - return retVal; - } - - public Preferences getPreferences() { - // TODO Auto-generated method stub - return null; - } - - }; + return this; } - /** - * @see org.olat.core.commons.persistence.Auditable#getCreationDate() - */ - public Date getCreationDate() { - throw new AssertException("unsupported"); + @Override + public String getProperty(String propertyName, Locale locale) { + return data.get(propertyName); } - /** - * @see org.olat.core.commons.persistence.Auditable#getLastModified() - */ - public Date getLastModified() { - throw new AssertException("unsupported"); + @Override + public void setProperty(String propertyName, String propertyValue) { + data.put(propertyName, propertyValue); } - /** - * @see org.olat.core.commons.persistence.Persistable#getKey() - */ - public Long getKey() { - throw new AssertException("unsupported"); + @Override + public void setIdentityEnvironmentAttributes(Map<String, String> identEnvAttribs) { + this.envAttrs = identEnvAttribs; + } + + @Override + public String getPropertyOrIdentityEnvAttribute(String propertyName, Locale locale) { + String retVal = null; + retVal = data.get(propertyName); + if(retVal== null && this.envAttrs != null){ + retVal = envAttrs.get(propertyName); + } + return retVal; + } + + @Override + public Preferences getPreferences() { + return null; + } + + @Override + public void setPreferences(Preferences prefs) { + // } /** - * @see org.olat.core.commons.persistence.Persistable#equalsByPersistableKey(org.olat.core.commons.persistence.Persistable) + * @see org.olat.core.commons.persistence.Auditable#getCreationDate() */ - public boolean equalsByPersistableKey(Persistable persistable) { - throw new AssertException("unsupported"); + @Override + public Date getCreationDate() { + return new Date(); } + @Override public Date getLastLogin() { - throw new AssertException("unsupported"); + return new Date(); } + @Override public void setLastLogin(Date loginDate) { - throw new AssertException("unsupported"); + // } - + + @Override public Integer getStatus() { - throw new AssertException("unsupported"); + return Identity.STATUS_ACTIV; } + @Override public void setStatus(Integer newStatus) { - throw new AssertException("unsupported"); - } - - public Date getDeleteEmailDate() { - throw new AssertException("unsupported"); - } - - public void setDeleteEmailDate(Date newDeleteEmail) { - throw new AssertException("unsupported"); + // } - - public void setName(String loginName) { - + + /** + * @see org.olat.core.commons.persistence.Persistable#equalsByPersistableKey(org.olat.core.commons.persistence.Persistable) + */ + @Override + public boolean equalsByPersistableKey(Persistable persistable) { + return equals(persistable); } - } \ No newline at end of file -- GitLab