19130aa267b00960dbdf5f497d10049b9b3051f6
[policy/gui.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2020 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.gui.editors.apex.rest.handling;
23
24 import java.util.Map;
25 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
26 import org.onap.policy.apex.model.modelapi.ApexApiResult;
27 import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
28 import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
29 import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanKeyRef;
30 import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanLogic;
31 import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanPolicy;
32 import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanState;
33 import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanStateOutput;
34 import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanStateTaskRef;
35 import org.slf4j.ext.XLogger;
36 import org.slf4j.ext.XLoggerFactory;
37
38 /**
39  * This class handles commands on policies in Apex models.
40  */
41 public class PolicyHandler implements RestCommandHandler {
42     // Get a reference to the logger
43     private static final XLogger LOGGER = XLoggerFactory.getXLogger(PolicyHandler.class);
44
45     // Recurring string constants
46     private static final String OK = ": OK";
47     private static final String NOT_OK = ": Not OK";
48     private static final String POLICY_WAS_CREATED = "\". The policy was created, ";
49     private static final String POLICY_STATE_CREATED = "\". The policy and state were created, ";
50     private static final String POLICY_PARTIALLY_DEFINED = " The policy has only been partially defined.";
51     private static final String FOR_POLICY = "\" for policy \"";
52     private static final String IN_STATE = "\" in state \"";
53     private static final String POLICY_CREATED_STATE_ERROR = POLICY_WAS_CREATED
54         + "but there was an error adding the state.";
55     private static final String POLICY_STATE_CREATED_OTHER_ERROR = POLICY_STATE_CREATED
56         + "but there was an error adding the";
57
58     /**
59      * {@inheritDoc}.
60      */
61     @Override
62     public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
63         final RestCommand command) {
64         return getUnsupportedCommandResultMessage(session, commandType, command);
65     }
66
67     /**
68      * {@inheritDoc}.
69      */
70     @Override
71     public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
72         final RestCommand command, final String jsonString) {
73
74         if (!RestCommandType.POLICY.equals(commandType)) {
75             return getUnsupportedCommandResultMessage(session, commandType, command);
76         }
77
78         switch (command) {
79             case CREATE:
80                 return createPolicy(session, jsonString);
81             case UPDATE:
82                 return updatePolicy(session, jsonString);
83             default:
84                 return getUnsupportedCommandResultMessage(session, commandType, command);
85         }
86     }
87
88     /**
89      * {@inheritDoc}.
90      */
91     @Override
92     public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
93         final RestCommand command, final String name, final String version) {
94         if (!RestCommandType.POLICY.equals(commandType)) {
95             return getUnsupportedCommandResultMessage(session, commandType, command);
96         }
97
98         switch (command) {
99             case LIST:
100                 return listPolicies(session, name, version);
101             case DELETE:
102                 return deletePolicy(session, name, version);
103             default:
104                 return getUnsupportedCommandResultMessage(session, commandType, command);
105         }
106     }
107
108     /**
109      * Creates a policy with the information in the JSON string passed.
110      *
111      * @param session    the Apex model editing session
112      * @param jsonString the JSON string to be parsed See {@linkplain BeanPolicy}
113      * @return an ApexAPIResult object. If successful then
114      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
115      *         can be retrieved using {@link ApexApiResult#getMessages()}
116      */
117     public ApexApiResult createPolicy(final RestSession session, final String jsonString) {
118         LOGGER.entry(jsonString);
119
120         final BeanPolicy jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
121
122         session.editModel();
123
124         ApexApiResult result = session.getApexModelEdited().createPolicy(jsonbean.getName(), jsonbean.getVersion(),
125             jsonbean.getTemplate(), jsonbean.getFirstState(), jsonbean.getUuid(), jsonbean.getDescription());
126
127         if (result.isOk()) {
128             result = createPolicyContent(session, jsonbean);
129         }
130
131         session.finishSession(result.isOk());
132
133         LOGGER.exit("Policy/Create" + (result != null && result.isOk() ? OK : NOT_OK));
134         return result;
135     }
136
137     /**
138      * Create the content of the policy.
139      *
140      * @param session    the Apex model editing session
141      * @param jsonString the JSON string to be parsed See {@linkplain BeanPolicy}
142      * @return an ApexAPIResult object. If successful then
143      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
144      *         can be retrieved using {@link ApexApiResult#getMessages()}
145      */
146     private ApexApiResult createPolicyContent(RestSession session, BeanPolicy jsonbean) {
147         ApexApiResult result = new ApexApiResult();
148
149         if (jsonbean.getStates() == null || jsonbean.getStates().isEmpty()) {
150             result.setResult(Result.FAILED);
151             result.addMessage("Null or empty state map; no states defined for policy \"" + jsonbean.getName() + ":"
152                 + jsonbean.getVersion() + "\". The policy was created, but there was an error adding states."
153                 + POLICY_PARTIALLY_DEFINED);
154             return result;
155         }
156
157         // States reference each other so all states must be created before they are
158         // populated
159         for (final Map.Entry<String, BeanState> stateEntry : jsonbean.getStates().entrySet()) {
160             ApexApiResult stateCreateResult = createState(session, jsonbean.getName(), jsonbean.getVersion(),
161                 stateEntry.getKey(), stateEntry.getValue());
162
163             if (stateCreateResult.isNok()) {
164                 result.setResult(stateCreateResult.getResult());
165                 result.addMessage(stateCreateResult.getMessage());
166             }
167         }
168
169         // Bale out if the state creation did not work
170         if (result.isNok()) {
171             return result;
172         }
173
174         // Now create the content of each state
175         for (final Map.Entry<String, BeanState> stateEntry : jsonbean.getStates().entrySet()) {
176             ApexApiResult stateContentCreateResult = createStateContent(session, jsonbean.getName(),
177                 jsonbean.getVersion(), stateEntry.getKey(), stateEntry.getValue());
178
179             if (stateContentCreateResult.isNok()) {
180                 result.setResult(stateContentCreateResult.getResult());
181                 result.addMessage(stateContentCreateResult.getMessage());
182             }
183         }
184
185         return result;
186     }
187
188     /**
189      * Create a state on the policy.
190      *
191      * @param session      the Apex model editing session
192      * @param policyName   the policy name
193      * @param policVersion the policy version
194      * @param stateName    the name of the state
195      * @param stateBean    the information on the state to create
196      * @return an ApexAPIResult object. If successful then
197      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
198      *         can be retrieved using {@link ApexApiResult#getMessages()}
199      */
200     private ApexApiResult createState(final RestSession session, final String policyName, final String policyVersion,
201         final String stateName, final BeanState stateBean) {
202
203         if (stateBean == null) {
204             return new ApexApiResult(Result.FAILED,
205                 "Null or invalid state information for state \"" + stateName + FOR_POLICY + policyName + ":"
206                     + policyVersion + POLICY_CREATED_STATE_ERROR + POLICY_PARTIALLY_DEFINED);
207         }
208
209         if (stateBean.getTrigger() == null) {
210             return new ApexApiResult(Result.FAILED,
211                 "Null or invalid state trigger for state \"" + stateName + FOR_POLICY + policyName + ":" + policyVersion
212                     + POLICY_CREATED_STATE_ERROR + POLICY_PARTIALLY_DEFINED);
213         }
214
215         if (stateBean.getDefaultTask() == null) {
216             return new ApexApiResult(Result.FAILED, "Null or invalid default task for state \"" + stateName + FOR_POLICY
217                 + policyName + ":" + policyVersion + POLICY_CREATED_STATE_ERROR + POLICY_PARTIALLY_DEFINED);
218         }
219
220         return session.getApexModelEdited().createPolicyState(policyName, policyVersion, stateName,
221             stateBean.getTrigger().getName(), stateBean.getTrigger().getVersion(), stateBean.getDefaultTask().getName(),
222             stateBean.getDefaultTask().getVersion());
223     }
224
225     /**
226      * Create the content of a state on the policy.
227      *
228      * @param session      the Apex model editing session
229      * @param policyName   the policy name
230      * @param policVersion the policy version
231      * @param stateName    the name of the state
232      * @param stateBean    the information on the state to create
233      * @return an ApexAPIResult object. If successful then
234      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
235      *         can be retrieved using {@link ApexApiResult#getMessages()}
236      */
237     private ApexApiResult createStateContent(final RestSession session, final String policyName,
238         final String policyVersion, final String stateName, final BeanState stateBean) {
239
240         ApexApiResult ret = createStateTaskSelectionLogic(session, policyName, policyVersion, stateName, stateBean);
241
242         if (ret.isOk()) {
243             ret = createStateContextReferences(session, policyName, policyVersion, stateName, stateBean);
244         }
245
246         if (ret.isOk()) {
247             ret = createStateFinalizers(session, policyName, policyVersion, stateName, stateBean);
248         }
249
250         if (ret.isOk()) {
251             ret = createStateOutputs(session, policyName, policyVersion, stateName, stateBean);
252         }
253
254         if (ret.isOk()) {
255             ret = createStateTaskReferences(session, policyName, policyVersion, stateName, stateBean);
256         }
257
258         return ret;
259     }
260
261     /**
262      * Create the task selection logic for the state.
263      *
264      * @param session      the Apex model editing session
265      * @param policyName   the policy name
266      * @param policVersion the policy version
267      * @param stateName    the name of the state
268      * @param stateBean    the information on the state to create
269      * @return an ApexAPIResult object. If successful then
270      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
271      *         can be retrieved using {@link ApexApiResult#getMessages()}
272      */
273     private ApexApiResult createStateTaskSelectionLogic(final RestSession session, final String policyName,
274         final String policyVersion, final String stateName, final BeanState stateBean) {
275
276         final BeanLogic tsl = stateBean.getTaskSelectionLogic();
277         if (tsl == null) {
278             return new ApexApiResult();
279         }
280
281         ApexApiResult result = session.getApexModelEdited().createPolicyStateTaskSelectionLogic(policyName,
282             policyVersion, stateName, tsl.getLogicFlavour(), tsl.getLogic());
283
284         if (result.isNok()) {
285             result.addMessage("Failed to add task selection logic for state \"" + stateName + "\" for" + " policy \""
286                 + policyName + ":" + policyVersion + POLICY_WAS_CREATED
287                 + "but there was an error adding the task selection logic "
288                 + "for the state. The policy has only been partially defined.");
289         }
290         return result;
291     }
292
293     /**
294      * Create the context references for the state.
295      *
296      * @param session      the Apex model editing session
297      * @param policyName   the policy name
298      * @param policVersion the policy version
299      * @param stateName    the name of the state
300      * @param stateBean    the information on the state to create
301      * @return an ApexAPIResult object. If successful then
302      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
303      *         can be retrieved using {@link ApexApiResult#getMessages()}
304      */
305     private ApexApiResult createStateContextReferences(final RestSession session, final String policyName,
306         final String policyVersion, final String stateName, final BeanState stateBean) {
307
308         ApexApiResult result = new ApexApiResult();
309
310         final BeanKeyRef[] contextReferences = stateBean.getContexts();
311         if (contextReferences == null || contextReferences.length == 0) {
312             return result;
313         }
314
315         for (final BeanKeyRef contextReference : contextReferences) {
316             if (contextReference == null) {
317                 result.setResult(Result.FAILED);
318                 result.addMessage("Null or invalid context reference \"" + contextReference + "\" for" + " state \""
319                     + stateName + FOR_POLICY + policyName + ":" + policyVersion
320                     + "\". The policy was created, but there was an error adding the context "
321                     + "reference for the state. The policy has only been partially defined.");
322                 continue;
323             }
324
325             ApexApiResult contextRefResult = session.getApexModelEdited().createPolicyStateContextRef(policyName,
326                 policyVersion, stateName, contextReference.getName(), contextReference.getVersion());
327
328             if (contextRefResult.isNok()) {
329                 result.setResult(contextRefResult.getResult());
330                 result.addMessage("Failed to add context reference \"" + contextReference + "\" for state \""
331                     + stateName + FOR_POLICY + policyName + ":" + policyVersion + POLICY_WAS_CREATED
332                     + "but there was an error adding the context reference "
333                     + "for the state. The policy has only been partially defined.");
334             }
335         }
336
337         return result;
338     }
339
340     /**
341      * Create the state finalizers for the state.
342      *
343      * @param session      the Apex model editing session
344      * @param policyName   the policy name
345      * @param policVersion the policy version
346      * @param stateName    the name of the state
347      * @param stateBean    the information on the state to create
348      * @return an ApexAPIResult object. If successful then
349      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
350      *         can be retrieved using {@link ApexApiResult#getMessages()}
351      */
352     private ApexApiResult createStateFinalizers(final RestSession session, final String policyName,
353         final String policyVersion, final String stateName, final BeanState stateBean) {
354
355         ApexApiResult result = new ApexApiResult();
356
357         final Map<String, BeanLogic> finalizers = stateBean.getFinalizers();
358         if (finalizers == null || finalizers.isEmpty()) {
359             return result;
360         }
361
362         for (final Map.Entry<String, BeanLogic> finalizerEntry : finalizers.entrySet()) {
363             if (finalizerEntry.getKey() == null || finalizerEntry.getValue() == null) {
364                 result.setResult(Result.FAILED);
365                 result.addMessage("Null or invalid finalizer information for finalizer " + "named \""
366                     + finalizerEntry.getKey() + IN_STATE + stateName + FOR_POLICY + policyName + ":" + policyVersion
367                     + POLICY_STATE_CREATED_OTHER_ERROR + " finalizer. The policy has only "
368                     + "been partially defined.");
369                 continue;
370             }
371
372             ApexApiResult finalizerResult = session.getApexModelEdited().createPolicyStateFinalizerLogic(policyName,
373                 policyVersion, stateName, finalizerEntry.getKey(), finalizerEntry.getValue().getLogicFlavour(),
374                 finalizerEntry.getValue().getLogic());
375
376             if (finalizerResult.isNok()) {
377                 result.setResult(finalizerResult.getResult());
378                 result.addMessage("Failed to add finalizer information for finalizer named \"" + finalizerEntry.getKey()
379                     + "\" in" + " state \"" + stateName + FOR_POLICY + policyName + ":" + policyVersion
380                     + POLICY_STATE_CREATED_OTHER_ERROR + " finalizer. The policy has only been partially defined.");
381             }
382         }
383
384         return result;
385     }
386
387     /**
388      * Create the state outputs for the state.
389      *
390      * @param session      the Apex model editing session
391      * @param policyName   the policy name
392      * @param policVersion the policy version
393      * @param stateName    the name of the state
394      * @param stateBean    the information on the state to create
395      * @return an ApexAPIResult object. If successful then
396      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
397      *         can be retrieved using {@link ApexApiResult#getMessages()}
398      */
399     private ApexApiResult createStateOutputs(final RestSession session, final String policyName,
400         final String policyVersion, final String stateName, final BeanState stateBean) {
401
402         ApexApiResult result = new ApexApiResult();
403
404         final Map<String, BeanStateOutput> stateOutputs = stateBean.getStateOutputs();
405         if (stateOutputs == null || stateOutputs.isEmpty()) {
406             result.setResult(Result.FAILED);
407             result.addMessage("No state outputs have been defined in state \"" + stateName + FOR_POLICY + policyName
408                 + ":" + policyVersion + "\". The policy and state were created, but there was an error adding state"
409                 + " outputs. The policy has only been partially defined.");
410             return result;
411         }
412
413         for (final Map.Entry<String, BeanStateOutput> stateOutput : stateOutputs.entrySet()) {
414             final String outputName = stateOutput.getKey();
415             final BeanStateOutput output = stateOutput.getValue();
416
417             if (outputName == null || output == null || output.getEvent() == null) {
418                 result.setResult(Result.FAILED);
419                 result.addMessage("Null or invalid output information for output named \"" + outputName + IN_STATE
420                     + stateName + FOR_POLICY + policyName + ":" + policyVersion + POLICY_STATE_CREATED_OTHER_ERROR
421                     + " output. The policy has only been partially defined.");
422                 continue;
423             }
424
425             ApexApiResult outputResult = session.getApexModelEdited().createPolicyStateOutput(policyName, policyVersion,
426                 stateName, outputName, output.getEvent().getName(), output.getEvent().getVersion(),
427                 output.getNextState());
428
429             if (outputResult.isNok()) {
430                 result.setResult(outputResult.getResult());
431                 result.addMessage("Failed to add output information for output named \"" + outputName + IN_STATE
432                     + stateName + FOR_POLICY + policyName + ":" + policyVersion + POLICY_STATE_CREATED
433                     + "but there was an error adding the output." + POLICY_PARTIALLY_DEFINED);
434             }
435         }
436
437         return result;
438     }
439
440     /**
441      * Create the task references for the state.
442      *
443      * @param session      the Apex model editing session
444      * @param policyName   the policy name
445      * @param policVersion the policy version
446      * @param stateName    the name of the state
447      * @param stateBean    the information on the state to create
448      * @return an ApexAPIResult object. If successful then
449      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
450      *         can be retrieved using {@link ApexApiResult#getMessages()}
451      */
452     private ApexApiResult createStateTaskReferences(final RestSession session, final String policyName,
453         final String policyVersion, final String stateName, final BeanState stateBean) {
454
455         ApexApiResult result = new ApexApiResult();
456
457         final Map<String, BeanStateTaskRef> taskMap = stateBean.getTasks();
458         if (taskMap == null || taskMap.isEmpty()) {
459             result.setResult(Result.FAILED);
460             result.addMessage("No tasks have been defined in state \"" + stateName + FOR_POLICY + policyName + ":"
461                 + policyVersion + "\". The policy and state were created, but there was an error adding tasks."
462                 + POLICY_PARTIALLY_DEFINED);
463             return result;
464         }
465
466         for (final Map.Entry<String, BeanStateTaskRef> taskEntry : taskMap.entrySet()) {
467             final String taskLocalName = taskEntry.getKey();
468             final BeanStateTaskRef taskReference = taskEntry.getValue();
469
470             if (taskLocalName == null || taskReference == null || taskReference.getTask() == null) {
471                 result.setResult(Result.FAILED);
472                 result.addMessage("Null or invalid task information for task named \"" + taskLocalName + IN_STATE
473                     + stateName + "\" for for policy \"" + policyName + ":" + policyVersion
474                     + "\". The policy and state were created, but there was an error adding the "
475                     + "task. The policy has only been partially defined.");
476                 continue;
477             }
478
479             ApexApiResult taskRefResult = session.getApexModelEdited().createPolicyStateTaskRef(policyName,
480                 policyVersion, stateName, taskLocalName, taskReference.getTask().getName(),
481                 taskReference.getTask().getVersion(), taskReference.getOutputType(), taskReference.getOutputName());
482
483             if (taskRefResult.isNok()) {
484                 result.setResult(taskRefResult.getResult());
485                 result.addMessage("Failed to add task reference \"" + taskEntry + "\" for state \"" + stateName
486                     + FOR_POLICY + policyName + ":" + policyVersion + POLICY_WAS_CREATED
487                     + "but there was an error adding the task reference for"
488                     + " the state. The policy has only been partially defined.");
489             }
490         }
491
492         return result;
493     }
494
495     /**
496      * Update a policy with the information in the JSON string passed.
497      *
498      * @param session    the Apex model editing session
499      * @param jsonString the JSON string to be parsed. See {@linkplain BeanPolicy}
500      * @return an ApexAPIResult object. If successful then
501      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
502      *         can be retrieved using {@link ApexApiResult#getMessages()}
503      */
504     private ApexApiResult updatePolicy(final RestSession session, final String jsonString) {
505
506         LOGGER.entry(jsonString);
507
508         final BeanPolicy jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
509
510         if (blank2Null(jsonbean.getName()) == null || blank2Null(jsonbean.getVersion()) == null) {
511             LOGGER.exit("Task/Update" + NOT_OK);
512             return new ApexApiResult(Result.FAILED, "Null/Empty Policy name/version (\"" + jsonbean.getName() + ":"
513                 + jsonbean.getVersion() + "\" passed to UpdatePolicy");
514         }
515
516         session.editModel();
517
518         ApexApiResult result = session.getApexModelEdited().deletePolicy(jsonbean.getName(), jsonbean.getVersion());
519
520         if (result.isOk()) {
521             result = session.getApexModelEdited().createPolicy(jsonbean.getName(), jsonbean.getVersion(),
522                 jsonbean.getTemplate(), jsonbean.getFirstState(), jsonbean.getUuid(), jsonbean.getDescription());
523
524             if (result.isOk()) {
525                 result = createPolicyContent(session, jsonbean);
526             }
527         }
528
529         session.finishSession(result.isOk());
530
531         LOGGER.exit("Policy/Update" + (result != null && result.isOk() ? OK : NOT_OK));
532         return result;
533
534     }
535
536     /**
537      * List policies with the given key names/versions. If successful the result(s)
538      * will be available in the result messages. The returned value(s) will be
539      * similar to {@link AxPolicy}, with merged {@linkplain AxKey Info} for the root
540      * object.
541      *
542      * @param session the Apex model editing session
543      * @param name    the name to search for. If null or empty, then all names will
544      *                be queried
545      * @param version the version to search for. If null then all versions will be
546      *                searched for.
547      * @return an ApexAPIResult object. If successful then
548      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
549      *         can be retrieved using {@link ApexApiResult#getMessages()}
550      */
551     private ApexApiResult listPolicies(final RestSession session, final String name, final String version) {
552         LOGGER.entry(name, version);
553
554         ApexApiResult result = session.getApexModel().listPolicy(blank2Null(name), blank2Null(version));
555
556         LOGGER.exit("Policy/Get" + (result != null && result.isOk() ? OK : NOT_OK));
557         return result;
558     }
559
560     /**
561      * Delete policies with the given key names/versions.
562      *
563      * @param session the Apex model editing session
564      * @param name    the name to search for. If null or empty, then all names will
565      *                be queried
566      * @param version the version to search for. If null then all versions will be
567      *                searched for.
568      * @return an ApexAPIResult object. If successful then
569      *         {@link ApexApiResult#isOk()} will return true. Any messages/errors
570      *         can be retrieved using {@link ApexApiResult#getMessages()}
571      */
572     private ApexApiResult deletePolicy(final RestSession session, final String name, final String version) {
573         LOGGER.entry(name, version);
574
575         session.editModel();
576
577         // all input/output fields, parameters, logic, context references is
578         // "owned"/contained
579         // in the task, so
580         // deleting the task removes all of these
581         ApexApiResult result = session.getApexModelEdited().deletePolicy(blank2Null(name), blank2Null(version));
582
583         session.finishSession(result.isOk());
584
585         LOGGER.exit("Policy/Delete" + (result != null && result.isOk() ? OK : NOT_OK));
586         return result;
587     }
588
589 }