[443330] Load UML static profile using path map
[EMFCompare2.git] / plugins / org.eclipse.emf.compare.uml2.rcp / src / org / eclipse / emf / compare / uml2 / rcp / internal / policy / UMLLoadOnDemandPolicy.java
blob9ecd2a610b3be4eadce0e747f87cafb1a28646a9
1 /*******************************************************************************
2 * Copyright (c) 2012 Obeo.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Obeo - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.emf.compare.uml2.rcp.internal.policy;
13 import java.util.Collection;
14 import java.util.Map;
16 import org.eclipse.emf.common.util.URI;
17 import org.eclipse.emf.compare.rcp.policy.ILoadOnDemandPolicy;
18 import org.eclipse.emf.ecore.resource.URIConverter;
19 import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
20 import org.eclipse.uml2.uml.UMLPlugin;
22 /**
23 * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
25 public class UMLLoadOnDemandPolicy implements ILoadOnDemandPolicy {
27 /**
28 * {@inheritDoc}
30 * @see org.eclipse.emf.compare.ide.policy.ILoadOnDemandPolicy#isAuthorizing(org.eclipse.emf.compare.ide.policy.URI)
32 public boolean isAuthorizing(URI uri) {
33 URIConverter uriConverter = new ExtensibleURIConverterImpl();
34 // Need to normalize the URI in order to resolve URI using path map
35 URI normalizedURI = uriConverter.normalize(uri);
36 Map<String, URI> nsURIToProfileLocationMap = UMLPlugin.getEPackageNsURIToProfileLocationMap();
37 Collection<URI> profileLocations = nsURIToProfileLocationMap.values();
38 for (URI profileLocation : profileLocations) {
39 URI profileResourceLocation = profileLocation.trimFragment();
40 // Need to normalize the URI in order to resolve URI using path map
41 URI profileResourceNormalizedURI = uriConverter.normalize(profileResourceLocation);
42 if (profileResourceNormalizedURI.equals(normalizedURI)) {
43 return true;
46 return false;