@@ -0,0 +1,2141 @@
+/*******************************************************************************%0A * Mission Control Technologies, Copyright (c) 2009-2012, United States Government%0A * as represented by the Administrator of the National Aeronautics and Space %0A * Administration. All rights reserved.%0A *%0A * The MCT platform is licensed under the Apache License, Version 2.0 (the %0A * %22License%22); you may not use this file except in compliance with the License. %0A * You may obtain a copy of the License at %0A * http://www.apache.org/licenses/LICENSE-2.0.%0A *%0A * Unless required by applicable law or agreed to in writing, software %0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT %0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the %0A * License for the specific language governing permissions and limitations under %0A * the License.%0A *%0A * MCT includes source code licensed under additional open source licenses. See %0A * the MCT Open Source Licenses file included with this distribution or the About %0A * MCT Licenses dialog available at runtime from the MCT Help menu for additional %0A * information. %0A *******************************************************************************/%0Apackage gov.nasa.arc.mct.scenario.policy;%0A%0Aimport gov.nasa.arc.mct.components.AbstractComponent;%0Aimport gov.nasa.arc.mct.policy.ExecutionResult;%0Aimport gov.nasa.arc.mct.policy.Policy;%0Aimport gov.nasa.arc.mct.policy.PolicyContext;%0Aimport gov.nasa.arc.mct.scenario.component.RepositoryCapability;%0A%0A%0Apublic class RepositoryRemovalPolicy implements Policy %7B%0A%0A%09@Override%0A%09public ExecutionResult execute(PolicyContext context) %7B%0A%09%09AbstractComponent parentComponent = context.getProperty(%0A%09%09%09%09PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);%0A%0A%09%09String message = %22%22;%0A%09%09boolean allow = true;%0A%09%09%0A%09%09if (parentComponent != null) %7B%0A%09%09%09RepositoryCapability repo = parentComponent.getCapability(RepositoryCapability.class);%09%09%09%0A%09%09%09if (repo != null) %7B%0A%09%09%09%09allow = false;%0A%09%09%09%09message = %22Cannot remove objects from repository (can only delete)%22;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return new ExecutionResult(context, allow, message);%0A%09%7D%0A%7D%0A

Add policy to prevent Remove from repositories