Esempio n. 1
0
 /**
  * Get the resource for this uri. It will use the resource set of the project to find it. It will
  * load if not already loaded.
  *
  * @param uri
  * @return resource or <code>null</code> if resource is not found.
  * @since 1.0.0
  */
 public Resource getResource(URI uri) {
   try {
     return getResourceSet().getResource(uri, true);
   } catch (WrappedException ex) {
     if (!WorkbenchResourceHelperBase.isResourceNotFound(ex)) throw ex;
   }
   return null;
 }
Esempio n. 2
0
 /**
  * Create an EMF context for the project.
  *
  * @throws CoreException
  * @since 1.0.0
  */
 protected void createEmfContext() throws CoreException {
   WorkbenchResourceHelperBase.createEMFContext(getProject(), this);
 }
  private Collection getWSServiceRefsFromSelection() {

    IStructuredSelection initSel = getInitialSelection();
    if (initSel != null && initSel.size() == 1) {
      Object obj = initSel.getFirstElement();
      ServiceRef serviceRef = null;
      if (obj instanceof ServiceRef) {
        // Client ServiceRef
        serviceRef = (ServiceRef) obj;
        serviceRefName_ = serviceRef.getServiceRefName();
        project_ = ProjectUtilities.getProject(serviceRef);
      } else if (obj instanceof WebServiceNavigatorGroupType) {
        WebServiceNavigatorGroupType wsngt = (WebServiceNavigatorGroupType) obj;
        serviceRef = wsngt.getServiceRef();
        serviceRefName_ = serviceRef.getServiceRefName();
        project_ = ProjectUtilities.getProject(serviceRef);
      } else if (obj instanceof IFile) {
        Resource res = WorkbenchResourceHelperBase.getResource((IFile) obj, true);
        Collection serviceRefs = null;
        if (res instanceof WebServicesResource) {
          // webservicesclient.xml for J2EE 1.3
          WebServicesResource wsRes = (WebServicesResource) res;
          serviceRefs = wsRes.getWebServicesClient().getServiceRefs();
          if (!serviceRefs.isEmpty()) {
            ServiceRef ref = (ServiceRef) ((List) serviceRefs).get(0);
            serviceRefName_ = ref.getServiceRefName();
            project_ = ProjectUtilities.getProject(ref);
            return serviceRefs;
          }
          return null;
        } else {
          if (res instanceof WebAppResource) {
            // web.xml for J2EE 1.4
            WebAppResource webAppRes = (WebAppResource) res;
            serviceRefs = webAppRes.getWebApp().getServiceRefs();
          } else if (res instanceof EJBResource) {
            EJBResource ejbRes = (EJBResource) res;
            serviceRefs = webServicesManager_.getServiceRefs(ejbRes.getEJBJar());
          } else if (res instanceof ApplicationClientResource) {
            ApplicationClientResource appClientRes = (ApplicationClientResource) res;
            serviceRefs =
                webServicesManager_.getServiceRefs(
                    appClientRes
                        .getApplicationClient()); // appClientRes.getApplicationClient().getServiceRefs();
          }
          if (serviceRefs != null && serviceRefs.size() > 0) {
            ServiceRef ref = (ServiceRef) ((List) serviceRefs).get(0);
            serviceRefName_ = ref.getServiceRefName();
            project_ = ProjectUtilities.getProject(ref);
          }
          return serviceRefs;
        }
      }

      // This section is for obtaining all the serviceRefs from the project, given that the initial
      // selection
      // was from the J2EE view (ServiceRef or WebServiceNavigatorGroupType), it will select the
      // right serviceRef
      if (project_ == null) {
        project_ = getProject();
      }
      if (project_ == null) {
        return null;
      }

      if (J2EEUtils.isWebComponent(project_)) {
        WebArtifactEdit webEdit = null;
        try {
          IVirtualComponent vc = ComponentCore.createComponent(project_);
          webEdit = WebArtifactEdit.getWebArtifactEditForRead(vc);
          if (webEdit != null) {
            WebApp webApp = (WebApp) webEdit.getDeploymentDescriptorRoot();
            if (webApp != null) {
              return webServicesManager_.getServiceRefs(webApp);
            }
          }
        } finally {
          if (webEdit != null) webEdit.dispose();
        }
      } else if (J2EEUtils.isEJBComponent(project_)) {

        IVirtualComponent vc = ComponentCore.createComponent(project_);
        EJBJar ejbJar = EJBArtifactEditUtilities.getEJBJar(vc);
        if (ejbJar != null) {
          return webServicesManager_.getServiceRefs(ejbJar);
        }
      } else if (J2EEUtils.isAppClientComponent(project_)) {
        IVirtualComponent vc = ComponentCore.createComponent(project_);
        AppClientArtifactEdit appEdit = null;
        try {
          appEdit = AppClientArtifactEdit.getAppClientArtifactEditForRead(vc);
          if (appEdit != null) {
            ApplicationClient appClient = appEdit.getApplicationClient();
            if (appClient != null) {
              return webServicesManager_.getServiceRefs(appClient);
            }
          }
        } finally {
          if (appEdit != null) {
            appEdit.dispose();
          }
        }
      }
    }
    return null;
  }