diff options
Diffstat (limited to 'bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst')
28 files changed, 0 insertions, 3842 deletions
diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/DescriptorImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/DescriptorImpl.java deleted file mode 100644 index 324d372d2..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/DescriptorImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071030 196997 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import org.eclipse.wst.ws.service.policy.IDescriptor; - -public class DescriptorImpl implements IDescriptor -{ - private String shortName; - private String longName; - private String description; - private String iconPath; - private String iconBundleId; - private String contextHelpId; - private boolean hasChanged = false; - - public boolean hasChanged() - { - return hasChanged; - } - - public void resetHasChanged() - { - hasChanged = false; - } - - public String getShortName() - { - return shortName; - } - - public void setShortName(String name) - { - this.shortName = name; - - if( longName == null ) longName = shortName; - - hasChanged = true; - } - - public String getLongName() - { - return longName; - } - - public void setLongName(String longName) - { - this.longName = longName; - - if( shortName == null ) shortName = longName; - - hasChanged = true; - } - - public String getDescription() - { - return description; - } - - public void setDescription(String description) - { - this.description = description; - hasChanged = true; - } - - public String getIconPath() - { - return iconPath; - } - - public void setIconPath(String iconPath) - { - this.iconPath = iconPath; - hasChanged = true; - } - - public String getIconBundleId() - { - return iconBundleId; - } - - public void setIconBundleId(String iconBundleId) - { - this.iconBundleId = iconBundleId; - hasChanged = true; - } - - public String getContextHelpId() - { - return contextHelpId; - } - - public void setContextHelpId(String contextHelpId) - { - this.contextHelpId = contextHelpId; - hasChanged = true; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/EnumerationStateImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/EnumerationStateImpl.java deleted file mode 100644 index 43ec950b8..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/EnumerationStateImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080625 238482 pmoogk@ca.ibm.com - Peter Moogk, Adding thread safety to the service platform api. - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.List; - -import org.eclipse.wst.ws.service.policy.IPolicyState; -import org.eclipse.wst.ws.service.policy.IPolicyStateEnum; -import org.eclipse.wst.ws.service.policy.IStateEnumerationItem; -import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform; - -public class EnumerationStateImpl implements IPolicyStateEnum -{ - private final String VALUE = IPolicyState.DefaultValueKey; //$NON-NLS-1$ - - private String enumId; - private List<IStateEnumerationItem> enumList; - private IPolicyState state; - private String defaultId; - - public EnumerationStateImpl( ServicePolicyPlatform platform, String enumId, String defaultId, IPolicyState state ) - { - this.enumId = enumId; - this.enumList = platform.getStateEnumeration( enumId ); - this.state = state; - this.defaultId = enumList.get(0).getId(); - - if( defaultId != null ) - { - this.defaultId = defaultId; - state.putDefaultValue( VALUE, defaultId, false ); - } - else - { - for( IStateEnumerationItem enumItem : enumList ) - { - if( enumItem.isDefault() ) - { - this.defaultId = enumItem.getId(); - state.putDefaultValue( VALUE, this.defaultId, false ); - break; - } - } - } - } - - public String getEnumId() - { - return enumId; - } - - public String getDefaultId() - { - return defaultId; - } - - public void setCurrentItem( String itemId ) - { - for( IStateEnumerationItem enumItem : enumList ) - { - String enumItemId = enumItem.getId(); - - if( enumItemId.equals( itemId ) ) - { - state.putValue( VALUE, enumItemId ); - break; - } - } - } - - public IStateEnumerationItem getCurrentItem() - { - String currentEnum = state.getValue( VALUE ); - IStateEnumerationItem currentItem = null; - - for( IStateEnumerationItem enumItem : enumList ) - { - if( enumItem.getId().equals( currentEnum ) ) - { - currentItem = enumItem; - break; - } - } - - return currentItem; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/LocalUtils.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/LocalUtils.java deleted file mode 100644 index 75e7a4b97..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/LocalUtils.java +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071030 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080325 222095 pmoogk@ca.ibm.com - Peter Moogk - * 20080626 238635 pmoogk@ca.ibm.com - Peter Moogk, Locally added service policy nodes meta data coliding with state data. - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.Arrays; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.wst.ws.service.policy.IDescriptor; -import org.eclipse.wst.ws.service.policy.IPolicyEnumerationList; -import org.eclipse.wst.ws.service.policy.IPolicyRelationship; -import org.eclipse.wst.ws.service.policy.IServicePolicy; -import org.eclipse.wst.ws.service.policy.IStateEnumerationItem; -import org.eclipse.wst.ws.service.policy.PolicyEnumerationListImpl; -import org.eclipse.wst.ws.service.policy.PolicyRelationshipImpl; -import org.eclipse.wst.ws.service.policy.ServicePolicyActivator; -import org.osgi.service.prefs.BackingStoreException; - -public class LocalUtils -{ - private static final String BASE_KEY = "org.eclipse.wst.local."; //$NON-NLS-1$ - private static final String LOCAL_IDS_KEY = "localIds"; //$NON-NLS-1$ - private static final String PARENT_KEY = "parentId"; //$NON-NLS-1$ - private static final String MUTABLE_KEY = "mutable"; //$NON-NLS-1$ - private static final String DESCR_KEY = "description"; //$NON-NLS-1$ - private static final String LONGNAME_KEY = "longname"; //$NON-NLS-1$ - private static final String SHORTNAME_KEY = "shortname"; //$NON-NLS-1$ - private static final String ICONPATH_KEY = "iconpath"; //$NON-NLS-1$ - private static final String ICONBUND_KEY = "iconbundleid"; //$NON-NLS-1$ - private static final String HELPID_KEY = "contexthelpid"; //$NON-NLS-1$ - private static final String ENUMLIST_KEY = "enumlistid"; //$NON-NLS-1$ - private static final String DEFENUM_KEY = "defaultenumid"; //$NON-NLS-1$ - private static final String REL_KEY = "rel"; //$NON-NLS-1$ - private static final String TARGET_SUFFIX = ".target"; //$NON-NLS-1$ - private static final String SOURCE_SUFFIX = ".source"; //$NON-NLS-1$ - - public static List<String> getLocalPolicyIds() - { - List<String> result = new Vector<String>(); - IEclipsePreferences preferences = getPreferences(); - String key = BASE_KEY + LOCAL_IDS_KEY; - String idsValue = preferences.get( key , "" ); //$NON-NLS-1$ - - if( !idsValue.equals( "" ) ) //$NON-NLS-1$ - { - result = createStringList( idsValue ); - } - - return result; - } - - public static void saveLocalIds( List<String> localIds ) - { - IEclipsePreferences preferences = getPreferences(); - String key = BASE_KEY + LOCAL_IDS_KEY; - - if( localIds.size() > 0 ) - { - preferences.put( key, createSpaceDelimitedString( localIds ) ); - } - } - - public static void removeAllPreferencePolicies( String startsWith, IEclipsePreferences prefs ) - { - if( startsWith == null ) startsWith = BASE_KEY; - - try - { - IEclipsePreferences preferences = prefs == null ? getPreferences() : prefs; - String[] keys = preferences.keys(); - - for( String key : keys ) - { - if( key.startsWith( startsWith ) ) - { - preferences.remove( key ); - } - } - } - catch( BackingStoreException exc ) - { - ServicePolicyActivator.logError( "Error loading service policy local preferences.", exc); //$NON-NLS-1$ - } - } - - public static void saveLocalPolicy( ServicePolicyImpl policy ) - { - IEclipsePreferences preferences = getPreferences(); - String policyId = policy.getId(); - IDescriptor descriptor = policy.getDescriptor(); - IServicePolicy parent = policy.getParentPolicy(); - - save( preferences, policyId, PARENT_KEY, parent == null ? null : parent.getId() ); - save( preferences, policyId, MUTABLE_KEY, "" + policy.getPolicyState().isMutable() ); //$NON-NLS-1$ - save( preferences, policyId, ENUMLIST_KEY, policy.getEnumListId() ); - save( preferences, policyId, DEFENUM_KEY, policy.getDefaultEnumId() ); - save( preferences, policyId, DESCR_KEY, descriptor.getDescription() ); - save( preferences, policyId, SHORTNAME_KEY, descriptor.getShortName() ); - save( preferences, policyId, LONGNAME_KEY, descriptor.getLongName() ); - save( preferences, policyId, ICONPATH_KEY, descriptor.getIconPath() ); - save( preferences, policyId, ICONBUND_KEY, descriptor.getIconBundleId() ); - save( preferences, policyId, HELPID_KEY, descriptor.getContextHelpId() ); - saveRelationships( preferences, policyId, policy.getRelationships() ); - } - - public static void loadLocalPolicy( String policyId, ServicePolicyPlatformImpl platform ) - { - IEclipsePreferences preferences = getPreferences(); - ServicePolicyImpl policy = platform.getServicePolicy( policyId ); - DescriptorImpl descriptor = (DescriptorImpl)policy.getDescriptor(); - String parentId = preferences.get( createKey( policyId, PARENT_KEY), null ); - - if( parentId != null ) - { - IServicePolicy parentPolicy = platform.getServicePolicy( parentId ); - - policy.setParent( (ServicePolicyImpl)parentPolicy ); - } - - policy.getPolicyState().setMutable( preferences.getBoolean( createKey( policyId, MUTABLE_KEY), true ) ); - policy.setEnumListId( preferences.get( createKey( policyId, ENUMLIST_KEY), null ) ); - policy.setDefaultEnumId( preferences.get( createKey( policyId, DEFENUM_KEY), null ) ); - descriptor.setDescription( preferences.get( createKey( policyId, DESCR_KEY), null ) ); - descriptor.setShortName( preferences.get( createKey( policyId, SHORTNAME_KEY), null ) ); - descriptor.setLongName( preferences.get( createKey( policyId, LONGNAME_KEY), null ) ); - descriptor.setIconPath( preferences.get( createKey( policyId, ICONPATH_KEY), null ) ); - descriptor.setIconBundleId( preferences.get( createKey( policyId, ICONBUND_KEY), null ) ); - descriptor.setContextHelpId( preferences.get( createKey( policyId, HELPID_KEY), null ) ); - policy.setRelationships( loadRelationships( preferences, policyId, platform ) ); - } - - private static IEclipsePreferences getPreferences() - { - return new InstanceScope().getNode( ServicePolicyActivator.PLUGIN_ID ); - } - - private static List<String> createStringList( String spaceDelimitedString ) - { - String[] splitValues = spaceDelimitedString.split( " " ); //$NON-NLS-1$ - - return Arrays.asList( splitValues ); - } - - private static String createSpaceDelimitedString( List<String> stringList ) - { - StringBuffer buffer = new StringBuffer(); - - for( int index = 0; index < stringList.size(); index++ ) - { - String id = stringList.get( index ); - - buffer.append( id ); - - if( index < (stringList.size() - 1) ) buffer.append( ' ' ); - } - - return buffer.toString(); - } - - private static void saveRelationships( IEclipsePreferences preferences, String policyId, List<IPolicyRelationship> relationships ) - { - for( int index = 0; index < relationships.size(); index++ ) - { - IPolicyRelationship relationship = relationships.get( index ); - IPolicyEnumerationList policyList = relationship.getPolicyEnumerationList(); - List<IPolicyEnumerationList> targetPolicies = relationship.getRelatedPolicies(); - - savePolicyRelationship( index+1, preferences, policyId, policyList, SOURCE_SUFFIX ); - - for( int targetIndex = 0; targetIndex < targetPolicies.size(); targetIndex++ ) - { - IPolicyEnumerationList targetPolicy = targetPolicies.get( targetIndex ); - String targetSuffix = TARGET_SUFFIX + (targetIndex+1); - - savePolicyRelationship( index+1, preferences, policyId, targetPolicy, targetSuffix ); - } - } - } - - private static List<IPolicyRelationship> loadRelationships( IEclipsePreferences preferences, String policyId, ServicePolicyPlatformImpl platform ) - { - List<IPolicyRelationship> relationships = new Vector<IPolicyRelationship>(); - int relCount = 1; - IPolicyEnumerationList sourceList = loadPolicyRelationship( relCount, preferences, platform, policyId, SOURCE_SUFFIX ); - - while( sourceList != null ) - { - int targetCount = 1; - String targetSuffix = TARGET_SUFFIX + targetCount; - IPolicyEnumerationList targetList = loadPolicyRelationship( relCount, preferences, platform, policyId, targetSuffix ); - List<IPolicyEnumerationList> targets = new Vector<IPolicyEnumerationList>(); - - while( targetList != null ) - { - targets.add( targetList ); - targetCount++; - targetSuffix = TARGET_SUFFIX + targetCount; - targetList = loadPolicyRelationship( relCount, preferences, platform, policyId, targetSuffix ); - } - - relationships.add( new PolicyRelationshipImpl( sourceList, targets ) ); - relCount++; - sourceList = loadPolicyRelationship( relCount, preferences, platform, policyId, SOURCE_SUFFIX ); - } - - return relationships; - } - - private static void savePolicyRelationship( int relCount, - IEclipsePreferences preferences, - String policyId, - IPolicyEnumerationList enumList, - String keySuffix ) - { - String key = createKey( policyId, REL_KEY + relCount + keySuffix ); - String value = createRelationshipValue( enumList ); - - preferences.put( key, value ); - } - - private static IPolicyEnumerationList loadPolicyRelationship( int relCount, - IEclipsePreferences preferences, - ServicePolicyPlatformImpl platform, - String policyId, - String keySuffix ) - { - String key = createKey( policyId, REL_KEY + relCount + keySuffix ); - String value = preferences.get( key, "" ); //$NON-NLS-1$ - IPolicyEnumerationList enumList = null; - - if( !value.equals( "" ) ) //$NON-NLS-1$ - { - String[] splitValue = value.split( " " ); //$NON-NLS-1$ - String targetPolicyId = splitValue[0]; - IServicePolicy targetPolicy = platform.getServicePolicy( targetPolicyId ); - List<IStateEnumerationItem> items = new Vector<IStateEnumerationItem>(); - - for( int index = 1; index < splitValue.length; index++ ) - { - IStateEnumerationItem item = platform.getStateItemEnumeration( splitValue[index] ); - - items.add( item ); - } - - enumList = new PolicyEnumerationListImpl( items, targetPolicy ); - } - - return enumList; - } - - /** - * This method will create a space delimited string of enumerations id. - * The first id in the list will be the policy id for this relationship. - * Subsequent ids will be enumeration item ids. - * - * @param enumList - * @return - */ - private static String createRelationshipValue( IPolicyEnumerationList enumList ) - { - List<String> stringList = new Vector<String>(); - List<IStateEnumerationItem> itemList = enumList.getEnumerationList(); - - stringList.add( enumList.getPolicy().getId() ); - - for( IStateEnumerationItem item : itemList ) - { - stringList.add( item.getId() ); - } - - return createSpaceDelimitedString( stringList ); - } - - private static void save( IEclipsePreferences preferences, String policyId, String key, String value ) - { - if( value != null && !value.equals( "" ) ) //$NON-NLS-1$ - { - preferences.put( createKey(policyId,key), value ); - } - } - - private static String createKey( String id, String key ) - { - StringBuffer buffer = new StringBuffer(50); - - buffer.append( BASE_KEY ); - buffer.append( id ); - buffer.append( '.' ); - buffer.append( key ); - - return buffer.toString(); - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/PolicyStateImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/PolicyStateImpl.java deleted file mode 100644 index 35a581c63..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/PolicyStateImpl.java +++ /dev/null @@ -1,342 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20071221 213492 pmoogk@ca.ibm.com - Peter Moogk - * 20080109 214818 pmoogk@ca.ibm.com - Peter Moogk - * 20080325 222095 pmoogk@ca.ibm.com - Peter Moogk - * 20080430 221578 pmoogk@ca.ibm.com - Peter Moogk, Fixed commit problem. - * 20080625 238482 pmoogk@ca.ibm.com - Peter Moogk, Adding thread safety to the service platform api. - * 20090327 270283 mahutch@ca.ibm.com - Mark Hutchinson, IPolicyStateChangeListener not notified first time change is made - * 20090514 276329 ericdp@ca.ibm.com - Eric D. Peters, Service Policy platform regression, causing NPE for listeners - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ProjectScope; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IPreferencesService; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.wst.ws.service.policy.IPolicyState; -import org.eclipse.wst.ws.service.policy.IServicePolicy; -import org.eclipse.wst.ws.service.policy.ServicePolicyActivator; -import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyStateChangeListener; - -public class PolicyStateImpl implements IPolicyState -{ - private List<IPolicyStateChangeListener> stateChangeListeners; - private List<IPolicyStateChangeListener> stateChangeListenersOnlyOnCommit; - private IPreferencesService service; - private IProject project; - private boolean mutable; - private IServicePolicy policy; - private Map<String,TableEntry> table; - private ServicePolicyPlatform platform; - - public PolicyStateImpl( ServicePolicyPlatform platform, IServicePolicy policy, IProject project) - { - this.service = Platform.getPreferencesService(); - this.platform = platform; - this.project = project; - this.policy = policy; - this.mutable = policy.isPredefined() ? false : true; - this.table = new HashMap<String, TableEntry>(); - } - - public void commitChanges() - { - // We don't do anything if this policy is not mutable. - if( !mutable ) return; - - IEclipsePreferences preferences = null; - - if( project == null ) - { - preferences = new InstanceScope().getNode( ServicePolicyActivator.PLUGIN_ID ); - } - else - { - preferences = new ProjectScope( project ).getNode( ServicePolicyActivator.PLUGIN_ID ); - } - - for( Map.Entry<String, TableEntry> entry : table.entrySet() ) - { - String key = entry.getKey(); - String storeKey = makeStoreKey( key ); - TableEntry tableEntry = entry.getValue(); - String value = tableEntry.value; - - if( value != null ) - { - String oldValue = tableEntry.lastCommittedValue; - - // Always need to put the value in the backing store even if it is the same value - // since we delete all preferences before committing them. - preferences.put( storeKey, value ); - tableEntry.lastCommittedValue = value; - - if( oldValue == null ) - { - //if the old value is null, and the new value is not null, need to fire a change - firePolicyStateChange( stateChangeListenersOnlyOnCommit, key, oldValue, value ); - - // Temporarily remove the tableEntry value so that getValue will get the old value. - tableEntry.value = null; - oldValue = getValue( key ); - - // Restore the tableEntry value; - tableEntry.value = value; - } - - if( !value.equals( oldValue ) ) - { - firePolicyStateChange( stateChangeListenersOnlyOnCommit, key, oldValue, value ); - } - } - } - } - - private IEclipsePreferences[] getNodes() - { - IEclipsePreferences[] result = null; - - if( project != null && platform.isProjectPreferencesEnabled(project) ) - { - result = new IEclipsePreferences[2]; - result[0] = new ProjectScope( project ).getNode( ServicePolicyActivator.PLUGIN_ID ); - result[1] = new InstanceScope().getNode( ServicePolicyActivator.PLUGIN_ID ); - } - else - { - result = new IEclipsePreferences[1]; - result[0] = new InstanceScope().getNode( ServicePolicyActivator.PLUGIN_ID ); - } - - return result; - } - - public void discardChanges() - { - if( !mutable ) return; - - for( TableEntry entry : table.values() ) - { - entry.value = null; - } - } - - public void restoreDefaults() - { - // We want to restore the setting to there default state, but we don't - // want change the backend eclipse preferences, since the user might not - // commit these changes. Therefore, we will set the values for all the - // table entries to their default value. - if( project == null ) - { - for( TableEntry entry : table.values() ) - { - entry.value = entry.defaultValue; - } - } - else - { - // Note: since we are restoring the state for a project we need to ensure - // that only the instance scope values are used. (ie. we want to - // ignore project scope values.) - IEclipsePreferences[] nodes = new IEclipsePreferences[]{new InstanceScope().getNode( ServicePolicyActivator.PLUGIN_ID )}; - - for( Map.Entry<String,TableEntry> entry : table.entrySet() ) - { - String storeKey = makeStoreKey( entry.getKey() ); - TableEntry tableEntry = entry.getValue(); - String defaultValue = ""; - - if( tableEntry.defaultValue != null ) - { - defaultValue = tableEntry.defaultValue; - } - - tableEntry.value = service.get( storeKey, defaultValue, nodes ); - } - } - - } - - /** - * The method gets the value from the following places in the given order. - * - * 1) From the local table. - * 2) From the preference store nodes. Note: this could include searching - * the project preference store and the plugin preference store. - * 3) From the default in the local table. - */ - public String getValue(String key) - { - String result = null; - TableEntry entry = table.get( key ); - - if( entry == null ) - { - entry = new TableEntry(); - table.put( key, entry ); - } - - if( project == null || - ( project != null && platform.isProjectPreferencesEnabled( project ) ) ) - { - result = entry.value; - } - - if( result == null ) - { - // We don't have a local value for this key so we will look in the - // preference store. - String defaultValue = ""; //$NON-NLS-1$ - String storeKey = makeStoreKey( key ); - - if( entry.defaultValue != null ) - { - defaultValue = entry.defaultValue; - } - - result = service.get( storeKey, defaultValue, getNodes() ); - } - - return result; - } - - private String makeStoreKey( String key ) - { - return policy.getId() + "." + key; //$NON-NLS-1$ - } - - public boolean isMutable() - { - return mutable; - } - - public void putDefaultValue( String key, String defaultValue, boolean overrideExisting ) - { - if( !mutable ) return; - - TableEntry entry = table.get( key ); - - if( entry == null ) - { - entry = new TableEntry(); - table.put( key, entry ); - } - - if( entry.defaultValue == null || overrideExisting ) - { - entry.defaultValue = defaultValue; - } - - } - - public void putValue(String key, String value) - { - if( !mutable ) return; - - TableEntry entry = table.get( key ); - - if( entry == null ) - { - entry = new TableEntry(); - table.put( key, entry ); - } - - String oldValue = getValue( key ); - - entry.value = value; - firePolicyStateChange( stateChangeListeners, key, oldValue, value ); - } - - public void internalSetMutable( boolean mutable ) - { - this.mutable = mutable; - } - - public void setMutable(boolean mutable) - { - if( policy.isPredefined() ) - { - ServicePolicyActivator.logError( "Attempt to set mutability on a predefined service policy.", null ); //$NON-NLS-1$ - } - else - { - this.mutable = mutable; - } - } - - public void addPolicyStateChangeListener(IPolicyStateChangeListener listener, boolean notifyOnCommitOnly ) - { - if( notifyOnCommitOnly ) - { - if( stateChangeListenersOnlyOnCommit == null ) - { - stateChangeListenersOnlyOnCommit = new Vector<IPolicyStateChangeListener>(); - } - - stateChangeListenersOnlyOnCommit.add( listener ); - } - else - { - if( stateChangeListeners == null ) - { - stateChangeListeners = new Vector<IPolicyStateChangeListener>(); - } - - stateChangeListeners.add( listener ); - } - } - - public void removePolicyStateChangeListener(IPolicyStateChangeListener listener) - { - if( stateChangeListeners != null ) - { - stateChangeListeners.remove( listener ); - } - - if( stateChangeListenersOnlyOnCommit != null ) - { - stateChangeListenersOnlyOnCommit.remove( listener ); - } - } - - private void firePolicyStateChange( List<IPolicyStateChangeListener> listeners, - String key, - String oldValue, - String newValue ) - { - if( listeners != null ) - { - for( IPolicyStateChangeListener listener : listeners ) - { - listener.policyStateChange( policy, key, oldValue, newValue ); - } - } - } - - private class TableEntry - { - String value; - String lastCommittedValue; - String defaultValue; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyImpl.java deleted file mode 100644 index 54e467351..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyImpl.java +++ /dev/null @@ -1,430 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080214 218996 pmoogk@ca.ibm.com - Peter Moogk, Concurrent exception fix - * 20080625 238482 pmoogk@ca.ibm.com - Peter Moogk, Adding thread safety to the service platform api. - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.ws.service.policy.IDescriptor; -import org.eclipse.wst.ws.service.policy.IPolicyEnumerationList; -import org.eclipse.wst.ws.service.policy.IPolicyRelationship; -import org.eclipse.wst.ws.service.policy.IPolicyState; -import org.eclipse.wst.ws.service.policy.IPolicyStateEnum; -import org.eclipse.wst.ws.service.policy.IServicePolicy; -import org.eclipse.wst.ws.service.policy.IStateEnumerationItem; -import org.eclipse.wst.ws.service.policy.PolicyEnumerationListImpl; -import org.eclipse.wst.ws.service.policy.PolicyRelationshipImpl; -import org.eclipse.wst.ws.service.policy.ServicePolicyActivator; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyChildChangeListener; -import org.eclipse.wst.ws.service.policy.listeners.IStatusChangeListener; - -public class ServicePolicyImpl implements IServicePolicy -{ - private boolean predefined; - private String id; - private ServicePolicyImpl parent; - private DescriptorImpl descriptor; - private List<IServicePolicy> committedChildren; - private List<IServicePolicy> children; - private PolicyStateImpl policyState; - private Map<IProject, PolicyStateImpl> projectPolicyStates; - private List<IPolicyRelationship> relationshipList; - private List<IPolicyChildChangeListener> childChangeListeners; - private ServicePolicyPlatformImpl platform; - private String enumListId; - private String defaultEnumId; - private List<IStatusChangeListener> statusChangeListeners; - private IStatus status; - - private String unresolvedParent; - private List<UnresolvedRelationship> unresolvedRelationshipList; - - public ServicePolicyImpl( boolean isPredefined, String id, ServicePolicyPlatformImpl platform ) - { - this.predefined = isPredefined; - this.id = id; - this.children = new Vector<IServicePolicy>(); - this.relationshipList = new Vector<IPolicyRelationship>(); - this.unresolvedRelationshipList = new Vector<UnresolvedRelationship>(); - this.policyState = new PolicyStateImpl( platform.getApiPlatform(), this, null ); - this.platform = platform; - this.childChangeListeners = new Vector<IPolicyChildChangeListener>(); - this.projectPolicyStates = new HashMap<IProject, PolicyStateImpl>(); - this.status = Status.OK_STATUS; - } - - public boolean isPredefined() - { - return predefined; - } - - public String getId() - { - return id; - } - - public void setParent( ServicePolicyImpl parent ) - { - this.parent = parent; - - if( parent != null ) - { - parent.addChild( this, false ); - } - } - - public void commitChanges() - { - policyState.commitChanges(); - - // Make a copy of the children in the committedChildren object. - committedChildren = new Vector<IServicePolicy>( children ); - } - - public void discardChanges() - { - policyState.discardChanges(); - - fireChildChangesDuetoDiscard(); - - //Restore children. - children = new Vector<IServicePolicy>( committedChildren ); - } - - public List<IServicePolicy> getChildren() - { - return children; - } - - private void addChild( ServicePolicyImpl child, boolean fireEvent ) - { - children.add( child ); - - if( fireEvent ) - { - fireChildChangeEvent( child, true ); - } - } - - public void removeChild(IServicePolicy policyToRemove ) - { - if( !policyToRemove.isPredefined() ) - { - // Remove all the children of this policy first. - List<IServicePolicy> childPolicies = new Vector<IServicePolicy>( policyToRemove .getChildren() ); - - for( IServicePolicy childPolicy : childPolicies ) - { - policyToRemove.removeChild( childPolicy ); - } - - boolean removed = children.remove( policyToRemove ); - - if( removed ) - { - platform.removePolicy( policyToRemove ); - fireChildChangeEvent( policyToRemove , false ); - } - } - } - - public IDescriptor getDescriptor() - { - if( descriptor == null ) - { - descriptor = new DescriptorImpl(); - } - - return descriptor; - } - - public void setDescriptor( DescriptorImpl descriptor ) - { - this.descriptor = descriptor; - } - - public IServicePolicy getParentPolicy() - { - return parent; - } - - public IPolicyState getPolicyState() - { - return policyState; - } - - public IPolicyState getPolicyState( IProject project ) - { - PolicyStateImpl projectPolicyState = projectPolicyStates.get( project ); - - if( projectPolicyState == null ) - { - projectPolicyState = new PolicyStateImpl( platform.getApiPlatform(), this, project ); - projectPolicyState.internalSetMutable( policyState.isMutable() ); - projectPolicyStates.put( project, projectPolicyState ); - } - - return projectPolicyState; - } - - public IPolicyStateEnum getPolicyStateEnum() - { - EnumerationStateImpl newEnum = null; - - if( enumListId != null ) - { - newEnum = new EnumerationStateImpl( platform.getApiPlatform(), enumListId, defaultEnumId, policyState ); - } - - return newEnum; - } - - public IPolicyStateEnum getPolicyStateEnum( IProject project ) - { - EnumerationStateImpl newEnum = null; - - if( enumListId != null ) - { - newEnum = new EnumerationStateImpl( platform.getApiPlatform(), enumListId, defaultEnumId, getPolicyState( project ) ); - } - - return newEnum; - } - - public void setPolicyState( PolicyStateImpl policyState ) - { - this.policyState = policyState; - } - - public void restoreDefaults() - { - // Remove all local children from the tree - // Java will not let you remove an item from a collection - // that is being iterated over, so we need to create a temporary - // copy of the children collection to iterator over. - Vector<IServicePolicy> tempChildren = new Vector<IServicePolicy>( children ); - - for( IServicePolicy child : tempChildren ) - { - if( !child.isPredefined() ) - { - removeChild( child ); - } - } - - policyState.restoreDefaults(); - } - - public void restoreDefaults( IProject project ) - { - PolicyStateImpl stateImpl = projectPolicyStates.get( project ); - - if( stateImpl != null ) - { - stateImpl.restoreDefaults(); - } - } - - - public List<IPolicyRelationship> getRelationships() - { - return relationshipList; - } - - public void setRelationships(List<IPolicyRelationship> relationships) - { - if( !predefined ) - { - this.relationshipList = relationships; - } - } - - public String getEnumListId() - { - return enumListId; - } - - public void setEnumListId(String enumListId) - { - this.enumListId = enumListId; - } - - public String getDefaultEnumId() - { - return defaultEnumId; - } - - public void setDefaultEnumId(String defaultEnumValue) - { - this.defaultEnumId = defaultEnumValue; - } - - public void setUnresolvedParent( String parentId ) - { - unresolvedParent = parentId; - } - - public void setUnresolvedRelationships( List<UnresolvedRelationship> relationships ) - { - unresolvedRelationshipList = relationships; - } - - public void resolve() - { - setParent( platform.getServicePolicy( unresolvedParent ) ); - - for( UnresolvedRelationship relationship : unresolvedRelationshipList ) - { - List<String> sourceEnumIdList = relationship.getSourceEnumerationList(); - List<UnresolvedPolicyRelationship> targetEnumIdList = relationship.getTargetEnumerationList(); - List<IStateEnumerationItem> sourceEnumList = getResolvedEnumList( sourceEnumIdList ); - IPolicyEnumerationList sourcePolicyList = new PolicyEnumerationListImpl( sourceEnumList, this ); - List<IPolicyEnumerationList> targetPolicyList = new Vector<IPolicyEnumerationList>(); - - for( UnresolvedPolicyRelationship targetEnum : targetEnumIdList ) - { - IServicePolicy targetPolicy = platform.getServicePolicy( targetEnum.getPolicyId() ); - List<IStateEnumerationItem> targetList = getResolvedEnumList( targetEnum.getEnumList()); - IPolicyEnumerationList targetEnumPolicyList = new PolicyEnumerationListImpl( targetList, targetPolicy ); - - targetPolicyList.add( targetEnumPolicyList ); - - if( targetPolicy == null ) - { - ServicePolicyActivator.logError( "Policy id, " + targetEnum.getPolicyId() + " not found.", null ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - IPolicyRelationship policyRelationship = new PolicyRelationshipImpl( sourcePolicyList, targetPolicyList ); - - relationshipList.add( policyRelationship ); - } - - unresolvedParent = null; - unresolvedRelationshipList = null; - } - - private List<IStateEnumerationItem> getResolvedEnumList( List<String> enumIdList ) - { - List<IStateEnumerationItem> enumList = new Vector<IStateEnumerationItem>(); - - for( String enumId : enumIdList ) - { - enumList.add( platform.getStateItemEnumeration( enumId ) ); - } - - return enumList; - } - - public void addPolicyChildChangeListener(IPolicyChildChangeListener listener) - { - childChangeListeners.add( listener ); - } - - public void removePolicyChildChangeListener(IPolicyChildChangeListener listener) - { - childChangeListeners.remove( listener ); - } - - public void addStatusChangeListener( IStatusChangeListener listener ) - { - if( statusChangeListeners == null ) - { - statusChangeListeners = new Vector<IStatusChangeListener>(); - } - - statusChangeListeners.add( listener ); - } - - public void removeStatusChangeListener( IStatusChangeListener listener ) - { - if( statusChangeListeners != null ) - { - statusChangeListeners.remove( listener ); - } - } - - public IStatus getStatus() - { - return status; - } - - public void setStatus( IStatus status ) - { - IStatus oldStatus = this.status; - this.status = status; - fireStatusChangeEvent( oldStatus, status ); - } - - private void fireStatusChangeEvent( IStatus oldStatus, IStatus newStatus ) - { - if( statusChangeListeners != null ) - { - for( IStatusChangeListener listener : statusChangeListeners ) - { - listener.statusChange( this, oldStatus, newStatus); - } - } - } - - private void fireChildChangesDuetoDiscard() - { - Set<IServicePolicy> childSet = new HashSet<IServicePolicy>( children ); - Set<IServicePolicy> committedChildSet = new HashSet<IServicePolicy>( committedChildren ); - - for( IServicePolicy child : childSet ) - { - if( committedChildSet.contains( child ) ) - { - committedChildSet.remove( child ); - } - else - { - // A child was added and is now being deleted by the discard. - fireChildChangeEvent( child, false ); - platform.fireChildChangeEvent( child, false ); - } - } - - // Any children left in the committed set must have been deleted and are now - // being added back due to the discard. - for( IServicePolicy child : committedChildSet ) - { - fireChildChangeEvent( child, true ); - platform.fireChildChangeEvent( child, true ); - } - } - - private void fireChildChangeEvent( IServicePolicy policy, boolean isAdd ) - { - for( IPolicyChildChangeListener listener : childChangeListeners ) - { - List<IServicePolicy> policyList = new Vector<IServicePolicy>(1); - List<Boolean> addedList = new Vector<Boolean>(1); - - policyList.add( policy ); - addedList.add( isAdd ); - listener.childChange( policyList, addedList ); - } - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyPlatformImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyPlatformImpl.java deleted file mode 100644 index 4d257fd16..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyPlatformImpl.java +++ /dev/null @@ -1,583 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20071113 209701 pmoogk@ca.ibm.com - Peter Moogk - * 20080111 214907 pmoogk@ca.ibm.com - Peter Moogk - * 20080214 218996 pmoogk@ca.ibm.com - Peter Moogk, Concurrent exception fix - * 20080325 222095 pmoogk@ca.ibm.com - Peter Moogk - * 20080625 238482 pmoogk@ca.ibm.com - Peter Moogk, Adding thread safety to the service platform api. - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.expressions.EvaluationContext; -import org.eclipse.core.expressions.EvaluationResult; -import org.eclipse.core.expressions.Expression; -import org.eclipse.core.expressions.IEvaluationContext; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ProjectScope; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.wst.ws.service.policy.IFilter; -import org.eclipse.wst.ws.service.policy.IServicePolicy; -import org.eclipse.wst.ws.service.policy.IStateEnumerationItem; -import org.eclipse.wst.ws.service.policy.ServicePolicyActivator; -import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyChildChangeListener; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyPlatformLoadListener; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyPlatformProjectLoadListener; -import org.osgi.service.prefs.BackingStoreException; - - -public class ServicePolicyPlatformImpl -{ - private List<IPolicyPlatformLoadListener> loadListeners; - private Map<String, ServicePolicyImpl> committedPolicyMap; - private Map<String, ServicePolicyImpl> policyMap; - private Map<String, List<IStateEnumerationItem>> enumList; - private Map<String, StateEnumerationItemImpl> enumItemList; - private Map<IProject, ProjectEntry> enabledProjectMap; - private List<Expression> enabledList; - private List<IPolicyChildChangeListener> childChangeListeners; - private List<IPolicyChildChangeListener> childChangeListenersOnCommit; - private List<IServicePolicy> commitChildChangePolicy; - private List<Boolean> commitChildChangeAdded; - private List<IServicePolicy> queuedChildChangePolicy; - private List<Boolean> queuedChildChangeAdded; - private List<IPolicyPlatformProjectLoadListener> projectPlatformListeners; - private ServicePolicyPlatform apiPlatform; - - public ServicePolicyPlatformImpl( ServicePolicyPlatform platform ) - { - apiPlatform = platform; - } - - public void load() - { - ServicePolicyRegistry registry = new ServicePolicyRegistry( this ); - List<String> localIds = LocalUtils.getLocalPolicyIds(); - - loadListeners = new Vector<IPolicyPlatformLoadListener>(); - policyMap = new HashMap<String, ServicePolicyImpl>(); - enumList = new HashMap<String, List<IStateEnumerationItem>>(); - enumItemList = new HashMap<String, StateEnumerationItemImpl>(); - enabledProjectMap = new HashMap<IProject, ProjectEntry>(); - enabledList = new Vector<Expression>(); - - childChangeListeners = new Vector<IPolicyChildChangeListener>(); - childChangeListenersOnCommit = new Vector<IPolicyChildChangeListener>(); - commitChildChangePolicy = new Vector<IServicePolicy>(); - commitChildChangeAdded = new Vector<Boolean>(); - projectPlatformListeners = new Vector<IPolicyPlatformProjectLoadListener>(); - - registry.load( loadListeners, policyMap, enumList, enumItemList ); - - // This first loop through the ids will only create service policy objects - // without populating them with there values. - for( String localPolicyId : localIds ) - { - ServicePolicyImpl localPolicy = new ServicePolicyImpl( false, localPolicyId, this ); - - policyMap.put( localPolicyId, localPolicy ); - } - - // This second loop will populate the service policy values and - // crossreference parent and child service policies. - for( String localPolicyId : localIds ) - { - LocalUtils.loadLocalPolicy( localPolicyId, this ); - } - } - - public void callLoadListeners() - { - for( IPolicyPlatformLoadListener loadListener : loadListeners ) - { - try - { - loadListener.load(); - } - catch( Exception exc ) - { - ServicePolicyActivator.logError( "Error in load listener:" + loadListener.getClass().getName(), exc ); //$NON-NLS-1$ - } - } - - commitChanges( false ); - - // Commit any project level changes that have been made by load listeners. - for( IProject project : enabledProjectMap.keySet() ) - { - commitChanges( project ); - } - } - - public ServicePolicyPlatform getApiPlatform() - { - return apiPlatform; - } - - public void addEnabledExpression( Expression expression ) - { - if( expression != null ) - { - enabledList.add( expression ); - } - } - - public boolean isEnabled( Object object ) - { - boolean result = false; - IEvaluationContext context = new EvaluationContext( null, object ); - context.addVariable( "selection", object ); //$NON-NLS-1$ - context.setAllowPluginActivation( true ); - - for( Expression enabledItem : enabledList ) - { - try - { - EvaluationResult expResult = enabledItem.evaluate( context ); - - // If any expression returns TRUE or NOT_LOADED we will return true as - // the result. - if( expResult != EvaluationResult.FALSE ) - { - result = true; - break; - } - } - catch( CoreException exc ) - { - // Ignore the expression if an exception occurs. - ServicePolicyActivator.logError( "Error evaluating enablement expression.", exc ); //$NON-NLS-1$ - } - } - - return result; - } - - public void commitChanges( boolean saveLocals ) - { - List<String> localIds = new Vector<String>(); - - if( saveLocals ) LocalUtils.removeAllPreferencePolicies( null, null ); - - // Fire child change events for commit listeners - for( IPolicyChildChangeListener listener : childChangeListenersOnCommit ) - { - listener.childChange( commitChildChangePolicy, commitChildChangeAdded ); - } - - removeDeletedPreferenceData(); - - commitChildChangePolicy = new Vector<IServicePolicy>(); - commitChildChangeAdded = new Vector<Boolean>(); - - for( ServicePolicyImpl policy : policyMap.values() ) - { - policy.commitChanges(); - - if( saveLocals && !policy.isPredefined() ) - { - LocalUtils.saveLocalPolicy( policy ); - localIds.add( policy.getId() ); - } - } - - if( saveLocals ) LocalUtils.saveLocalIds( localIds ); - - committedPolicyMap = new HashMap<String, ServicePolicyImpl>(); - committedPolicyMap.putAll( policyMap ); - ServicePolicyActivator.getDefault().savePluginPreferences(); - } - - private void removeDeletedPreferenceData() - { - for( int index = 0; index < commitChildChangePolicy.size(); index++ ) - { - IServicePolicy policy = commitChildChangePolicy.get( index ); - boolean added = commitChildChangeAdded.get( index ); - - if( !added ) - { - // Add policy is being deleted. We need to remove any state data - // for this policy at the workspace level and the project level. - LocalUtils.removeAllPreferencePolicies( policy.getId(), null ); - - for( IProject proj : enabledProjectMap.keySet() ) - { - if( proj.exists() && proj.isOpen() ) - { - IEclipsePreferences projPrefs = new ProjectScope( proj ).getNode( ServicePolicyActivator.PLUGIN_ID ); - LocalUtils.removeAllPreferencePolicies( policy.getId(), projPrefs ); - - try - { - projPrefs.flush(); - } - catch( BackingStoreException exc ) - { - ServicePolicyActivator.logError( "Error flushing project properties.", exc ); //$NON-NLS-1$ - } - } - } - } - } - } - - /** - * This method is called internally to remove a service policy. - * - * @param policy - */ - public void removePolicy( IServicePolicy policy ) - { - policyMap.remove( policy.getId() ); - fireChildChangeEvent( policy, false ); - } - - /** - * This method is only called from the platform API - * - * @param policy - */ - public void removePlatformPolicy( IServicePolicy policy ) - { - if( policy.isPredefined() ) return; - - IServicePolicy parent = policy.getParentPolicy(); - - if( parent == null ) - { - // Remove any children first - List<IServicePolicy> children = new Vector<IServicePolicy>( policy.getChildren() ); - - for( IServicePolicy child : children ) - { - policy.removeChild( child ); - } - - removePolicy( (ServicePolicyImpl)policy); - } - else - { - parent.removeChild( policy ); - } - } - - public void addChildChangeListener( IPolicyChildChangeListener listener, boolean onCommit ) - { - if( onCommit ) - { - childChangeListenersOnCommit.add( listener ); - } - else - { - childChangeListeners.add( listener ); - } - } - - public void removeChildChangeListener( IPolicyChildChangeListener listener, boolean onCommit ) - { - if( onCommit ) - { - childChangeListenersOnCommit.remove( listener ); - } - else - { - childChangeListeners.remove( listener ); - } - } - - public void queueChildChangeListeners( boolean queue ) - { - if( queue && queuedChildChangeAdded == null ) - { - queuedChildChangeAdded = new Vector<Boolean>(); - queuedChildChangePolicy = new Vector<IServicePolicy>(); - } - else if( !queue && queuedChildChangeAdded != null ) - { - // Queuing has been turned off so we will fire all the queued events. - for( IPolicyChildChangeListener listener : childChangeListeners ) - { - listener.childChange( queuedChildChangePolicy, queuedChildChangeAdded ); - } - - queuedChildChangeAdded = null; - queuedChildChangePolicy = null; - } - } - - public void fireChildChangeEvent( IServicePolicy policy, boolean isAdd ) - { - if( queuedChildChangeAdded == null ) - { - List<IServicePolicy> policyList = new Vector<IServicePolicy>(1); - List<Boolean> addedList = new Vector<Boolean>(1); - - policyList.add( policy ); - addedList.add( isAdd ); - - for( IPolicyChildChangeListener listener : childChangeListeners ) - { - listener.childChange( policyList, addedList ); - } - } - else - { - queuedChildChangeAdded.add( isAdd ); - queuedChildChangePolicy.add( policy ); - } - - commitChildChangeAdded.add( isAdd ); - commitChildChangePolicy.add( policy ); - } - - public void commitChanges( IProject project ) - { - for( ServicePolicyImpl policy : policyMap.values() ) - { - ((PolicyStateImpl)policy.getPolicyState( project )).commitChanges(); - } - - ProjectEntry entry = getProjectEntry( project ); - - entry.isEnabledCommitted = entry.isEnabled; - setProjectEnabled( project, entry.isEnabledCommitted ); - - try - { - IEclipsePreferences projectPrefs = new ProjectScope( project ).getNode( ServicePolicyActivator.PLUGIN_ID ); - - projectPrefs.flush(); - } - catch( BackingStoreException exc ) - { - ServicePolicyActivator.logError( "Error while committing project preferences.", exc ); //$NON-NLS-1$ - } - - } - - public void discardChanges() - { - policyMap = new HashMap<String, ServicePolicyImpl>(); - policyMap.putAll( committedPolicyMap ); - - commitChildChangePolicy = new Vector<IServicePolicy>(); - commitChildChangeAdded = new Vector<Boolean>(); - - for( ServicePolicyImpl policy : committedPolicyMap.values() ) - { - policy.discardChanges(); - } - } - - public void discardChanges( IProject project ) - { - for( ServicePolicyImpl policy : policyMap.values() ) - { - ((PolicyStateImpl)policy.getPolicyState( project )).discardChanges(); - } - - ProjectEntry entry = getProjectEntry( project ); - - entry.isEnabled = entry.isEnabledCommitted; - } - - public void restoreDefaults() - { - Vector<ServicePolicyImpl> tempPolicyValues - = new Vector<ServicePolicyImpl>( policyMap.values() ); - - for( ServicePolicyImpl policy : tempPolicyValues ) - { - policy.restoreDefaults(); - } - } - - public void restoreDefaults( IProject project ) - { - for( ServicePolicyImpl policy : policyMap.values() ) - { - policy.restoreDefaults( project ); - } - } - - public Set<String> getAllPolicyIds() - { - return policyMap.keySet(); - } - - public List<IServicePolicy> getRootServicePolicies( IFilter filter ) - { - List<IServicePolicy> rootPolicies = new Vector<IServicePolicy>(); - - for( String policyId : policyMap.keySet() ) - { - ServicePolicyImpl policy = policyMap.get( policyId ); - - if( policy.getParentPolicy() == null ) - { - if( filter == null || (filter != null && filter.accept( policy )) ) - { - rootPolicies.add( policy ); - } - } - } - - return rootPolicies; - } - - public ServicePolicyImpl createServicePolicy( IServicePolicy parent, - String id, - String enumListId, - String defaultEnumId ) - { - if( id == null ) id = "org.eclipse.wst.ws.service.policy.id"; //$NON-NLS-1$ - - String uniqueId = makeUniqueId( id ); - ServicePolicyImpl policy = new ServicePolicyImpl( false, uniqueId, this ); - - policy.setParent( (ServicePolicyImpl)parent ); - policy.setEnumListId( enumListId ); - policy.setDefaultEnumId( defaultEnumId ); - policyMap.put( uniqueId, policy ); - fireChildChangeEvent( policy, true ); - - return policy; - } - - public ServicePolicyImpl getServicePolicy( String id ) - { - return id == null ? null : policyMap.get( id ); - } - - public List<IStateEnumerationItem> getStateEnumeration( String enumId ) - { - return enumList.get( enumId ); - } - - public IStateEnumerationItem getStateItemEnumeration( String stateItemId ) - { - return enumItemList.get( stateItemId ); - } - - public boolean isProjectPreferencesEnabled( IProject project ) - { - ProjectEntry entry = getProjectEntry( project ); - - return entry.isEnabled; - } - - private boolean getProjectPreferenceEnabled( IProject project ) - { - String pluginId = ServicePolicyActivator.PLUGIN_ID; - IEclipsePreferences projectPreference = new ProjectScope( project ).getNode( pluginId ); - String key = pluginId + ".projectEnabled"; //$NON-NLS-1$ - - return projectPreference.getBoolean( key, false ); - } - - public void setProjectPreferencesEnabled( IProject project, boolean value ) - { - ProjectEntry entry = getProjectEntry( project ); - - entry.isEnabled = value; - } - - /** - * Add a project platform listener. When a particular project is referenced - * by in the service policy platform this listener will be called the first - * time the project is loaded into the system. - * - * @param listener the listener - */ - public void addProjectLoadListener( IPolicyPlatformProjectLoadListener listener ) - { - projectPlatformListeners.add( listener ); - } - - /** - * Removes a project platform listener. - * - * @param listener the listener - */ - public void removeProjectLoadListener( IPolicyPlatformProjectLoadListener listener ) - { - projectPlatformListeners.remove( listener ); - } - - private void setProjectEnabled( IProject project, boolean value ) - { - String pluginId = ServicePolicyActivator.PLUGIN_ID; - IEclipsePreferences projectPreference = new ProjectScope( project ).getNode( pluginId ); - String key = pluginId + ".projectEnabled"; //$NON-NLS-1$ - - projectPreference.putBoolean( key, value ); - } - - private ProjectEntry getProjectEntry( IProject project ) - { - ProjectEntry entry = enabledProjectMap.get( project ); - - if( entry == null ) - { - entry = new ProjectEntry(); - enabledProjectMap.put( project, entry ); - entry.isEnabledCommitted = getProjectPreferenceEnabled( project ); - entry.isEnabled = entry.isEnabledCommitted; - fireProjectLoadListener( project ); - } - - return entry; - } - - private void fireProjectLoadListener( IProject project ) - { - for( IPolicyPlatformProjectLoadListener listener : projectPlatformListeners ) - { - listener.load( project ); - } - } - - private String makeUniqueId( String id ) - { - String result = id; - int idCount = 1; - Pattern pattern = Pattern.compile( "\\d*$" ); // Match any numerical digits at the end //$NON-NLS-1$ - // of the string. - - while( policyMap.containsKey( result ) ) - { - Matcher matcher = pattern.matcher( result ); - - result = matcher.replaceFirst( "" ) + idCount; //$NON-NLS-1$ - idCount++; - } - - return result; - } - - private class ProjectEntry - { - boolean isEnabledCommitted; - boolean isEnabled; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyRegistry.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyRegistry.java deleted file mode 100644 index f7802eaca..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyRegistry.java +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080428 227501 pmoogk@ca.ibm.com - Peter Moogk, Fixed toLowerCase Locale problem. - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Vector; - -import org.eclipse.core.expressions.Expression; -import org.eclipse.core.expressions.ExpressionConverter; -import org.eclipse.core.expressions.ExpressionTagNames; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.ws.service.policy.IStateEnumerationItem; -import org.eclipse.wst.ws.service.policy.ServicePolicyActivator; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyPlatformLoadListener; -import org.eclipse.wst.ws.service.policy.utils.RegistryUtils; - -public class ServicePolicyRegistry -{ - private final String SERVICE_POLICY_ID = ServicePolicyActivator.PLUGIN_ID + ".servicepolicy"; //$NON-NLS-1$ - - private ServicePolicyPlatformImpl platform; - - public ServicePolicyRegistry( ServicePolicyPlatformImpl platform ) - { - this.platform = platform; - } - - public void load( List<IPolicyPlatformLoadListener> loadListeners, - Map<String, ServicePolicyImpl> policyMap, - Map<String, List<IStateEnumerationItem>> enumMap, - Map<String, StateEnumerationItemImpl> enumItemMap ) - { - IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(SERVICE_POLICY_ID); - - for( IConfigurationElement element : elements ) - { - String elementName = element.getName().toLowerCase( Locale.ENGLISH ); - - if( elementName.equals( "servicepolicy") ) //$NON-NLS-1$ - { - loadServicePolicy( element, loadListeners, policyMap, enumMap, enumItemMap ); - } - else - { - error( "Undefined service policy element, " + elementName + " found." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - // Resolve all policy services. - for( String policyId : policyMap.keySet() ) - { - ServicePolicyImpl policy = policyMap.get( policyId ); - - policy.resolve(); - } - } - - private void loadServicePolicy( IConfigurationElement element, - List<IPolicyPlatformLoadListener> loadListeners, - Map<String, ServicePolicyImpl> policyMap, - Map<String, List<IStateEnumerationItem>> enumMap, - Map<String, StateEnumerationItemImpl> enumItemMap ) - { - IConfigurationElement[] childElements = element.getChildren(); - - for( IConfigurationElement child : childElements ) - { - String childName = child.getName().toLowerCase( Locale.ENGLISH ); - - if( childName.equals( "loadlistener" ) ) //$NON-NLS-1$ - { - loadLoadListener( child, loadListeners ); - } - else if( childName.equals( "policy" ) ) //$NON-NLS-1$ - { - loadPolicy( child, policyMap ); - } - else if( childName.equals( "enumeration" ) ) //$NON-NLS-1$ - { - loadEnumeration( child, enumMap, enumItemMap ); - } - else if( childName.equals( ExpressionTagNames.ENABLEMENT ) ) - { - loadEnablement( child ); - } - else - { - error( "Undefined service policy element, " + childName + " found." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - - private void loadEnablement( IConfigurationElement element ) - { - try - { - Expression expression = ExpressionConverter.getDefault().perform( element ); - - platform.addEnabledExpression( expression ); - } - catch( CoreException exc ) - { - error( "Error loading enablement expression: " + exc.getMessage() ); //$NON-NLS-1$ - } - } - - private void loadEnumeration( IConfigurationElement element, - Map<String, List<IStateEnumerationItem>> enumMap, - Map<String, StateEnumerationItemImpl> enumItemMap ) - { - String enumId = RegistryUtils.getAttribute( element, "id" ); //$NON-NLS-1$ - String defaultEnumId = RegistryUtils.getAttribute( element, "default" ); //$NON-NLS-1$ - IConfigurationElement[] childElements = element.getChildren(); - List<IStateEnumerationItem> enumList = new Vector<IStateEnumerationItem>(); - - if( enumId == null ) - { - error( "\"Id\" attribute missing from Serivce Policy Enumeration element." ); //$NON-NLS-1$ - return; - } - - for( IConfigurationElement child : childElements ) - { - String childName = child.getName().toLowerCase( Locale.ENGLISH ); - - if( childName.equals( "item" ) ) //$NON-NLS-1$ - { - loadItem( child, enumList, enumItemMap ); - } - else - { - error( "Undefined service policy enumeration element, " + childName + " found." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - if( defaultEnumId != null ) - { - StateEnumerationItemImpl defaultEnum = enumItemMap.get( defaultEnumId ); - - if( defaultEnum == null ) - { - error( "Default enum attribute for enumeration " + enumId + " not found." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - else - { - defaultEnum.setDefault( true ); - } - } - - enumMap.put( enumId, enumList ); - } - - private void loadItem( IConfigurationElement element, - List<IStateEnumerationItem> enumList, - Map<String, StateEnumerationItemImpl> enumItemMap) - { - String itemId = RegistryUtils.getAttribute( element, "id" ); //$NON-NLS-1$ - String shortName = RegistryUtils.getAttribute( element, "shortname" ); //$NON-NLS-1$ - String longName = RegistryUtils.getAttribute( element, "longname" ); //$NON-NLS-1$ - - if( itemId == null ) - { - error( "\"Id\" attribute missing from Serivce Policy Enumeration item element." ); //$NON-NLS-1$ - } - - if( shortName == null && longName == null ) - { - error( "shortName or longName attribute missing from Service Policy Enumeration item element." ); //$NON-NLS-1$ - } - else if( shortName == null ) - { - shortName = longName; - } - else if( longName == null ) - { - longName = shortName; - } - - StateEnumerationItemImpl item = new StateEnumerationItemImpl(); - - item.setId( itemId ); - item.setShortName( shortName ); - item.setLongName( longName ); - enumList.add( item ); - enumItemMap.put( itemId, item ); - } - - private void loadLoadListener( IConfigurationElement element, - List<IPolicyPlatformLoadListener> loadListeners ) - { - try - { - Object listener = element.createExecutableExtension( "class" ); //$NON-NLS-1$ - - if( listener instanceof IPolicyPlatformLoadListener ) - { - loadListeners.add( (IPolicyPlatformLoadListener)listener ); - } - else - { - error( "Load listener, " + element.getAttribute( "class" ) + " does not implement IPolicyPlatformLoadListener" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } - catch( CoreException exc ) - { - ServicePolicyActivator.logError( "Error loading service policy loadlistener.", exc ); //$NON-NLS-1$ - } - } - - private void loadPolicy( IConfigurationElement policy, Map<String, ServicePolicyImpl> policyMap ) - { - IConfigurationElement[] policyElements = policy.getChildren(); - String parentId = RegistryUtils.getAttribute( policy, "parentpolicyid" ); //$NON-NLS-1$ - String id = RegistryUtils.getAttribute( policy, "id" ); //$NON-NLS-1$ - String enumListId = RegistryUtils.getAttribute( policy, "enumlistid" ); //$NON-NLS-1$ - String defaultEnumId = RegistryUtils.getAttribute( policy, "defaultenumid" ); //$NON-NLS-1$ - String mutableValue = RegistryUtils.getAttribute( policy, "mutable" ); //$NON-NLS-1$ - boolean mutable = mutableValue != null && mutableValue.equalsIgnoreCase( "true" ); //$NON-NLS-1$ - DescriptorImpl descriptor = null; - List<UnresolvedRelationship> relationships = new Vector<UnresolvedRelationship>(); - List<String[]> stateKeyValues = new Vector<String[]>(); - - // If the mutable attribute was not specified and the enumListId attribute - // attribute was specified then this policy should be mutable, since - // it doesn't make sense to associate state with a policy that is not - // changeable. - if( mutableValue == null && enumListId != null ) - { - mutable = true; - } - - try - { - for( IConfigurationElement policyElement : policyElements ) - { - String name = policyElement.getName().toLowerCase( Locale.ENGLISH ); - - if( name.equals( "descriptor") ) //$NON-NLS-1$ - { - descriptor = RegistryUtils.loadDescriptor( policyElement ); - } - else if( name.equals( "relationship" ) ) //$NON-NLS-1$ - { - loadRelationship( policyElement, relationships ); - } - else if( name.equals( "state" ) ) //$NON-NLS-1$ - { - String key = RegistryUtils.getAttribute( policyElement, "key" ); //$NON-NLS-1$ - String value = RegistryUtils.getAttribute( policyElement, "value" ); //$NON-NLS-1$ - - if( key == null ) - { - error( "Service policy state missing attribute \"key\"." ); //$NON-NLS-1$ - } - - if( value == null ) - { - error( "Service policy state missing attribute \"value\"." ); //$NON-NLS-1$ - } - - if( key != null && value != null ) - { - stateKeyValues.add( new String[]{ key, value } ); - } - } - else - { - error( "Undefined service policy element, " + name + " found." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - ServicePolicyImpl newPolicy = new ServicePolicyImpl( true, id, platform ); - - newPolicy.setUnresolvedParent( parentId ); - newPolicy.setUnresolvedRelationships( relationships ); - newPolicy.setDescriptor( descriptor ); - newPolicy.setEnumListId( enumListId ); - newPolicy.setDefaultEnumId( defaultEnumId ); - policyMap.put( id, newPolicy ); - - PolicyStateImpl policyState = (PolicyStateImpl)newPolicy.getPolicyState(); - - // Temporarily allow the state to be updated for static state provided - // by the extender. - policyState.internalSetMutable( true ); - - for( String[] keyValue : stateKeyValues ) - { - policyState.putValue( keyValue[0], keyValue[1] ); - } - - policyState.internalSetMutable( mutable ); - } - catch( IllegalArgumentException exc ) - { - error( "An error was found loading a service policy." ); //$NON-NLS-1$ - } - } - - private void loadRelationship( IConfigurationElement relationshipElement, List<UnresolvedRelationship> relationships ) - { - String enumValueAttr = RegistryUtils.getAttribute( relationshipElement, "enumlist" ); //$NON-NLS-1$ - - if( enumValueAttr == null ) - { - error( "Service policy relationship missing attribute \"enumList\"." ); //$NON-NLS-1$ - throw new IllegalArgumentException(); - } - - List<String> sourceEnumList = Arrays.asList( enumValueAttr.split( " " ) ); //$NON-NLS-1$ - IConfigurationElement[] children = relationshipElement.getChildren(); - List<UnresolvedPolicyRelationship> targetRelationshipList = new Vector<UnresolvedPolicyRelationship>(); - - for( IConfigurationElement child : children ) - { - String name = child.getName().toLowerCase( Locale.ENGLISH ); - - if( name.equals( "targetpolicy" ) ) //$NON-NLS-1$ - { - loadPolicyRelationship( child, targetRelationshipList ); - } - else - { - error( "Undefined service policy element, " + name + " found." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - UnresolvedRelationship relationship = new UnresolvedRelationship( sourceEnumList, targetRelationshipList ); - - relationships.add( relationship ); - } - - private void loadPolicyRelationship( IConfigurationElement policyElement, - List<UnresolvedPolicyRelationship> policyRelationshipList ) - { - String itemListAttr = RegistryUtils.getAttribute( policyElement, "itemlist" ); //$NON-NLS-1$ - String policyId = RegistryUtils.getAttribute( policyElement, "id" ); //$NON-NLS-1$ - - if( itemListAttr == null ) - { - error( "Service policy relationship missing attribute \"enumList\"." ); //$NON-NLS-1$ - throw new IllegalArgumentException(); - } - - if( policyId == null ) - { - error( "Service policy relationship missing attribute \"id\"." ); //$NON-NLS-1$ - throw new IllegalArgumentException(); - } - - List<String> targetEnumList = Arrays.asList( itemListAttr.split( " " ) ); //$NON-NLS-1$ - UnresolvedPolicyRelationship policyRelationship = new UnresolvedPolicyRelationship( policyId, targetEnumList ); - - policyRelationshipList.add( policyRelationship ); - } - - private void error( String message ) - { - ServicePolicyActivator.logError( message, null ); - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/StateEnumerationItemImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/StateEnumerationItemImpl.java deleted file mode 100644 index 0ce22946d..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/StateEnumerationItemImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import org.eclipse.wst.ws.service.policy.IStateEnumerationItem; - -public class StateEnumerationItemImpl implements IStateEnumerationItem -{ - private String id; - private String shortName; - private String longName; - private boolean isDefault = false; - - public String getId() - { - return id; - } - - public void setId(String id) - { - this.id = id; - } - - public String getShortName() - { - return shortName; - } - - public void setShortName(String shortName) - { - this.shortName = shortName; - } - - public String getLongName() - { - return longName; - } - - public void setLongName(String longName) - { - this.longName = longName; - } - - public boolean isDefault() - { - return isDefault; - } - - public void setDefault(boolean isDefault) - { - this.isDefault = isDefault; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/UnresolvedPolicyRelationship.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/UnresolvedPolicyRelationship.java deleted file mode 100644 index f27d74d6c..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/UnresolvedPolicyRelationship.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.List; - -public class UnresolvedPolicyRelationship -{ - private String policyId; - private List<String> enumList; - - public UnresolvedPolicyRelationship( String policyId, List<String> enumList ) - { - this.policyId = policyId; - this.enumList = enumList; - } - - public String getPolicyId() - { - return policyId; - } - - public List<String> getEnumList() - { - return enumList; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/UnresolvedRelationship.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/UnresolvedRelationship.java deleted file mode 100644 index a919f6801..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/UnresolvedRelationship.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy; - -import java.util.List; - -public class UnresolvedRelationship -{ - private List<String> sourceEnumerationList; - private List<UnresolvedPolicyRelationship> targetEnumerationList; - - public UnresolvedRelationship( List<String> sourceEnumerationList, - List<UnresolvedPolicyRelationship> targetEnumerationList ) - { - this.sourceEnumerationList = sourceEnumerationList; - this.targetEnumerationList = targetEnumerationList; - } - - public List<String> getSourceEnumerationList() - { - return sourceEnumerationList; - } - - public List<UnresolvedPolicyRelationship> getTargetEnumerationList() - { - return targetEnumerationList; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IDescriptor.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IDescriptor.java deleted file mode 100644 index 7eae1a225..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IDescriptor.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080515 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -/** - * - * This interface encapsulates the idea of a description for a service policy. - * - */ -public interface IDescriptor -{ - /** - * Returns the short name for the descriptor - * @return returns the short name for the descriptor - */ - public String getShortName(); - - /** - * Sets the short name for the descriptor. - * @param name - */ - public void setShortName(String name); - - /** - * Returns the long name for the descriptor. - * @return returns the long name for the descriptor. - */ - public String getLongName(); - - /** - * Sets the long name for the descriptor. - * @param longName - */ - public void setLongName(String longName); - - /** - * Returns the description for this descriptor. - * @return returns the description for this descriptor. - */ - public String getDescription(); - - /** - * Sets the description for this descriptor. - * @param description - */ - public void setDescription(String description); - - /** - * Returns the icon path relative to an icon bundle. - * @return returns the icon path for this descriptor. This path - * is relative to the plugin specified by the icon bundle id. This - * method may return null if there is no icon for this descriptor. - */ - public String getIconPath(); - - /** - * Sets the icon patch for this descriptor. - * - * @param iconPath - */ - public void setIconPath(String iconPath); - - /** - * Returns the icon bundle id. - * @return returns the bundle ID of a plugin that contains an icon. This - * method may return null if there is no icon associated with this descriptor. - */ - public String getIconBundleId(); - - /** - * - * Sets the icon bundle id for this descriptor. - * - * @param iconBundleId - */ - public void setIconBundleId(String iconBundleId); - - /** - * Returns the context help id. - * @return returns the context help id for this descriptor. This method - * may return null if no context has been specified. - */ - public String getContextHelpId(); - - /** - * Sets the context help id for this descriptor. - * - * @param contextHelpId - */ - public void setContextHelpId(String contextHelpId); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IFilter.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IFilter.java deleted file mode 100644 index d948ff927..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IFilter.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080515 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -/** - * - * This interface is used to filter service policies. - * - */ -public interface IFilter -{ - /** - * Determines if a policy should be accepted or not. - * - * @param policy the service policy. - * @return returns true if this policy is accepted by the filter. - */ - public boolean accept( IServicePolicy policy ); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyEnumerationList.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyEnumerationList.java deleted file mode 100644 index 0e839b94f..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyEnumerationList.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080515 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import java.util.List; - -/** - * - * This interface encapsulates the combination of a policy and a list - * of state enumeration items. This interface is used with the IPolicyRelationship - * interface. - * - */ -public interface IPolicyEnumerationList -{ - /** - * Returns the service policy for this list. - * @return returns a service policy. - */ - public IServicePolicy getPolicy(); - - /** - * - * Returns the state enumeration list items. - * @return returns a list of state enumeration items. - */ - public List<IStateEnumerationItem> getEnumerationList(); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyRelationship.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyRelationship.java deleted file mode 100644 index 89540bf99..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyRelationship.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import java.util.List; - -/** - * - * This interface is used to describe the dependency relationships between - * service policies. - * - */ -public interface IPolicyRelationship -{ - /** - * - * Returns the policy enumeration list for this relationship. - * - * @return This method returns the source service policy along with a list - * of possible states that this source policy could be in. - */ - public IPolicyEnumerationList getPolicyEnumerationList(); - - /** - * Returns the related policies for this relationship. - * - * @return returns a list of other target service policies and the states that - * these policies must be in to satisfy the relationship. - */ - public List<IPolicyEnumerationList> getRelatedPolicies(); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyState.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyState.java deleted file mode 100644 index 94bad0b6c..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyState.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import org.eclipse.wst.ws.service.policy.listeners.IPolicyStateChangeListener; - -/** - * - * This interface is used by service policy extenders to save the state of - * there policies. Note: extenders do not need to worry about if these changes - * are committed or discarded. This is handled by the framework. For example - * if an extender makes a number of calls to the putValue method and at some - * point ServicePolicyPlatform.discard() is called, the framework will handle - * the discarding of the changes made by the putValue method calls. - * - * Note: this data will eventually be stored in Eclipse with the following key: - * - * servicePolicyId + "." + key - * - * where servicePolicyId is the unique id for this service policy and the key - * is the key specified in the putValue method. - * - */ -public interface IPolicyState -{ - public final static String DefaultValueKey = "default.value.key"; //$NON-NLS-1$ - - /** - * - * Returns whether the state of this policy is mutible or not. - * - * @return returns true if the state of this policy is mutable. - */ - public boolean isMutable(); - - /** - * - * @param mutable sets whether this policy is mutable or not. Note: - * if the service policy for this IPolicyState object is predefined calling - * this method will have no effect. - */ - public void setMutable( boolean mutable ); - - /** - * This method sets some state for a service policy. - * - * @param key a key for this policy state. - * @param value the value of the policy state. - */ - public void putValue( String key, String value ); - - /** - * This method gets some state for a service policy. If there - * is no persisted value for this key the default value will be - * returned. If there is no default value an empty string is returned. - * - * @param key a key for this service policy. - * @return returns the value for the key specified. - */ - public String getValue( String key ); - - /** - * This method sets the default for a particular key. - * - * @param key the key - * @param defaultValue the default value. - * @param overrideExisting indicates if a existing default value should be overridden. - */ - public void putDefaultValue( String key, String defaultValue, boolean overrideExisting ); - - /** - * Adds a policy state change listener to this service policy. - * - * @param listener the listener - * @param notifyOnlyOnCommit indicates if this listener should be - * called for all state changes or only when the state data is - * committed. - */ - public void addPolicyStateChangeListener( IPolicyStateChangeListener listener, boolean notifyOnlyOnCommit ); - - /** - * Removes a policy state change listener from this service policy. - * - * @param listener - */ - public void removePolicyStateChangeListener( IPolicyStateChangeListener listener ); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyStateEnum.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyStateEnum.java deleted file mode 100644 index d116d757a..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IPolicyStateEnum.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080325 222095 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -/** - * - * This interface is used to access the state when an enumeration is used - * to persist state. - * - */ -public interface IPolicyStateEnum -{ - public final static String TRUE_ENUM = "org.eclipse.wst.true"; - public final static String FALSE_ENUM = "org.eclipse.wst.false"; - - /** - * - * Returns the enumeration id associated with this service policy. - * - * @return returns the enumeration id associated with this service policy. - */ - public String getEnumId(); - - /** - * Returns the default enum item for this enumeration. - * - * @return returns the default enum item for this enumeration. - */ - public String getDefaultId(); - - /** - * Sets the current enum item. This enum item id needs to be and enum item - * id associated with this enumeration. - * @param itemId - */ - public void setCurrentItem( String itemId ); - - /** - * - * Returns the current enum item. - * - * @return returns the current enum item. - */ - public IStateEnumerationItem getCurrentItem(); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IServicePolicy.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IServicePolicy.java deleted file mode 100644 index d64f320a9..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IServicePolicy.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyChildChangeListener; -import org.eclipse.wst.ws.service.policy.listeners.IStatusChangeListener; - -/** - * - * This interface encapsulates the idea of a service policy - * - */ -public interface IServicePolicy -{ - /** - * - * Returns if this service policy is defined by an extension or not. - * - * @return returns true if this Service policy is defined in plugin.xml - * meta data. Otherwise, false is returned. - */ - public boolean isPredefined(); - - /** - * - * Returns the unique ID for this service policy. - * - * @return returns the unique ID for this service policy. - */ - public String getId(); - - /** - * - * Returns the descriptor for this service policy. - * - * @return returns the descriptor for this service policy. - */ - public IDescriptor getDescriptor(); - - /** - * - * Returns a list of relationships to other IServicePolicy objects. - * - * @return returns a list of relationships to other IServicePolicy objects. - * - */ - public List<IPolicyRelationship> getRelationships(); - - /** - * Sets the relationships for this service policy. - * - * @param relationships - */ - public void setRelationships( List<IPolicyRelationship> relationships ); - - /** - * Restores the policy to its original state. All locally added - * child policies will be removed. The state of each policy will - * be set to is default value. Note: the changes made calling - * this method can be undone if the platform performs a discardChanges - * operation. Alternatively, if the plaform performs a commitChanges - * operation these changes will be saved. - */ - public void restoreDefaults(); - - /** - * Restores the policy to its original state for a particular project. - * The state of each policy will be set to is default value. - * Note: the changes made calling - * this method can be undone if the platform performs a discardChanges - * operation. Alternatively, if the plaform performs a commitChanges - * operation these changes will be saved. - */ - public void restoreDefaults( IProject project ); - - /** - * - * Returns the policy state for this service policy. - * - * @return returns the policy state for this service policy. - */ - public IPolicyState getPolicyState(); - - /** - * - * Returns the IPolicyState for a particular project. - * - * @param project the project. - * @return The IPolicyState for a particular project. - */ - public IPolicyState getPolicyState( IProject project ); - - /** - * - * Returns the policy state enumeration object. Note: this is just - * a wrapper around the policy state object. - * - * @return returns the state enumeration object for this service - * policy. If this policy is not associated with an enumeration - * null will be returned. - */ - public IPolicyStateEnum getPolicyStateEnum(); - - /** - * - * Returns the policy state enumeration object for a particular project. - * Note: this is just a wrapper around the policy state object. - * - * @param project the project - * @return returns the state enumeration for a particular project. If - * no state enumeration is associated with the service policy - * null will be returned. - */ - public IPolicyStateEnum getPolicyStateEnum( IProject project ); - - /** - * - * Returns the parent service policy object. - * - * @return returns the parent policy for this service policy. If this - * service policy has no parent then null is returned. - */ - public IServicePolicy getParentPolicy(); - - /** - * - * @return returns the child service policies for this service policy. Changes - * made to the returned list do not change the underlying number of children - * for this service policy. - */ - public List<IServicePolicy> getChildren(); - - /** - * Removes a child service policy from this service policy. If the policy specified - * is null or is not a child of this service policy this method will have no effect. - * Also, if this service policy is predefined calling this method will have - * no effect. - * @param policy - */ - public void removeChild( IServicePolicy policy ); - - /** - * Adds a child listener to this service policy. - * - * @param listener the listener - */ - public void addPolicyChildChangeListener( IPolicyChildChangeListener listener ); - - /** - * Removes a child listener from this service policy. - * @param listener - */ - public void removePolicyChildChangeListener( IPolicyChildChangeListener listener ); - - /** - * Adds a status change listener to this service policy. When the status changes - * this listener will be notified. - * - * @param listener - */ - public void addStatusChangeListener( IStatusChangeListener listener ); - - /** - * Removes a status change listener from this service policy. - * - * @param listener - */ - public void removeStatusChangeListener( IStatusChangeListener listener ); - - /** - * - * Returns the status for this service policy. - * - * @return returns the status for this service policy. - */ - public IStatus getStatus(); - - /** - * Sets the status for this service policy. - * - * @param status - */ - public void setStatus( IStatus status ); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IStateEnumerationItem.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IStateEnumerationItem.java deleted file mode 100644 index 4ce9bc243..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/IStateEnumerationItem.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -/** - * - * This interface is used to describe a state enumeration item that was - * defined by an enumeration in plugin.xml meta data. - * - */ -public interface IStateEnumerationItem -{ - /** - * - * Returns the ID of this state enumeration item. - * - * @return returns the ID of this state enumeration item. - */ - public String getId(); - - /** - * Returns the short name of this state enumeration item. - * - * @return returns the short name of this state enumeration item. - */ - public String getShortName(); - - /** - * - * Returns the long name of this state enumeration item. - * - * @return returns the long name of this state enumeration item. - */ - public String getLongName(); - - /** - * - * Returns whether this is the default item or not. - * - * @return returns true if this enumeration item is the default for this - * enumeration. - */ - public boolean isDefault(); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/PolicyEnumerationListImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/PolicyEnumerationListImpl.java deleted file mode 100644 index f4212786d..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/PolicyEnumerationListImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import java.util.List; - -/** - * - * This class provides a simple implementation of the IPolicyEnumerationList interface. - * - */ -public class PolicyEnumerationListImpl implements IPolicyEnumerationList -{ - private List<IStateEnumerationItem> enumList; - private IServicePolicy policy; - - /** - * A simple constructor for this class. - * - * @param enumList - * @param policy - */ - public PolicyEnumerationListImpl( List<IStateEnumerationItem> enumList, IServicePolicy policy ) - { - this.enumList = enumList; - this.policy = policy; - } - - /** - * - * Returns a list of state enumeration items. - * - * @return returns a list of state enumeration items. - */ - public List<IStateEnumerationItem> getEnumerationList() - { - return enumList; - } - - /** - * - * Returns a service policy. - * - * @return returns a service policy. - */ - public IServicePolicy getPolicy() - { - return policy; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/PolicyRelationshipImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/PolicyRelationshipImpl.java deleted file mode 100644 index 3c6cf2002..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/PolicyRelationshipImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import java.util.List; - -/** - * - * This class provides a simple implementation of the IPolicyRelationship - * interface. - * - */ -public class PolicyRelationshipImpl implements IPolicyRelationship -{ - private IPolicyEnumerationList policyEnumerationList; - private List<IPolicyEnumerationList> relatedPolices; - - public PolicyRelationshipImpl( IPolicyEnumerationList policyEnumerationList, - List<IPolicyEnumerationList> relatedPolicies ) - { - this.policyEnumerationList = policyEnumerationList; - this.relatedPolices = relatedPolicies; - } - - /** - * - * Returns the policy enumeration list for this relationship. - * - * @return This method returns the source service policy along with a list - * of possible states that this source policy could be in. - */ - public IPolicyEnumerationList getPolicyEnumerationList() - { - return policyEnumerationList; - } - - /** - * - * Returns the related policies for this relationship. - * - * @return returns a list of other target service policies and the states that - * these policies must be in to satisfy the relationship. - */ - public List<IPolicyEnumerationList> getRelatedPolicies() - { - return relatedPolices; - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/ServicePolicyActivator.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/ServicePolicyActivator.java deleted file mode 100644 index c21a43612..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/ServicePolicyActivator.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class ServicePolicyActivator extends Plugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.wst.ws.service.policy"; //$NON-NLS-1$ - - // The shared instance - private static ServicePolicyActivator plugin; - - /** - * The constructor - */ - public ServicePolicyActivator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static ServicePolicyActivator getDefault() { - return plugin; - } - - /** - * Logs an error with this plugin. - * - * @param message - * @param exc - */ - public static void logError( String message, Throwable exc ) - { - IStatus status = new Status( IStatus.ERROR, PLUGIN_ID, 0, message, exc ); - - getDefault().getLog().log(status); - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/ServicePolicyPlatform.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/ServicePolicyPlatform.java deleted file mode 100644 index 377d78377..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/ServicePolicyPlatform.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080325 222095 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - * 20080625 238482 pmoogk@ca.ibm.com - Peter Moogk, Adding thread safety to the service platform api. - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy; - -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.ws.service.internal.policy.ServicePolicyPlatformImpl; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyChildChangeListener; -import org.eclipse.wst.ws.service.policy.listeners.IPolicyPlatformProjectLoadListener; - -/** - * - * This class is used to access and add service policies to the platform. - * - */ -public class ServicePolicyPlatform -{ - private static ServicePolicyPlatform instancePlatform = null; - private ServicePolicyPlatformImpl platformImpl; - - private ServicePolicyPlatform() - { - } - - /** - * - * Returns a singleton instance of this service policy platform. - * - * @return returns a singleton instance of this service policy platform. - */ - public static synchronized ServicePolicyPlatform getInstance() - { - if( instancePlatform == null ) - { - instancePlatform = new ServicePolicyPlatform(); - instancePlatform.platformImpl = new ServicePolicyPlatformImpl( instancePlatform ); - instancePlatform.platformImpl.load(); - instancePlatform.platformImpl.callLoadListeners(); - } - - return instancePlatform; - } - - /** - * Indicates if the property page for a project should be displayed in a popup - * menu or not. - * - * @param object - * @return returns true if this platform is enabled for specified object. In most - * cases the specified object will be an IProject. This method is usually called - * to determine if a the service policy entry should appear for a particular project. - */ - public boolean isEnabled( Object object ) - { - return platformImpl.isEnabled( object ); - } - - /** - * Calling this method will commit all the state changes that were made to all - * the service policies. The method only applies to state changes at the workspace - * level. - */ - public synchronized void commitChanges() - { - platformImpl.commitChanges( true ); - } - - /** - * Calling this method will discard all the state changes that were made to all - * the service policies. The method only applies to state changes at the workspace - * level. - */ - public synchronized void discardChanges() - { - platformImpl.discardChanges(); - } - - /** - * Calling this method will commit all the state changes that were made to all - * the service policies for a particular project. The method only applies to - * state changes at the project level. - */ - public synchronized void commitChanges( IProject project ) - { - platformImpl.commitChanges( project ); - } - - /** - * Calling this method will discard all the state changes that were made to all - * the service policies for a particular project. The method only applies to - * state changes at the project level. - */ - public synchronized void discardChanges( IProject project ) - { - platformImpl.discardChanges( project ); - } - - /** - * - * Returns all service policy IDs that are defined. - * - * @return returns all service policy IDs that are defined. - */ - public Set<String> getAllPolicyIds() - { - return platformImpl.getAllPolicyIds(); - } - - /** - * - * Returns the list of root policies for the platform given a filter. - * - * @param filter a filter a the service policies. This method may be null if - * no filter is required. - * @return returns all root level service policies. If a filter is specified - * some service policies may be removed from the returned list. A root - * level service policy is defined to be a service policy with no parent. - * - */ - public List<IServicePolicy> getRootServicePolicies( IFilter filter ) - { - return platformImpl.getRootServicePolicies( filter ); - } - - /** - * - * Returns a service policy given it's unique ID. - * - * @param id - * @return returns a service policy given it's unique ID. - */ - public IServicePolicy getServicePolicy( String id ) - { - return platformImpl.getServicePolicy( id ); - } - - /** - * - * Returns if the particular project has been enabled or not on it's - * service policy property page. - * - * @param project - * @return returns true if the specified project has been enabled for - * project specific policy preferences. - */ - public boolean isProjectPreferencesEnabled( IProject project ) - { - return platformImpl.isProjectPreferencesEnabled( project ); - } - - /** - * Sets whether a project specific service policy preferences is enabled or not. - * - * @param project - * @param value - */ - public synchronized void setProjectPreferencesEnabled( IProject project, boolean value ) - { - platformImpl.setProjectPreferencesEnabled( project, value ); - } - - /** - * Restores the workspace level defaults. Note: the state changes made by - * calling this method need to be committed or discarded by the platform. - */ - public synchronized void restoreDefaults() - { - platformImpl.restoreDefaults(); - } - - /** - * - * Restores the project level defaults. Note: the state changes made by - * calling this method need to be committed or discarded by the platform. - * - * @param project - */ - public synchronized void restoreDefaults( IProject project ) - { - platformImpl.restoreDefaults( project ); - } - - /** - * This method creates an IServicePolicy object. - * - * @param parent the parent policy for this policy. If this policy has no - * parent null may be specified. - * @param id This is a unique id for this service policy. If the id specified - * is not unique trailing numerical digits in the id will be stripped off. - * Numerical digits will then be added to end of the id to make it unique. - * If the id is empty or null the framework will assign a unique id. - * @param enumListId If this policy's state is defined by an enumeration - * the enumeration id should be specified here. Otherwise null should be - * specified. - * @param defaultEnumId If this policy's state is defined by an enumeration - * this parameter specifies the default value. This value may be null - * if not using an enumeration or if the default value of the enumeration - * should be used. - * @return returns a service policy object. - */ - public synchronized IServicePolicy createServicePolicy( IServicePolicy parent, String id, String enumListId, String defaultEnumId ) - { - return platformImpl.createServicePolicy( parent, id, enumListId, defaultEnumId ); - } - - /** - * Removes a service policy from the service policy platform. - * - * @param policy the service policy - */ - public synchronized void removeServicePolicy( IServicePolicy policy ) - { - platformImpl.removePlatformPolicy( policy ); - } - - /** - * This method allows calls to listener to any child change that is - * made in the service policy platform regardless of where it is - * located in the tree of service policies. - * - * @param listener - * @param onCommit indicates whether this listener should be invoked when - * the the platform changes are committed. - */ - public synchronized void addChildChangeListener( IPolicyChildChangeListener listener, boolean onCommit ) - { - platformImpl.addChildChangeListener( listener, onCommit ); - } - - /** - * Indicates whether child change listeners should be queued or not. If - * they are queued then child change events will be queue up until this - * method is called with a false parameter. When this happens the child - * change event listeners are noticed of add the events that have occurred. - * - * @param queue - */ - public synchronized void queueChildChangeListeners( boolean queue ) - { - platformImpl.queueChildChangeListeners( queue ); - } - - /** - * Removes a child change listener from the service policy platform. - * - * @param listener - * @param onCommit indicates whether this change listener should be removed - * from the onCommit list. - */ - public synchronized void removeChildChangeListener( IPolicyChildChangeListener listener, boolean onCommit ) - { - platformImpl.removeChildChangeListener( listener, onCommit ); - } - - /** - * Add a project platform listener. When a particular project is referenced - * by in the service policy platform this listener will be called the first - * time the project is loaded into the system. - * - * @param listener the listener - */ - public synchronized void addProjectLoadListener( IPolicyPlatformProjectLoadListener listener ) - { - platformImpl.addProjectLoadListener( listener ); - } - - /** - * Removes a project platform listener. - * - * @param listener the listener - */ - public synchronized void removeProjectLoadListener( IPolicyPlatformProjectLoadListener listener ) - { - platformImpl.removeProjectLoadListener( listener ); - } - - /** - * - * @param enumId - * @return returns a list of state enumeration items given the unique - * enumeration ID for this enumeration. - */ - public List<IStateEnumerationItem> getStateEnumeration( String enumId ) - { - return platformImpl.getStateEnumeration( enumId ); - } - - /** - * - * @param stateItemId - * @return returns a state enumeration item given this ID for this enumeration - * item. - */ - public IStateEnumerationItem getStateItemEnumeration( String stateItemId ) - { - return platformImpl.getStateItemEnumeration( stateItemId ); - } -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyChildChangeListener.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyChildChangeListener.java deleted file mode 100644 index c5136044e..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyChildChangeListener.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy.listeners; - -import java.util.List; - -import org.eclipse.wst.ws.service.policy.IServicePolicy; - -public interface IPolicyChildChangeListener -{ - /** - * The method is called with an array of child changes. Each child item - * is associated with the added item at the same index value. - * - * @param child service policies that have changed. - * @param added indicates if the associate policy was added or removed. - */ - public void childChange( List<IServicePolicy> child, List<Boolean> added ); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyPlatformLoadListener.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyPlatformLoadListener.java deleted file mode 100644 index ed929c0ec..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyPlatformLoadListener.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy.listeners; - - -/** - * - * This interface is used to register code that needs to execute when the - * service policy platform is loaded. - * - */ -public interface IPolicyPlatformLoadListener -{ - /** - * Called once when the service platform is loaded in the system. This - * may not necessarily happen when Eclipse initially starts. - */ - public void load(); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyPlatformProjectLoadListener.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyPlatformProjectLoadListener.java deleted file mode 100644 index d2b5a94bc..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyPlatformProjectLoadListener.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20080324 222095 pmoogk@ca.ibm.com - Peter Moogk, UI now listens for state changes. - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy.listeners; - -import org.eclipse.core.resources.IProject; - -/** - * - * This interface is used to register code that needs to loaded when a particular - * project is loaded into the service policy platform. - * - */ -public interface IPolicyPlatformProjectLoadListener -{ - /** - * This method is called once when a project loaded into the service policy - * platform. - * - * @param project the project - */ - public void load( IProject project ); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyStateChangeListener.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyStateChangeListener.java deleted file mode 100644 index 88add1151..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IPolicyStateChangeListener.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy.listeners; - -import org.eclipse.wst.ws.service.policy.IServicePolicy; - -/** - * - * This interface is used when the developer wants to listener to state - * changes for a particular service policy. - * - */ -public interface IPolicyStateChangeListener -{ - /** - * Called when a state change event occurs for a service policy. - * - * @param policy the service policy - * @param key the key of the state that changed. - * @param oldValue the old value of the state that changed. - * @param newValue the new value of the state that changed. - */ - public void policyStateChange( IServicePolicy policy, String key, String oldValue, String newValue ); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IStatusChangeListener.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IStatusChangeListener.java deleted file mode 100644 index 2d5b31983..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/listeners/IStatusChangeListener.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy.listeners; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.ws.service.policy.IServicePolicy; - -/** - * - * This interface is used by code that is interested in listening to status - * change events of service policies. - * - */ -public interface IStatusChangeListener -{ - /** - * Called when a status change event occurs. - * - * @param policy the service policy. - * @param oldStatus the old status. - * @param newStatus the new status. - */ - public void statusChange( IServicePolicy policy, IStatus oldStatus, IStatus newStatus ); -} diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/utils/RegistryUtils.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/utils/RegistryUtils.java deleted file mode 100644 index 1fec83055..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/policy/utils/RegistryUtils.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk - * 20080428 227501 pmoogk@ca.ibm.com - Peter Moogk, Fixed toLowerCase Locale problem. - * 20080516 232603 pmoogk@ca.ibm.com - Peter Moogk, Clean up java doc - * 20080905 246428 pmoogk@ca.ibm.com - Peter Moogk, Added iconBundleId parsing. - *******************************************************************************/ -package org.eclipse.wst.ws.service.policy.utils; - -import java.util.Locale; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.ws.service.internal.policy.DescriptorImpl; -import org.eclipse.wst.ws.service.policy.ServicePolicyActivator; - -/** - * - * This class is only intended for org.eclipse.wst.ws.service.policy.ui plugin to use. - * It contains convenience method for parsing the service policy extension point. - * - */ -public class RegistryUtils -{ - /** - * Loads the attributes for a descriptor element. - * @param element the descriptor element - * @return returns the data for this element. - */ - public static DescriptorImpl loadDescriptor( IConfigurationElement element ) - { - DescriptorImpl descriptor = new DescriptorImpl(); - - String shortName = getAttribute( element, "shortname" ); //$NON-NLS-1$ - String longName = getAttribute( element, "longname" ); //$NON-NLS-1$ - String description = getAttribute( element, "description" ); //$NON-NLS-1$ - String iconPath = getAttribute( element, "iconpath" ); //$NON-NLS-1$ - String contextHelp = getAttribute( element, "contexthelpid" ); //$NON-NLS-1$ - - if( shortName == null && longName == null ) - { - ServicePolicyActivator.logError( "Short name or Long name missing from service policy descriptor.", null ); //$NON-NLS-1$ - } - else if( shortName == null ) - { - shortName = longName; - } - else if( longName == null ) - { - longName = shortName; - } - - descriptor.setDescription( description ); - descriptor.setShortName( shortName ); - descriptor.setLongName( longName ); - descriptor.setContextHelpId( contextHelp ); - - if( iconPath != null ) - { - String iconBundleId = element.getContributor().getName(); - String pluginPrefix = "plugin://"; //$NON-NLS-1$ - - if( iconPath.startsWith( pluginPrefix ) && iconPath.length() > pluginPrefix.length() ) - { - int pluginSlash = iconPath.indexOf( '/', pluginPrefix.length() ); - - iconBundleId = iconPath.substring( pluginPrefix.length(), pluginSlash ); - iconPath = iconPath.substring( pluginSlash + 1 ); - } - - descriptor.setIconPath( iconPath ); - descriptor.setIconBundleId( iconBundleId ); - } - - descriptor.resetHasChanged(); - return descriptor; - } - - /** - * This method takes in a lower case attribute name. It will then return - * the same attribute name that includes potentially uppercase characters. - * This method allows clients to specify attribute names in a case insensitive - * fashion. - * - * @param element the element - * @param attribute the attribute - * @return returns the lowercase attribute name. - */ - public static String getAttributeName( IConfigurationElement element, String attribute ) - { - String[] names = element.getAttributeNames(); - String result = null; - - for( String name : names ) - { - if( name.toLowerCase( Locale.ENGLISH ).equals( attribute ) ) - { - result = name; - break; - } - } - - return result; - } - - /** - * Gets a attribute value where the attribute name is case insensitive. - * - * @param element the element. - * @param attribute the attribute to get. - * @return the value for this attribute or null if the attribute is not specified. - */ - public static String getAttribute( IConfigurationElement element, String attribute ) - { - String[] names = element.getAttributeNames(); - String value = null; - - for( String name : names ) - { - if( name.toLowerCase( Locale.ENGLISH ).equals( attribute ) ) - { - value = element.getAttribute( name ); - break; - } - } - - return value; - } -} |