MCPcopy
hub / github.com/zaproxy/zaproxy / exit

Method exit

zap/src/main/java/org/parosproxy/paros/control/Control.java:235–338  ·  view source on GitHub ↗
(boolean noPrompt, final File openOnExit)

Source from the content-addressed store, hash-verified

233 }
234
235 public void exit(boolean noPrompt, final File openOnExit) {
236 boolean isNewState = model.getSession().isNewState();
237 int rootCount = 0;
238 if (!Constant.isLowMemoryOptionSet()) {
239 rootCount =
240 model.getSession()
241 .getSiteTree()
242 .getChildCount(model.getSession().getSiteTree().getRoot());
243 }
244 boolean askOnExit =
245 hasView()
246 && Model.getSingleton()
247 .getOptionsParam()
248 .getViewParam()
249 .getAskOnExitOption()
250 > 0;
251 boolean sessionUnsaved = isNewState && rootCount > 0;
252
253 if (!noPrompt) {
254 List<String> list = getExtensionLoader().getUnsavedResources();
255 if (sessionUnsaved && askOnExit) {
256 list.add(
257 0,
258 Constant.messages.getString("menu.file.exit.message.sessionResNotSaved"));
259 }
260
261 String message = null;
262 String activeActions = wrapEntriesInLiTags(getExtensionLoader().getActiveActions());
263 if (list.size() > 0) {
264 String unsavedResources = wrapEntriesInLiTags(list);
265
266 if (activeActions.isEmpty()) {
267 message =
268 Constant.messages.getString(
269 "menu.file.exit.message.resourcesNotSaved", unsavedResources);
270 } else {
271 message =
272 Constant.messages.getString(
273 "menu.file.exit.message.resourcesNotSavedAndActiveActions",
274 unsavedResources,
275 activeActions);
276 }
277 } else if (!activeActions.isEmpty()) {
278 message =
279 Constant.messages.getString(
280 "menu.file.exit.message.activeActions", activeActions);
281 }
282
283 if (message != null
284 && view.showConfirmDialog(new ZapHtmlLabel(message)) != JOptionPane.OK_OPTION) {
285 return;
286 }
287 }
288
289 if (sessionUnsaved) {
290 control.discardSession();
291 }
292

Callers 15

mainFunction · 0.45
runMethod · 0.45
exitAndDeleteSessionMethod · 0.45
actionPerformedMethod · 0.45
windowClosingMethod · 0.45
initMethod · 0.45
runMethod · 0.45
mainMethod · 0.45
exitZapMethod · 0.45

Calls 15

isLowMemoryOptionSetMethod · 0.95
hasViewMethod · 0.95
getSingletonMethod · 0.95
wrapEntriesInLiTagsMethod · 0.95
isNewStateMethod · 0.80
getSiteTreeMethod · 0.80
getAskOnExitOptionMethod · 0.80
getViewParamMethod · 0.80
getExtensionLoaderMethod · 0.80
getChildCountMethod · 0.65
getUnsavedResourcesMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected