Customer login  |   Contact us
Home Company Products Support Purchase
Forum Home » Survey software » Opinio plugins

Topic: Explanation of locking ....
Replies: 2   Pages: 1   Last Post: Jun 30, 2007 12:51 AM by: bkeyser


Back to Topic List Back to Topic List
Replies: 2   Pages: 1  
bkeyser

Posts: 13
From: Broomfield, CO, US
Registered: Jun 5, 2007
Explanation of locking ....
Posted: Jun 26, 2007 2:35 AM
  Reply

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
  Reply

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
  Reply

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



© 1998-2013 ObjectPlanet, Inc. Øvre Slottsgate 5, 0157 Oslo, Norway Tel (+47) 2233 3360 | Fax (+47) 2233 3361