Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 30f7ff28f7d5f234a20d81d06f7e87d0366c9a8b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*******************************************************************************
 * Copyright (c) 2005 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
 *******************************************************************************/

package org.eclipse.jst.ws.internal.consumption.ui.extension;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.ws.internal.consumption.command.common.AddModuleToServerCommand;
import org.eclipse.jst.ws.internal.consumption.command.common.CreateServerCommand;
import org.eclipse.wst.common.environment.IEnvironment;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;

public class PreClientInstallCommand extends AbstractDataModelOperation 
{
  private IWebServiceClient webServiceClient_;
  private String            project_;
  private String            module_;
  private String            earProject_;
  private String            ear_;
  
  public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable )
  {
      IEnvironment environment = getEnvironment();
      
      if (webServiceClient_.getWebServiceClientInfo().getServerInstanceId()==null)
      {
        CreateServerCommand createServerCommand = new CreateServerCommand();
        createServerCommand.setServerFactoryid(webServiceClient_.getWebServiceClientInfo().getServerFactoryId());
        createServerCommand.setEnvironment( environment );
        IStatus createServerStatus = createServerCommand.execute(null, null);
        if (createServerStatus.getSeverity()==Status.OK)
        {
          webServiceClient_.getWebServiceClientInfo().setServerInstanceId(createServerCommand.getServerInstanceId());
        }
        else
        {
          if (createServerStatus.getSeverity()==Status.ERROR)
          {
            environment.getStatusHandler().reportError( createServerStatus );
          }               
          return createServerStatus;
        }
      }
        
      
      
      AddModuleToServerCommand command = new AddModuleToServerCommand();
      command.setServerInstanceId(webServiceClient_.getWebServiceClientInfo().getServerInstanceId());
      if (earProject_ != null && earProject_.length()>0 && ear_!= null && ear_.length()>0)
      {
        command.setProject(earProject_);
        command.setModule(ear_);
      }
      else
      {
        command.setProject(project_);
        command.setModule(module_);       
      }

      command.setEnvironment( environment );
      IStatus status = command.execute( null, null );
      if (status.getSeverity()==Status.ERROR)
      {
        environment.getStatusHandler().reportError( status );
      }     
      return status;
	  }

    public void setProject( String project )
    {
      project_ = project;
    }
      
    public void setModule( String module )
    {
      module_ = module;
    } 
    
    public void setEarProject( String earProject )
    {
      earProject_ = earProject;
    }
    
    public void setEar( String ear )
    {
      ear_ = ear;  
    }
    
    public void setWebService( IWebServiceClient webServiceClient )
    {
      webServiceClient_ = webServiceClient;  
    }    
}

Back to the top