/** {@inheritDoc} */
 @Override
 public IWizardPage[] getContentPages() {
   try {
     consumerFromWsdl = new ConsumeServiceFromExistingWSDLWizardPage(getSelection());
   } catch (Exception e) {
     logger.warning(e);
   }
   return new IWizardPage[] {consumerFromWsdl};
 }
Ejemplo n.º 2
0
 /** {@inheritDoc} */
 @Override
 public void start(BundleContext context) throws Exception {
   super.start(context);
   plugin = this;
   StringBuffer buf = new StringBuffer();
   buf.append("SOAPlugin.start - ");
   buf.append(JDTUtil.getBundleInfo(context.getBundle(), SOALogger.DEBUG));
   SOALogger.getLogger().info(buf);
 }
  /** {@inheritDoc} */
  @Override
  public boolean performFinish() {
    // saving the user selected project dir

    if (SOALogger.DEBUG) logger.entering();

    final ISOAProject soaProject = consumerFromWsdl.getSOAProject();

    final boolean overrideWorkspaceRoot = consumerFromWsdl.isOverrideProjectRootDirectory();
    final String workspaceRootDirectory = consumerFromWsdl.getProjectRootDirectory();
    if (overrideWorkspaceRoot) SOABasePage.saveWorkspaceRoot(workspaceRootDirectory);

    final String serviceName = consumerFromWsdl.getAdminName();
    final String servicePackage = consumerFromWsdl.getServicePackage();
    final String serviceInterface =
        StringUtils.isBlank(servicePackage)
            ? serviceName
            : servicePackage + SOAProjectConstants.CLASS_NAME_SEPARATOR + serviceName;

    final ConsumerFromWsdlParamModel uiModel = new ConsumerFromWsdlParamModel();
    uiModel.setServiceName(serviceName);
    uiModel.setPublicServiceName(consumerFromWsdl.getPublicServiceName());
    uiModel.setServiceInterface(serviceInterface);
    uiModel.setOverrideWorkspaceRoot(overrideWorkspaceRoot);
    uiModel.setWorkspaceRootDirectory(workspaceRootDirectory);
    uiModel.setServiceImpl(consumerFromWsdl.getFullyQualifiedServiceImplementation());
    uiModel.setServiceVersion(consumerFromWsdl.getServiceVersion());
    uiModel.setServiceLayer(consumerFromWsdl.getServiceLayer());
    final String clientName = consumerFromWsdl.getClientName();
    final String clientID = consumerFromWsdl.getConsumerId();
    uiModel.setWSDLSourceType(SOAProjectConstants.InterfaceWsdlSourceType.EXISTIING);
    uiModel.setNamespaceToPacakgeMappings(consumerFromWsdl.getNamespaceToPackageMappings());
    uiModel.setClientName(clientName);
    if (StringUtils.isNotBlank(consumerFromWsdl.getConsumerId()))
      uiModel.setConsumerId(consumerFromWsdl.getConsumerId());
    uiModel.setServiceDomain(consumerFromWsdl.getServiceDomain());
    uiModel.setNamespacePart(consumerFromWsdl.getDomainClassifier());
    uiModel.setEnvironments(consumerFromWsdl.getEnvironments());
    uiModel.setTypeFolding(consumerFromWsdl.getTypeFolding());
    uiModel.setServiceLocation(consumerFromWsdl.getServiceLocation());
    try {
      uiModel.setOriginalWsdlUrl(new URL(consumerFromWsdl.getWSDLURL()));
      WorkspaceModifyOperation operation =
          new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor monitor)
                throws CoreException, InvocationTargetException, InterruptedException {
              final long startTime = System.currentTimeMillis();
              final int totalWork = ProgressUtil.PROGRESS_STEP * 180;
              monitor.beginTask("Creating consumer from WSDL->" + clientName, totalWork);
              ProgressUtil.progressOneStep(monitor);
              SOAConsumerProject consumerSOAProject = null;
              try {
                if (((soaProject instanceof SOAImplProject) == true)
                    && (soaProject
                            .getProject()
                            .hasNature(
                                GlobalRepositorySystem.instanceOf()
                                    .getActiveRepositorySystem()
                                    .getProjectNatureId(SupportedProjectType.CONSUMER))
                        == false)) {
                  // does not have consumer nature yet, add it now
                  IProject project = soaProject.getProject();
                  BuildSystemUtil.addSOAConsumerSupport(
                      project,
                      GlobalRepositorySystem.instanceOf()
                          .getActiveRepositorySystem()
                          .getProjectNatureId(SupportedProjectType.CONSUMER),
                      monitor);
                  logger.warning(
                      "Added SOA consumer project nature to the impl project->"
                          + project.getName());
                  SOAResourceCreator.createConsumerPropertiesFileForImplProjects(
                      project, clientName, clientID, monitor);
                  logger.warning(
                      "Created service_consumer_project.properties to the impl project->"
                          + project.getName());
                  consumerSOAProject =
                      (SOAConsumerProject)
                          GlobalRepositorySystem.instanceOf()
                              .getActiveRepositorySystem()
                              .getAssetRegistry()
                              .getSOAProject(project);
                } else {
                  consumerSOAProject = (SOAConsumerProject) soaProject;
                }
                ServiceCreator.addServiceToConsumerFromWSDL(uiModel, consumerSOAProject, monitor);
                // we should open the wsdl file for any successful
                // creation of an interface project.
                final IFile wsdlFile = SOAServiceUtil.getWsdlFile(serviceName);
                WorkspaceUtil.refresh(wsdlFile, monitor);
                if (wsdlFile.exists()) {
                  IDE.openEditor(
                      UIUtil.getWorkbench().getActiveWorkbenchWindow().getActivePage(), wsdlFile);
                }
                final TrackingEvent event =
                    new TrackingEvent(
                        "ConsumeNewServiceFromWSDL",
                        new Date(startTime),
                        System.currentTimeMillis() - startTime);
                GlobalRepositorySystem.instanceOf()
                    .getActiveRepositorySystem()
                    .trackingUsage(event);
              } catch (Exception e) {
                logger.error(e);
                throw new SOAConsumerCreationFailedException(
                    "Failed to create consumer from WSDL->" + clientName, e);
              } finally {
                monitor.done();
              }
            }
          };
      getContainer().run(false, true, operation);
      changePerspective();
    } catch (Exception e) {
      logger.error(e);
      UIUtil.showErrorDialog(getShell(), "Error Occured During Consumer Creation", null, e);
      if (SOALogger.DEBUG) logger.exiting(false);
      return false;
    }
    if (SOALogger.DEBUG) logger.exiting(true);
    return true;
  }