Search in sources :

Example 1 with RSConnectDeploymentFiles

use of org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentFiles in project rstudio by rstudio.

the class RSConnectDeploy method populateDeploymentFiles.

private void populateDeploymentFiles(final ProgressIndicator indicator) {
    if (source_ == null)
        return;
    // dependencies; just inject it directly into the list.
    if (source_.isSelfContained() && source_.isStatic() && !source_.isWebsiteRmd()) {
        ArrayList<String> files = new ArrayList<String>();
        FileSystemItem selfContained = FileSystemItem.createFile(source_.getDeployFile());
        files.add(selfContained.getName());
        setFileList(files, null, null);
        setPrimaryFile(selfContained.getName());
        return;
    }
    // ternery operator maps to appropriate files to list for deployment:
    // website code    - website code directory 
    // static website  - website build directory
    // document        - R Markdown document
    // non-document    - Shiny app directory
    final String fileSource = source_.isDocument() ? source_.isWebsiteRmd() ? source_.isStatic() ? source_.getDeployDir() : source_.getWebsiteDir() : source_.getDeployFile() : source_.getDeployDir();
    indicator.onProgress("Collecting files...");
    server_.getDeploymentFiles(fileSource, asMultipleRmd_, new ServerRequestCallback<RSConnectDeploymentFiles>() {

        @Override
        public void onResponseReceived(RSConnectDeploymentFiles files) {
            if (files.getDirSize() > files.getMaxSize()) {
                indicator.onError("The item to be deployed (" + fileSource + ") " + "exceeds the maximum deployment size, which is " + StringUtil.formatFileSize(files.getMaxSize()) + "." + " Consider creating a new directory containing " + "only the content you wish to deploy.");
            } else {
                if (files.getDirList() == null || files.getDirList().length() == 0) {
                    indicator.onError("Could not determine the list of " + "files to deploy.");
                    indicator.onCompleted();
                }
                setFileList(JsArrayUtil.fromJsArrayString(files.getDirList()), fromPrevious_ != null ? fromPrevious_.getAdditionalFiles() : null, fromPrevious_ != null ? fromPrevious_.getIgnoredFiles() : null);
                if (!source_.isWebsiteRmd())
                    setPrimaryFile(FileSystemItem.createFile(source_.getDeployFile()).getName());
            }
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    indicator.clearProgress();
                }
            });
        }

        @Override
        public void onError(ServerError error) {
            // we need to have a list of files to deploy to proceed
            indicator.onError("Could not find files to deploy: \n\n" + error.getMessage());
            indicator.onCompleted();
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) RSConnectDeploymentFiles(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentFiles)

Aggregations

ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ArrayList (java.util.ArrayList)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 RSConnectDeploymentFiles (org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentFiles)1 ServerError (org.rstudio.studio.client.server.ServerError)1