![]() |
![]() |
| Home > Discussion Forum | ![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Correct way of making session
In my DFC 6.5SP1 application this is how I am making and releasing a session
Code:
public boolean folderExists(String folderName, String path) {
IDfSessionManager smgr = null;
IDfSession session = null;
try {
smgr = DFCUtil.newInstance().getSessionManager();
session = DFCUtil.newInstance().getDocbaseSession(smgr);
IDfFolder folder = session.getFolderByPath(path);
if(folder != null) {
folderExists = true;
}
} catch (DfException dfe) {
DfLogger.error(this, "Path : "+path, null, dfe);
throw new RuntimeException(dfe);
} finally {
if(smgr != null && session != null) {
smgr.release(session);
}
}
return folderExists;
}
Code:
public IDfSessionManager getSessionManager() {
IDfClientX clientx =null;
IDfClient client=null;
IDfSessionManager smgr = null;
try {
clientx=new DfClientX();
client=clientx.getLocalClient();
smgr=client.newSessionManager();
}catch(Exception e) {
throw new RuntimeException(e);
}
return smgr;
}
Code:
public IDfSession getDocbaseSession(IDfSessionManager smgr){
RegistryPasswordUtils putils = new RegistryPasswordUtils();
IDfLoginInfo logininfo=null;
IDfClientX clientx =null;
String lsUserName = null;
String lsPassword = null;
String lsDocbaseName = null;
lsUserName = PropertyReaderFactory.getInstance().getProperties().getProperty("username");
lsPassword = PropertyReaderFactory.getInstance().getProperties().getProperty("password");
lsDocbaseName = PropertyReaderFactory.getInstance().getProperties().getProperty("repository");
IDfSession loSession = null;
try {
clientx=new DfClientX();
logininfo=clientx.getLoginInfo();
logininfo.setUser(lsUserName);
logininfo.setPassword(putils.decrypt(lsPassword));
smgr.setIdentity(lsDocbaseName, logininfo);
smgr.authenticate(lsDocbaseName);
loSession=smgr.getSession(lsDocbaseName);
} catch (DfException e) {
throw new RuntimeException(e);
}
return loSession;
}
For single user it works fine. It made me wonder if I am not creating/releasing the session correctly. Thank you |
|
#2
|
|||
|
|||
|
You shouldnt be retrieving logininfo from the client, you instantiate a new instance:
logininfo = new DfLoginInfo ();
__________________
__________________ Johnny Gee Principal Architect Beach Street Consulting Blog: http://johnnygee.wordpress.com |
|
#3
|
|||
|
|||
|
Quote:
Does that mean, this is not required at all. clientx=new DfClientX(); since I see no other place where this is used. thank you |
|
#4
|
|||
|
|||
|
Its used to get sessionmanager, but its not needed for logininfo.
__________________
__________________ Johnny Gee Principal Architect Beach Street Consulting Blog: http://johnnygee.wordpress.com |
|
#5
|
|||
|
|||
|
Quote:
I'll change that as suggested. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|