Skip to content

Commit eca01d2

Browse files
Merge pull request #153 from oracle/issue#147-update-domain-does-not-end-session
Issue #147 - Correct exception type in catch statements; perform undo…
2 parents da6eea7 + 880e6c1 commit eca01d2

File tree

5 files changed

+50
-24
lines changed

5 files changed

+50
-24
lines changed

core/src/main/python/deploy.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from oracle.weblogic.deploy.exception import BundleAwareException
1717
from oracle.weblogic.deploy.util import CLAException
1818
from oracle.weblogic.deploy.util import FileUtils
19-
from oracle.weblogic.deploy.util import PyWLSTException
2019
from oracle.weblogic.deploy.util import TranslateException
2120
from oracle.weblogic.deploy.util import VariableException
2221
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
@@ -284,10 +283,7 @@ def __deploy_online(model, model_context, aliases):
284283
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions()
285284
__wlst_helper.edit()
286285
__wlst_helper.start_edit()
287-
except PyWLSTException, pwe:
288-
ex = exception_helper.create_deploy_exception('WLSDPLY-09006', _program_name, admin_url,
289-
pwe.getLocalizedMessage(), error=pwe)
290-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
286+
except BundleAwareException, ex:
291287
raise ex
292288

293289
__logger.info("WLSDPLY-09007", admin_url, method_name=_method_name, class_name=_class_name)
@@ -301,20 +297,18 @@ def __deploy_online(model, model_context, aliases):
301297
try:
302298
__wlst_helper.save()
303299
__wlst_helper.activate()
304-
except PyWLSTException, pwe:
305-
ex = exception_helper.create_deploy_exception('WLSDPLY-09008', pwe.getLocalizedMessage(), error=pwe)
306-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
300+
except BundleAwareException, ex:
307301
__release_edit_session_and_disconnect()
308302
raise ex
309303

310304
model_deployer.deploy_applications(model, model_context, aliases, wlst_mode=__wlst_mode)
311305

312306
try:
313307
__wlst_helper.disconnect()
314-
except PyWLSTException, pwe:
308+
except BundleAwareException, ex:
315309
# All the changes are made and active so don't raise an error that causes the program
316310
# to indicate a failure...just log the error since the process is going to exit anyway.
317-
__logger.warning('WLSDPLY-09009', _program_name, pwe.getLocalizedMessage(), error=pwe,
311+
__logger.warning('WLSDPLY-09009', _program_name, ex.getLocalizedMessage(), error=ex,
318312
class_name=_class_name, method_name=_method_name)
319313
return
320314

@@ -358,6 +352,7 @@ def __release_edit_session_and_disconnect():
358352
"""
359353
_method_name = '__release_edit_session_and_disconnect'
360354
try:
355+
__wlst_helper.undo()
361356
__wlst_helper.stop_edit()
362357
__wlst_helper.disconnect()
363358
except BundleAwareException, ex:
@@ -375,10 +370,10 @@ def __close_domain_on_error():
375370
_method_name = '__close_domain_on_error'
376371
try:
377372
__wlst_helper.close_domain()
378-
except PyWLSTException, pwe:
373+
except BundleAwareException, ex:
379374
# This method is only used for cleanup after an error so don't mask
380375
# the original problem by throwing yet another exception...
381-
__logger.warning('WLSDPLY-09013', pwe.getLocalizedMessage(), error=pwe,
376+
__logger.warning('WLSDPLY-09013', ex.getLocalizedMessage(), error=ex,
382377
class_name=_class_name, method_name=_method_name)
383378
return
384379

@@ -479,6 +474,7 @@ def main(args):
479474
__clean_up_temp_files()
480475
return
481476

477+
482478
if __name__ == "main":
483479
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
484480
main(sys.argv)

core/src/main/python/update.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from oracle.weblogic.deploy.exception import BundleAwareException
1717
from oracle.weblogic.deploy.util import CLAException
1818
from oracle.weblogic.deploy.util import FileUtils
19-
from oracle.weblogic.deploy.util import PyWLSTException
2019
from oracle.weblogic.deploy.util import TranslateException
2120
from oracle.weblogic.deploy.util import VariableException
2221
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
@@ -296,10 +295,7 @@ def __update_online(model, model_context, aliases):
296295
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions()
297296
__wlst_helper.edit()
298297
__wlst_helper.start_edit()
299-
except PyWLSTException, pwe:
300-
ex = exception_helper.create_deploy_exception('WLSDPLY-09006', _program_name, admin_url,
301-
pwe.getLocalizedMessage(), error=pwe)
302-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
298+
except BundleAwareException, ex:
303299
raise ex
304300

305301
__logger.info("WLSDPLY-09007", admin_url, method_name=_method_name, class_name=_class_name)
@@ -316,20 +312,18 @@ def __update_online(model, model_context, aliases):
316312
try:
317313
__wlst_helper.save()
318314
__wlst_helper.activate()
319-
except PyWLSTException, pwe:
320-
ex = exception_helper.create_deploy_exception('WLSDPLY-09008', pwe.getLocalizedMessage(), error=pwe)
321-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
315+
except BundleAwareException, ex:
322316
__release_edit_session_and_disconnect()
323317
raise ex
324318

325319
model_deployer.deploy_applications(model, model_context, aliases, wlst_mode=__wlst_mode)
326320

327321
try:
328322
__wlst_helper.disconnect()
329-
except PyWLSTException, pwe:
323+
except BundleAwareException, ex:
330324
# All the changes are made and active so don't raise an error that causes the program
331325
# to indicate a failure...just log the error since the process is going to exit anyway.
332-
__logger.warning('WLSDPLY-09009', _program_name, pwe.getLocalizedMessage(), error=pwe,
326+
__logger.warning('WLSDPLY-09009', _program_name, ex.getLocalizedMessage(), error=ex,
333327
class_name=_class_name, method_name=_method_name)
334328
return
335329

@@ -376,6 +370,7 @@ def __release_edit_session_and_disconnect():
376370
"""
377371
_method_name = '__release_edit_session_and_disconnect'
378372
try:
373+
__wlst_helper.undo()
379374
__wlst_helper.stop_edit()
380375
__wlst_helper.disconnect()
381376
except BundleAwareException, ex:
@@ -393,10 +388,10 @@ def __close_domain_on_error():
393388
_method_name = '__close_domain_on_error'
394389
try:
395390
__wlst_helper.close_domain()
396-
except PyWLSTException, pwe:
391+
except BundleAwareException, ex:
397392
# This method is only used for cleanup after an error so don't mask
398393
# the original problem by throwing yet another exception...
399-
__logger.warning('WLSDPLY-09013', pwe.getLocalizedMessage(), error=pwe,
394+
__logger.warning('WLSDPLY-09013', ex.getLocalizedMessage(), error=ex,
400395
class_name=_class_name, method_name=_method_name)
401396
return
402397

core/src/main/python/wlsdeploy/tool/util/wlst_helper.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,22 @@ def stop_edit(self):
520520
raise ex
521521
return
522522

523+
def undo(self):
524+
"""
525+
Revert all unsaved or unactivated edits.
526+
:raises: BundleAwareException of the specified type: if an error occurs
527+
"""
528+
_method_name = 'undo'
529+
530+
try:
531+
wlst_helper.undo()
532+
except PyWLSTException, pwe:
533+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19142',
534+
pwe.getLocalizedMessage(), error=pwe)
535+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
536+
raise ex
537+
return
538+
523539
def save(self):
524540
"""
525541
Save the outstanding Weblogic Server configuration changes for the current edit session.

core/src/main/python/wlsdeploy/util/wlst_helper.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,23 @@ def stop_edit():
692692
_logger.exiting(class_name=_class_name, method_name=_method_name)
693693

694694

695+
def undo():
696+
"""
697+
Revert all unsaved or unactivated edits.
698+
:raises: PyWLSTException: if a WLST error occurs
699+
"""
700+
_method_name = 'undo'
701+
_logger.entering(class_name=_class_name, method_name=_method_name)
702+
703+
try:
704+
wlst.undo('true', 'y')
705+
except wlst.WLSTException, e:
706+
pwe = exception_helper.create_pywlst_exception('WLSDPLY-00069', _format_exception(e), error=e)
707+
_logger.throwing(class_name=_class_name, method_name=_method_name, error=pwe)
708+
raise pwe
709+
_logger.exiting(class_name=_class_name, method_name=_method_name)
710+
711+
695712
def save():
696713
"""
697714
Save the outstanding Weblogic Server configuration changes for the current edit session.

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ WLSDPLY-00065=Failed to switch to the serverConfig MBean tree: {0}
7373
WLSDPLY-00066=Failed to switch to the domainRuntime MBean tree: {0}
7474
WLSDPLY-00067=Failed to switch to the custom MBean tree: {0}
7575
WLSDPLY-00068=Failed to change directories back to the original location {0}: {1}
76+
WLSDPLY-00069=wlst.undo() failed : {0}
7677

7778
###############################################################################
7879
# Util messages (1000 - 3999) #
@@ -1095,6 +1096,7 @@ WLSDPLY-19138=Failed to redeploy application {0}:{1}
10951096
WLSDPLY-19139=Failed to start application {0}: {1}
10961097
WLSDPLY-19140=Failed to stop application {0}: {1}
10971098
WLSDPLY-19141=Failed to undeploy application {0}:{1}
1099+
WLSDPLY-19142=Failed to undo changes: {0}
10981100

10991101
# wlsdeploy/tool/util/attribute_setter.py
11001102
WLSDPLY-19200=No target found with name {0}

0 commit comments

Comments
 (0)