use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class RSConnectPublishButton method renderThenPublish.
// for static content only: perform a just-in-time render if necessary and
// then publish the content
private void renderThenPublish(final String target, final RSConnectDeploymentRecord previous) {
// prevent re-entrancy
if (rmdInfoPending_)
return;
final Command renderCommand = new Command() {
@Override
public void execute() {
publishAfterRmdRender_ = previous;
rmdRenderPending_ = true;
anyRmdRenderPending_ = true;
if (commands_.knitDocument().isEnabled())
commands_.knitDocument().execute();
else if (commands_.previewHTML().isEnabled())
commands_.previewHTML().execute();
else
display_.showErrorMessage("Can't Render Document", "RStudio cannot render " + target + " for publishing.");
}
};
rmdInfoPending_ = true;
rmdServer_.getRmdOutputInfo(target, new ServerRequestCallback<RmdOutputInfo>() {
@Override
public void onResponseReceived(RmdOutputInfo response) {
if (response.isCurrent()) {
RenderedDocPreview preview = new RenderedDocPreview(target, response.getOutputFile(), true);
events_.fireEvent(RSConnectActionEvent.DeployDocEvent(preview, RSConnect.CONTENT_TYPE_DOCUMENT, previous));
} else {
renderCommand.execute();
}
rmdInfoPending_ = false;
}
@Override
public void onError(ServerError error) {
// if we failed to figure out whether we need to do a re-render,
// assume one is necessary
Debug.logError(error);
renderCommand.execute();
rmdInfoPending_ = false;
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class RSConnectPublishButton method rebuildPopupMenu.
// rebuilds the popup menu--this can happen when the menu is invoked; it can
// also happen when the button is created if we're aggressively checking
// publish status
private void rebuildPopupMenu(final ToolbarPopupMenu.DynamicPopupMenuCallback callback) {
final ToolbarPopupMenu menu = publishMenu_;
// prevent reentrancy
if (populating_) {
if (callback != null)
callback.onPopupMenu(menu);
return;
}
// handle case where we don't have a content path (i.e. plots)
if (contentPath_ == null) {
setPreviousDeployments(null);
if (callback != null)
callback.onPopupMenu(menu);
return;
}
// (unless we're forcefully repopulating)
if (populatedPath_ != null && populatedPath_.equals(contentPath_)) {
if (callback != null)
callback.onPopupMenu(menu);
return;
}
String contentPath = contentPath_;
boolean parent = false;
// CONTENT_TYPE_APP_SINGLE and their own deployment records)
if (contentType_ == RSConnect.CONTENT_TYPE_APP && StringUtil.getExtension(contentPath_).equalsIgnoreCase("r"))
parent = true;
// if this is a document in a website, use the parent path
if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE)
parent = true;
// apply parent path if needed
if (parent) {
FileSystemItem fsiContent = FileSystemItem.createFile(contentPath_);
contentPath = fsiContent.getParentPathString();
}
populating_ = true;
server_.getRSConnectDeployments(contentPath, outputPath_ == null ? "" : outputPath_, new ServerRequestCallback<JsArray<RSConnectDeploymentRecord>>() {
@Override
public void onResponseReceived(JsArray<RSConnectDeploymentRecord> recs) {
populatedPath_ = contentPath_;
populating_ = false;
// that are static (as we can't update them)
if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE && (docPreview_ == null || StringUtil.isNullOrEmpty(docPreview_.getOutputFile()))) {
JsArray<RSConnectDeploymentRecord> codeRecs = JsArray.createArray().cast();
for (int i = 0; i < recs.length(); i++) {
if (!recs.get(i).getAsStatic())
codeRecs.push(recs.get(i));
}
recs = codeRecs;
}
setPreviousDeployments(recs);
if (callback != null)
callback.onPopupMenu(menu);
}
@Override
public void onError(ServerError error) {
populating_ = false;
if (callback != null)
callback.onPopupMenu(menu);
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class RSConnect method configureShinyApp.
// Manage, step 2: Get the status of the applications from the server
private void configureShinyApp(final String dir, JsArray<RSConnectDeploymentRecord> records) {
if (records.length() == 0) {
display_.showMessage(GlobalDisplay.MSG_INFO, "No Deployments Found", "No application deployments were found for '" + dir + "'");
return;
}
// If we know the most recent deployment of the directory, act on that
// deployment by default
final ArrayList<RSConnectDeploymentRecord> recordList = new ArrayList<RSConnectDeploymentRecord>();
RSConnectDeploymentRecord lastRecord = dirState_.getLastDeployment(dir);
if (lastRecord != null) {
recordList.add(lastRecord);
}
for (int i = 0; i < records.length(); i++) {
RSConnectDeploymentRecord record = records.get(i);
if (lastRecord == null) {
recordList.add(record);
} else {
if (record.getUrl().equals(lastRecord.getUrl()))
recordList.set(0, record);
}
}
// We need to further filter the list by deployments that are
// eligible for termination (i.e. are currently running)
server_.getRSConnectAppList(recordList.get(0).getAccountName(), recordList.get(0).getServer(), new ServerRequestCallback<JsArray<RSConnectApplicationInfo>>() {
@Override
public void onResponseReceived(JsArray<RSConnectApplicationInfo> apps) {
configureShinyApp(dir, apps, recordList);
}
@Override
public void onError(ServerError error) {
display_.showErrorMessage("Error Listing Applications", error.getMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class RSConnect method onRSConnectDeployInitiated.
@Override
public void onRSConnectDeployInitiated(final RSConnectDeployInitiatedEvent event) {
// shortcut: when deploying static content we don't need to do any linting
if (event.getSettings().getAsStatic()) {
doDeployment(event);
return;
}
// get lint results for the file or directory being deployed, as
// appropriate
server_.getLintResults(event.getSource().getDeployKey(), new ServerRequestCallback<RSConnectLintResults>() {
@Override
public void onResponseReceived(RSConnectLintResults results) {
if (results.getErrorMessage().length() > 0) {
display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Lint Failed", "The content you tried to publish could not be checked " + "for errors. Do you want to proceed? \n\n" + results.getErrorMessage(), false, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Publish Anyway"
doDeployment(event);
indicator.onCompleted();
}
}, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Cancel"
indicator.onCompleted();
}
}, "Publish Anyway", "Cancel", false);
} else if (results.hasLint()) {
display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Publish Content Issues Found", "Some issues were found in your content, which may " + "prevent it from working correctly after publishing. " + "Do you want to review these issues or publish anyway? ", false, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Review Issues" -- we automatically show the
// markers so they're already behind the dialog.
indicator.onCompleted();
}
}, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Publish Anyway"
doDeployment(event);
indicator.onCompleted();
}
}, "Review Issues", "Publish Anyway", true);
} else {
// no lint and no errors -- good to go for deployment
doDeployment(event);
}
}
@Override
public void onError(ServerError error) {
// we failed to lint, which is not encouraging, but we don't want to
// fail the whole deployment lest a balky linter prevent people from
// getting their work published, so forge on ahead.
doDeployment(event);
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class RSAccountConnector method connectLocalAccount.
private void connectLocalAccount(final NewRSConnectAccountResult result, final ProgressIndicator indicator, final OperationWithInput<AccountConnectResult> onConnected) {
indicator.onProgress("Adding account...");
final RSConnectAuthUser user = result.getAuthUser();
final RSConnectServerInfo serverInfo = result.getServerInfo();
final RSConnectPreAuthToken token = result.getPreAuthToken();
server_.registerUserToken(serverInfo.getName(), result.getAccountNickname(), user.getId(), token, new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void result) {
onConnected.execute(AccountConnectResult.Successful);
}
@Override
public void onError(ServerError error) {
display_.showErrorMessage("Account Connect Failed", "Your account was authenticated successfully, but could " + "not be connected to RStudio. Make sure your installation " + "of the 'rsconnect' package is correct for the server " + "you're connecting to.\n\n" + serverInfo.getInfoString() + "\n" + error.getMessage());
onConnected.execute(AccountConnectResult.Failed);
}
});
}
Aggregations