1 /*
2  * RSConnectPublishResult.java
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 package org.rstudio.studio.client.rsconnect.model;
16 
17 import java.util.ArrayList;
18 
19 public class RSConnectPublishResult
20 {
RSConnectPublishResult(RSConnectPublishSource source)21    public RSConnectPublishResult(RSConnectPublishSource source)
22    {
23       ArrayList<String> deployFiles = new ArrayList<>();
24       deployFiles.add(source.getDeployFile());
25       publishType_ = PUBLISH_RPUBS;
26       appName_     = "";
27       appTitle_    = "";
28       appId_       = "";
29       account_     = null;
30       source_      = source;
31       settings_    = new RSConnectPublishSettings(deployFiles, null, null, false,
32          true);
33       isUpdate_    = false;
34    }
35 
RSConnectPublishResult(String appName, String appTitle, String appId, RSConnectAccount account, RSConnectPublishSource source, RSConnectPublishSettings settings, boolean isUpdate)36    public RSConnectPublishResult(String appName,
37          String appTitle,
38          String appId,
39          RSConnectAccount account,
40          RSConnectPublishSource source,
41          RSConnectPublishSettings settings,
42          boolean isUpdate)
43    {
44       this(settings.getAsStatic() ?
45                PUBLISH_STATIC : PUBLISH_CODE,
46            appName, appTitle, appId, account, source, settings,
47            isUpdate);
48    }
49 
RSConnectPublishResult(int publishType, String appName, String appTitle, String appId, RSConnectAccount account, RSConnectPublishSource source, RSConnectPublishSettings settings, boolean isUpdate)50    private RSConnectPublishResult(int publishType,
51          String appName,
52          String appTitle,
53          String appId,
54          RSConnectAccount account,
55          RSConnectPublishSource source,
56          RSConnectPublishSettings settings,
57          boolean isUpdate)
58    {
59       publishType_ = publishType;
60       appName_     = appName;
61       appTitle_    = appTitle;
62       appId_       = appId;
63       account_     = account;
64       source_      = source;
65       settings_    = settings;
66       isUpdate_    = isUpdate;
67    }
68 
getAppName()69    public String getAppName()
70    {
71       return appName_;
72    }
73 
getAppTitle()74    public String getAppTitle()
75    {
76       return appTitle_;
77    }
78 
getAppId()79    public String getAppId()
80    {
81       return appId_;
82    }
83 
getAccount()84    public RSConnectAccount getAccount()
85    {
86       return account_;
87    }
88 
getPublishType()89    public int getPublishType()
90    {
91       return publishType_;
92    }
93 
getSettings()94    public RSConnectPublishSettings getSettings()
95    {
96       return settings_;
97    }
98 
getSource()99    public RSConnectPublishSource getSource()
100    {
101       return source_;
102    }
103 
isUpdate()104    public boolean isUpdate()
105    {
106       return isUpdate_;
107    }
108 
109    private final String appName_;
110    private final String appTitle_;
111    private final String appId_;
112    private final RSConnectAccount account_;
113    private final int publishType_;
114    private final RSConnectPublishSettings settings_;
115    private final RSConnectPublishSource source_;
116    private final boolean isUpdate_;
117 
118    public final static int PUBLISH_RPUBS  = 0;
119    public final static int PUBLISH_STATIC = 1;
120    public final static int PUBLISH_CODE   = 2;
121 }
122