bkeyser
Posts:
13
From:
Broomfield, CO, US
Registered:
Jun 5, 2007
|
|
Explanation of locking ....
Posted:
Jun 26, 2007 2:35 AM
|
|
Hi,
While trying to create a survey the following steps are performed
Survey survey = SurveyManager.create(user, folderId);
survey.setSurveyName(....); SurveyManager.updateSurvey(user, survey.getSurveyId());
However, a LockException is being thrown. I have tried modifying the above segment to include a release of lock
Survey survey = ... survey.releaseLock(); SurveyManager.updateSurvey(user, survey.getSurveyId());
survey.setName(...); SurveyManager.updateSurvey(user, survey.getSurveyId());
However, it is still throwing a lock exception. Can someone please describe the guidelines for handling locks?
Thanks, Brian
|
|
torgeir
Posts:
1,096
From:
Oslo
Registered:
Jun 20, 2002
|
|
Re: Explanation of locking ....
Posted:
Jun 27, 2007 8:02 PM
|
|
It should work. I ran the following, and it worked fine:
// create a test user User testUser = UserManager.createUser(adminUser, "testuser", "testuser", "tst@nowhere.com", null); UserManager.grantFolderPermission(adminUser, testUser.getUserId(), mainFolderId, UserManager.PERMISSION_ADMIN);
testUser = UserManager.getUser("testuser"); // create survey: Survey testSurvey = SurveyManager.createSurvey(testUser, -1); surveyId2 = testSurvey.getSurveyId(); SurveyManager.updateSurvey(testUser, testSurvey.getSurveyId());
testSurvey.setSurveyName("Test Survey by testuser"); SurveyManager.updateSurvey(testUser, surveyId2);
Are you sure you don't have another user locking it somehow in the meantime?
|
|
bkeyser
Posts:
13
From:
Broomfield, CO, US
Registered:
Jun 5, 2007
|
|
Re: Explanation of locking ....
Posted:
Jun 30, 2007 12:51 AM
|
|
Hi Torgeir,
This method worked. The key was was calling the first update. You might consider updating the javadoc to help others out ....
Thanks, Brian
|
|
|
|
|