1 30 package com.genimen.djeneric.repository; 31 32 import com.genimen.djeneric.language.Messages; 33 import com.genimen.djeneric.repository.exceptions.DjenericException; 34 import com.genimen.djeneric.repository.exceptions.ObjectNotDefinedException; 35 36 44 public abstract class DjContextManager 45 { 46 53 public abstract DjContext createNewContext() throws DjenericException; 54 55 61 public abstract DjContext[] getContexts() throws DjenericException; 62 63 70 public abstract DjUserContextAssociation createNewUserContextAssociation() throws DjenericException; 71 72 79 public abstract DjUser createNewUser() throws DjenericException; 80 81 88 public abstract DjUser getUser(String userCode) throws DjenericException; 89 90 96 public abstract DjUser[] getUsers() throws DjenericException; 97 98 100 DjPersistenceManager _mgr; 101 DjContext _currentContext = null; 102 103 108 public DjContextManager(DjPersistenceManager mgr) 109 110 { 111 _mgr = mgr; 112 } 113 114 119 public DjPersistenceManager getPersistenceManager() 120 { 121 return _mgr; 122 } 123 124 132 public void setCurrentContext(String contextCode) throws ObjectNotDefinedException, DjenericException 133 { 134 if (contextCode == null) 135 { 136 setCurrentContext((DjContext) null); 137 return; 138 } 139 140 DjContext[] ctxts = getContexts(); 141 for (int i = 0; i < ctxts.length; i++) 142 { 143 if (ctxts[i].getCode().equals(contextCode)) 144 { 145 setCurrentContext(ctxts[i]); 146 return; 147 } 148 } 149 throw new ObjectNotDefinedException(Messages.getString("DjContextManager.UnknownCode", contextCode)); 150 } 151 152 158 public void setCurrentContext(DjContext ctxt) 159 { 160 _currentContext = ctxt; 161 } 162 163 168 public DjContext getCurrentContext() 169 { 170 return _currentContext; 171 } 172 } | Popular Tags |