code
stringlengths 25
201k
| docstring
stringlengths 19
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
51
| path
stringlengths 11
314
| url
stringlengths 62
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public Build getLastSuccessfulBuild() {
if (lastSuccessfulBuild == null) {
return Build.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastSuccessfulBuild);
}
}
|
@return The lastSuccessfulBuild. If {@link #lastSuccessfulBuild} has
never been run {@link Build#BUILD_HAS_NEVER_RUN} will be
returned.
|
getLastSuccessfulBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public boolean hasLastSuccessfulBuildRun() {
return lastSuccessfulBuild != null;
}
|
Check if the {@link #lastSuccessfulBuild} has been run or not.
@return <code>true</code> if the last successful build has been run
<code>false</code> otherwise.
|
hasLastSuccessfulBuildRun
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public Build getLastUnstableBuild() {
if (lastUnstableBuild == null) {
return Build.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastUnstableBuild);
}
}
|
@return The lastUnstableBuild. If {@link #lastUnstableBuild} has never
been run {@link Build#BUILD_HAS_NEVER_RUN} will be returned.
|
getLastUnstableBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public boolean hasLastUnstableBuildRun() {
return lastUnstableBuild != null;
}
|
Check if the {@link #lastUnstableBuild} has been run or not.
@return <code>true</code> if the last unstable build has been run
<code>false</code> otherwise.
|
hasLastUnstableBuildRun
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public Build getLastUnsuccessfulBuild() {
if (lastUnsuccessfulBuild == null) {
return Build.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastUnsuccessfulBuild);
}
}
|
@return The lastUnsuccessfulBuild. If {@link #lastUnsuccessfulBuild} has
never been run {@link Build#BUILD_HAS_NEVER_RUN} will be
returned.
|
getLastUnsuccessfulBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public List<Job> getDownstreamProjects() {
if (downstreamProjects == null) {
return Collections.emptyList();
} else {
return downstreamProjects.stream()
.map(SET_CLIENT(this.client))
.collect(toList());
}
}
|
@return the list of downstream projects. If no downstream projects exist
just return an empty list {@link Collections#emptyList()}.
|
getDownstreamProjects
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public Optional<Build> getBuildByNumber(final int buildNumber) {
return builds.stream().filter(isBuildNumberEqualTo(buildNumber)).findFirst();
}
|
Get a build by the given buildNumber.
@param buildNumber The number to select the build by.
@return The an Optional with the {@link Build} selected by the given buildnumber
|
getBuildByNumber
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public MavenModuleWithDetails getModule(String moduleName) throws IOException {
return client.get(getUrl() + moduleName, MavenModuleWithDetails.class);
}
|
Get a module of a {@link Job}
@param moduleName name of the {@link MavenModule}
@return The {@link MavenModuleWithDetails} selected by the given module name
@throws IOException in case of errors.
|
getModule
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public JobWithDetails updateDescription(String description) throws IOException {
return updateDescription(description, false);
}
|
Update the <code>description</code> of a Job.
@param description The description which should be set. If you like to
set an empty description you should use
{@link #EMPTY_DESCRIPTION}.
@throws IOException in case of errors.
|
updateDescription
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public JobWithDetails updateDescription(String description, boolean crumbFlag) throws IOException {
Objects.requireNonNull(description, "description is not allowed to be null.");
//JDK9+
// Map.of(...);
Map<String, String> params = Maps.newHashMap();
params.put("description", description);
client.post_form(this.getUrl() + "/submitDescription?", params, crumbFlag);
return this;
}
|
Update the <code>description</code> of a Job.
@param description The description which should be set. If you like to
set an empty description you should use
{@link #EMPTY_DESCRIPTION}.
@param crumbFlag <code>true</code> or <code>false</code>.
@throws IOException in case of errors.
|
updateDescription
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public JobWithDetails clearDescription() throws IOException {
return updateDescription(EMPTY_DESCRIPTION);
}
|
clear the description of a job.
@throws IOException in case of errors.
|
clearDescription
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/JobWithDetails.java
|
Apache-2.0
|
public List<MavenBuild> getAllBuilds(Range range) throws IOException {
String path = "/" + "job/" + EncodingUtils.encode(this.getName())
+ "?tree=allBuilds[number[*],url[*],queueId[*]]";
try {
List<MavenBuild> builds = client.get(path + range.getRangeString(), AllMavenBuilds.class).getAllBuilds();
if (builds == null) {
return Collections.emptyList();
} else {
return builds.stream()
.map(SET_CLIENT(this.client))
.collect(toList());
}
} catch (HttpResponseException e) {
// TODO: Thinks about a better handline if the job does not exist?
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
// TODO: Check this if this is necessary or a good idea?
return null;
}
throw e;
}
}
|
<ul>
<li>{M,N}: From the M-th element (inclusive) to the N-th element
(exclusive).</li>
<li>{M,}: From the M-th element (inclusive) to the end.</li>
<li>{,N}: From the first element (inclusive) to the N-th element
(exclusive). The same as {0,N}.</li>
<li>{N}: Just retrieve the N-th element. The same as {N,N+1}.</li>
</ul>
<b>Note: At the moment there seemed to be no option to get the number of
existing builds for a job. The only option is to get all builds via
{@link #getAllBuilds()}.</b>
@param range
{@link Range}
@return the list of {@link Build}. In case of no builds have been
executed yet return {@link Collections#emptyList()}.
@throws IOException
in case of an error.
|
getAllBuilds
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
public MavenBuild getFirstBuild() {
if (firstBuild == null) {
return MavenBuild.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(firstBuild);
}
}
|
@return The firstBuild. If {@link #firstBuild} has never been run
{@link MavenBuild#BUILD_HAS_NEVER_RUN} will be returned.
|
getFirstBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
public MavenBuild getLastBuild() {
if (lastBuild == null) {
return MavenBuild.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastBuild);
}
}
|
@return The lastBuild. If {@link #lastBuild} has never been run
{@link MavenBuild#BUILD_HAS_NEVER_RUN} will be returned.
|
getLastBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
public MavenBuild getLastCompletedBuild() {
if (lastCompletedBuild == null) {
return MavenBuild.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastCompletedBuild);
}
}
|
@return The lastCompletedBuild. If {@link #lastCompletedBuild} has never
been run {@link MavenBuild#BUILD_HAS_NEVER_RUN} will be returned.
|
getLastCompletedBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
public MavenBuild getLastFailedBuild() {
if (lastFailedBuild == null) {
return MavenBuild.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastFailedBuild);
}
}
|
@return The lastFailedBuild. If {@link #lastFailedBuild} has never been
run {@link MavenBuild#BUILD_HAS_NEVER_RUN} will be returned.
|
getLastFailedBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
public MavenBuild getLastStableBuild() {
if (lastStableBuild == null) {
return MavenBuild.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastStableBuild);
}
}
|
@return The lastStableBuild. If {@link #lastStableBuild} has never been
run {@link MavenBuild#BUILD_HAS_NEVER_RUN} will be returned.
|
getLastStableBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
public MavenBuild getLastSuccessfulBuild() {
if (lastSuccessfulBuild == null) {
return MavenBuild.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastSuccessfulBuild);
}
}
|
@return The lastSuccessfulBuild. If {@link #lastSuccessfulBuild} has
never been run {@link MavenBuild#BUILD_HAS_NEVER_RUN} will be
returned.
|
getLastSuccessfulBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
public MavenBuild getLastUnstableBuild() {
if (lastUnstableBuild == null) {
return MavenBuild.BUILD_HAS_NEVER_RUN;
} else {
return buildWithClient(lastUnstableBuild);
}
}
|
@return The lastUnstableBuild. If {@link #lastUnstableBuild} has never
been run {@link MavenBuild#BUILD_HAS_NEVER_RUN} will be returned.
|
getLastUnstableBuild
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-jenkins/src/main/java/com/baiyi/opscloud/datasource/jenkins/model/MavenJobWithDetails.java
|
Apache-2.0
|
@Override
public AssetContainer toAssetContainer(DatasourceInstance dsInstance) {
DatasourceInstanceAsset asset = DatasourceInstanceAsset.builder()
.instanceUuid(dsInstance.getUuid())
.assetId(this.key)
.name(this.name)
.assetKey(this.key)
.assetKey2(this.revision)
.isActive(true)
.assetType(DsAssetTypeConstants.SONAR_PROJECT.name())
.kind("project")
.build();
return AssetContainerBuilder.newBuilder()
.paramAsset(asset)
.paramProperty("revision", this.revision)
.paramProperty("visibility", this.visibility)
.build();
}
|
{
"organization": "my-org-1",
"id": "project-uuid-1",
"key": "project-key-1",
"name": "Project Name 1",
"qualifier": "TRK",
"visibility": "public",
"lastAnalysisDate": "2017-03-01T11:39:03+0300",
"revision": "cfb82f55c6ef32e61828c4cb3db2da12795fd767"
}
|
toAssetContainer
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-sonar/src/main/java/com/baiyi/opscloud/datasource/sonar/entity/base/BaseSonarElement.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-sonar/src/main/java/com/baiyi/opscloud/datasource/sonar/entity/base/BaseSonarElement.java
|
Apache-2.0
|
public static List<Map<String, String>> toHosts(List<String> hostids) {
List<Map<String, String>> hosts = Lists.newArrayList();
hostids.forEach(id -> {
Map<String, String> hostid = Maps.newHashMap();
hostid.put(HOSTID, id);
hosts.add(hostid);
});
return hosts;
}
|
{
"jsonrpc": "2.0",
"method": "host.massupdate",
"params": {
"hosts": [
{
"hostid": "69665"
},
{
"hostid": "69666"
}
],
"status": 0
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
@param hostids
@return
|
toHosts
|
java
|
ixrjog/opscloud4
|
opscloud-datasource-zabbix/src/main/java/com/baiyi/opscloud/zabbix/ZabbixUtil.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-datasource-zabbix/src/main/java/com/baiyi/opscloud/zabbix/ZabbixUtil.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.CLIENT_BAD_TYPE;
}
|
Creates a new GuacamoleClientBadTypeException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientBadTypeException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientBadTypeException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.CLIENT_BAD_REQUEST;
}
|
Creates a new GuacamoleException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.CLIENT_OVERRUN;
}
|
Creates a new GuacamoleClientOverrunException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientOverrunException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientOverrunException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.CLIENT_TIMEOUT;
}
|
Creates a new GuacamoleClientTimeoutException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientTimeoutException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientTimeoutException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.CLIENT_TOO_MANY;
}
|
Creates a new GuacamoleClientTooManyException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientTooManyException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleClientTooManyException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return super.getStatus();
}
|
Creates a new GuacamoleConnectionClosedException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleConnectionClosedException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleConnectionClosedException.java
|
Apache-2.0
|
public GuacamoleStatus getStatus() {
return GuacamoleStatus.SERVER_ERROR;
}
|
Returns the Guacamole status associated with this exception. This status
can then be easily translated into an HTTP error code or Guacamole
protocol error code.
@return The corresponding Guacamole status.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleException.java
|
Apache-2.0
|
public int getHttpStatusCode() {
return getStatus().getHttpStatusCode();
}
|
Returns the most applicable HTTP status code that can be associated
with this exception.
@return
An integer representing the most applicable HTTP status code
associated with this exception.
|
getHttpStatusCode
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleException.java
|
Apache-2.0
|
public int getWebSocketCode() {
return getStatus().getWebSocketCode();
}
|
Returns the most applicable WebSocket status code that can be
associated with this exception.
@return
An integer representing the most applicable WebSocket status
code associated with this exception.
|
getWebSocketCode
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.RESOURCE_CLOSED;
}
|
Creates a new GuacamoleResourceClosedException with the given cause.
@param cause
The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleResourceClosedException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleResourceClosedException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.RESOURCE_CONFLICT;
}
|
Creates a new GuacamoleResourceConflictException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleResourceConflictException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleResourceConflictException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.RESOURCE_NOT_FOUND;
}
|
Creates a new GuacamoleResourceNotFoundException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleResourceNotFoundException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleResourceNotFoundException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.CLIENT_FORBIDDEN;
}
|
Creates a new GuacamoleSecurityException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSecurityException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSecurityException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.SERVER_BUSY;
}
|
Creates a new GuacamoleServerBusyException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleServerBusyException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleServerBusyException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.SESSION_CLOSED;
}
|
Creates a new GuacamoleSessionClosedException with the given cause.
@param cause
The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSessionClosedException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSessionClosedException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.SESSION_CONFLICT;
}
|
Creates a new GuacamoleSessionConflictException with the given cause.
@param cause
The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSessionConflictException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSessionConflictException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.SESSION_TIMEOUT;
}
|
Creates a new GuacamoleSessionTimeoutException with the given cause.
@param cause
The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSessionTimeoutException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleSessionTimeoutException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.CLIENT_UNAUTHORIZED;
}
|
Creates a new GuacamoleUnauthorizedException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUnauthorizedException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUnauthorizedException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.UNSUPPORTED;
}
|
Creates a new GuacamoleUnsupportedException with the given cause.
@param cause The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUnsupportedException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUnsupportedException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.UPSTREAM_NOT_FOUND;
}
|
Creates a new GuacamoleUpstreamNotFoundException with the given cause.
@param cause
The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUpstreamNotFoundException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUpstreamNotFoundException.java
|
Apache-2.0
|
@Override
public GuacamoleStatus getStatus() {
return GuacamoleStatus.UPSTREAM_UNAVAILABLE;
}
|
Creates a new GuacamoleUpstreamUnavailableException with the given
cause.
@param cause
The cause of this exception.
|
getStatus
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUpstreamUnavailableException.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/GuacamoleUpstreamUnavailableException.java
|
Apache-2.0
|
@Override
public GuacamoleReader acquireReader() {
readerLock.lock();
return getSocket().getReader();
}
|
Acquires exclusive read access to the Guacamole instruction stream
and returns a GuacamoleReader for reading from that stream.
@return A GuacamoleReader for reading from the Guacamole instruction
stream.
|
acquireReader
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
Apache-2.0
|
@Override
public void releaseReader() {
readerLock.unlock();
}
|
Relinquishes exclusive read access to the Guacamole instruction
stream. This function should be called whenever a thread finishes using
a GuacamoleTunnel's GuacamoleReader.
|
releaseReader
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
Apache-2.0
|
@Override
public boolean hasQueuedReaderThreads() {
return readerLock.hasQueuedThreads();
}
|
Returns whether there are threads waiting for read access to the
Guacamole instruction stream.
@return true if threads are waiting for read access the Guacamole
instruction stream, false otherwise.
|
hasQueuedReaderThreads
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
Apache-2.0
|
@Override
public GuacamoleWriter acquireWriter() {
writerLock.lock();
return getSocket().getWriter();
}
|
Acquires exclusive write access to the Guacamole instruction stream
and returns a GuacamoleWriter for writing to that stream.
@return A GuacamoleWriter for writing to the Guacamole instruction
stream.
|
acquireWriter
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/net/AbstractGuacamoleTunnel.java
|
Apache-2.0
|
default String getProtocol() {
return null;
}
|
Returns the name of the protocol to be used. If the protocol is not
known or the implementation refuses to reveal the underlying protocol,
null is returned.
<p>Implementations <strong>should</strong> aim to expose the name of the
underlying protocol, such that protocol-specific responses like the
"required" and "argv" instructions can be handled correctly by code
consuming the GuacamoleSocket.
@return
The name of the protocol to be used, or null if this information is
not available.
|
getProtocol
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/net/GuacamoleSocket.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/net/GuacamoleSocket.java
|
Apache-2.0
|
private static void handleReceivedError(GuacamoleInstruction instruction)
throws GuacamoleException {
// Provide reasonable default error message for invalid "error"
// instructions that fail to provide one
String message = "Internal error within guacd / protocol handling.";
// Consider all error instructions without a corresponding status code
// to be server errors
GuacamoleStatus status = GuacamoleStatus.SERVER_ERROR;
// Parse human-readable message from "error" instruction, warning if no
// message was given
List<String> args = instruction.getArgs();
if (!args.isEmpty())
message = args.getFirst();
else
log.debug("Received \"error\" instruction with no corresponding message.");
// Parse the status code from the received error instruction, warning
// if the status code is missing or invalid
if (args.size() >= 2) {
try {
// Translate numeric status code into a GuacamoleStatus
int statusCode = Integer.parseInt(args.get(1));
GuacamoleStatus parsedStatus = GuacamoleStatus.fromGuacamoleStatusCode(statusCode);
if (parsedStatus != null)
status = parsedStatus;
else
log.debug("Received \"error\" instruction with unknown/invalid status code: {}", statusCode);
}
catch (NumberFormatException e) {
log.debug("Received \"error\" instruction with non-numeric status code.", e);
}
}
else
log.debug("Received \"error\" instruction without status code.");
// Convert parsed status code and message to a GuacamoleException
throw status.toException(message);
}
|
Parses the given "error" instruction, throwing a GuacamoleException that
corresponds to its status code and message.
@param instruction
The "error" instruction to parse.
@throws GuacamoleException
A GuacamoleException that corresponds to the status code and message
present within the given "error" instruction.
|
handleReceivedError
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
|
Apache-2.0
|
private GuacamoleInstruction expect(GuacamoleReader reader, String opcode)
throws GuacamoleException {
// Wait for an instruction
GuacamoleInstruction instruction = reader.readInstruction();
if (instruction == null)
throw new GuacamoleServerException("End of stream while waiting for \"" + opcode + "\".");
// Report connection closure if server explicitly disconnects
if ("disconnect".equals(instruction.getOpcode()))
throw new GuacamoleConnectionClosedException("Server disconnected while waiting for \"" + opcode + "\".");
// Pass through any received errors as GuacamoleExceptions
if ("error".equals(instruction.getOpcode()))
handleReceivedError(instruction);
// Ensure instruction has expected opcode
if (!instruction.getOpcode().equals(opcode))
throw new GuacamoleServerException("Expected \"" + opcode + "\" instruction but instead received \"" + instruction.getOpcode() + "\".");
return instruction;
}
|
Waits for the instruction having the given opcode, returning that
instruction once it has been read. If the instruction is never read,
an exception is thrown.
Respects server control instructions that are allowed during the handshake
phase, namely {@code error} and {@code disconnect}.
@param reader
The reader to read instructions from.
@param opcode
The opcode of the instruction we are expecting.
@return
The instruction having the given opcode.
@throws GuacamoleException
If an error occurs while reading, or if the expected instruction is
not read.
|
expect
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
|
Apache-2.0
|
public GuacamoleConfiguration getConfiguration() {
return config;
}
|
Returns the GuacamoleConfiguration used to configure this
ConfiguredGuacamoleSocket.
@return The GuacamoleConfiguration used to configure this
ConfiguredGuacamoleSocket.
|
getConfiguration
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java
|
Apache-2.0
|
private static void handleUpstreamErrors(GuacamoleInstruction instruction)
throws GuacamoleUpstreamException {
// Ignore error instructions which are missing the status code
List<String> args = instruction.getArgs();
if (args.size() < 2) {
log.debug("Received \"error\" instruction without status code.");
return;
}
// Parse the status code from the received error instruction
int statusCode;
try {
statusCode = Integer.parseInt(args.get(1));
}
catch (NumberFormatException e) {
log.debug("Received \"error\" instruction with non-numeric status code.", e);
return;
}
// Translate numeric status code into a GuacamoleStatus
GuacamoleStatus status = GuacamoleStatus.fromGuacamoleStatusCode(statusCode);
if (status == null) {
log.debug("Received \"error\" instruction with unknown/invalid status code: {}", statusCode);
return;
}
// Only handle error instructions related to the upstream remote desktop
switch (status) {
// Generic upstream error
case UPSTREAM_ERROR:
throw new GuacamoleUpstreamException(args.getFirst());
// Upstream is unreachable
case UPSTREAM_NOT_FOUND:
throw new GuacamoleUpstreamNotFoundException(args.getFirst());
// Upstream did not respond
case UPSTREAM_TIMEOUT:
throw new GuacamoleUpstreamTimeoutException(args.getFirst());
// Upstream is refusing the connection
case UPSTREAM_UNAVAILABLE:
throw new GuacamoleUpstreamUnavailableException(args.getFirst());
}
}
|
Parses the given "error" instruction, throwing an exception if the
instruction represents an error from the upstream remote desktop.
@param instruction
The "error" instruction to parse.
@throws GuacamoleUpstreamException
If the "error" instruction represents an error from the upstream
remote desktop.
|
handleUpstreamErrors
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/FailoverGuacamoleSocket.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/FailoverGuacamoleSocket.java
|
Apache-2.0
|
public void setOptimalScreenWidth(int optimalScreenWidth) {
this.optimalScreenWidth = optimalScreenWidth;
}
|
Sets the client's optimal screen width.
@param optimalScreenWidth The optimal screen width of the client.
|
setOptimalScreenWidth
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
Apache-2.0
|
public void setOptimalScreenHeight(int optimalScreenHeight) {
this.optimalScreenHeight = optimalScreenHeight;
}
|
Sets the client's optimal screen height.
@param optimalScreenHeight The optimal screen height of the client.
|
setOptimalScreenHeight
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
Apache-2.0
|
public void setOptimalResolution(int optimalResolution) {
this.optimalResolution = optimalResolution;
}
|
Sets the resolution of the screen if the optimal width and height are
used, in DPI.
@param optimalResolution The optimal screen resolution in DPI.
|
setOptimalResolution
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
Apache-2.0
|
public void setTimezone(String timezone) {
this.timezone = timezone;
}
|
Set the string value of the timezone, or null if the timezone will not
be provided by the client. Valid timezones are specified in IANA zone
key format (aka Olson time zone database or tz database).
@param timezone
The string value of the timezone reported by the client, in tz
database format, or null if the timezone is not provided by the
client.
|
setTimezone
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleClientInformation.java
|
Apache-2.0
|
public void setProtocol(String protocol) {
this.protocol = protocol;
}
|
Sets the name of the protocol to be used. If no connection is being
joined (a new connection is being established), this value must be set.
<p>If a connection is being joined, <strong>this value should still be
set</strong> to ensure that protocol-specific responses like the
"required" and "argv" instructions can be understood in their proper
context by other code that may consume this GuacamoleConfiguration like
{@link ConfiguredGuacamoleSocket}.
<p>If this value is unavailable or remains unset, it is still possible
to join an established connection using
{@link #setConnectionID(String)}, however protocol-specific
responses like the "required" and "argv" instructions might not be
possible to handle correctly if the underlying protocol is not made
available through some other means to the client receiving those
responses.
@param protocol
The name of the protocol to be used.
|
setProtocol
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
Apache-2.0
|
public String getParameter(String name) {
return parameters.get(name);
}
|
Returns the value set for the parameter with the given name, if any.
@param name The name of the parameter to return the value for.
@return The value of the parameter with the given name, or null if
that parameter has not been set.
|
getParameter
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
Apache-2.0
|
public void setParameter(String name, String value) {
parameters.put(name, value);
}
|
Sets the value for the parameter with the given name.
@param name The name of the parameter to set the value for.
@param value The value to set for the parameter with the given name.
|
setParameter
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
Apache-2.0
|
public Set<String> getParameterNames() {
return Collections.unmodifiableSet(parameters.keySet());
}
|
Returns a set of all currently defined parameter names. Each name
corresponds to a parameter that has a value set on this
GuacamoleConfiguration via setParameter().
@return A set of all currently defined parameter names.
|
getParameterNames
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
Apache-2.0
|
public void setParameters(Map<String, String> parameters) {
this.parameters.clear();
this.parameters.putAll(parameters);
}
|
Replaces all current parameters with the parameters defined within the
given map. Key/value pairs within the map represent parameter name/value
pairs.
@param parameters
A map which contains all parameter name/value pairs as key/value
pairs.
|
setParameters
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleConfiguration.java
|
Apache-2.0
|
private static void appendElement(StringBuilder buff, String element) {
buff.append(element.codePointCount(0, element.length()));
buff.append('.');
buff.append(element);
}
|
Appends the given value to the provided StringBuilder as a Guacamole
instruction element, including length prefix.
@param buff
The StringBuilder to append the element to.
@param element
The string value of the element to append.
|
appendElement
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleInstruction.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleInstruction.java
|
Apache-2.0
|
@Override
public String toString() {
// Avoid rebuilding Guacamole protocol form of instruction if already
// known
if (protocolForm == null) {
StringBuilder buff = new StringBuilder();
// Write opcode
appendElement(buff, opcode);
// Write argument values
for (String value : args) {
buff.append(',');
appendElement(buff, value);
}
// Write terminator
buff.append(';');
// Cache result for future calls
protocolForm = buff.toString();
}
return protocolForm;
}
|
Returns this GuacamoleInstruction in the form it would be sent over the
Guacamole protocol.
@return
This GuacamoleInstruction in the form it would be sent over the
Guacamole protocol.
|
toString
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleInstruction.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleInstruction.java
|
Apache-2.0
|
public int append(char[] chunk, int offset, int length) throws GuacamoleException {
int charsParsed = 0;
// Do not exceed maximum number of elements
if (elementCount == INSTRUCTION_MAX_ELEMENTS && state != State.COMPLETE) {
state = State.ERROR;
throw new GuacamoleServerException("Instruction contains too many elements.");
}
// Parse element length
if (state == State.PARSING_LENGTH) {
int parsedLength = elementLength;
while (charsParsed < length) {
// Pull next character
char c = chunk[offset + charsParsed++];
// If digit, add to length
if (c >= '0' && c <= '9')
parsedLength = parsedLength*10 + c - '0';
// If period, switch to parsing content
else if (c == '.') {
state = State.PARSING_CONTENT;
break;
}
// If not digit, parse error
else {
state = State.ERROR;
throw new GuacamoleServerException("Non-numeric character in element length.");
}
}
// If too long, parse error
if (parsedLength > INSTRUCTION_MAX_LENGTH) {
state = State.ERROR;
throw new GuacamoleServerException("Instruction exceeds maximum length.");
}
// Save length
elementCodepoints = elementLength = parsedLength;
} // end parse length
// Parse element content, if available
while (state == State.PARSING_CONTENT && charsParsed + elementLength + 1 <= length) {
// Read element (which may not match element length if surrogate
// characters are present)
String element = new String(chunk, offset + charsParsed, elementLength);
// Verify element contains the number of whole Unicode characters
// expected, scheduling a future read if we don't yet have enough
// characters
int codepoints = element.codePointCount(0, element.length());
if (codepoints < elementCodepoints) {
elementLength += elementCodepoints - codepoints;
continue;
}
// If the current element ends with a character involving both
// a high and low surrogate, elementLength points to the low
// surrogate and NOT the element terminator. We must correct the
// length and reevaluate.
else if (Character.isSurrogatePair(chunk[offset + charsParsed + elementLength - 1],
chunk[offset + charsParsed + elementLength])) {
elementLength++;
continue;
}
charsParsed += elementLength;
elementLength = 0;
// Add element to currently parsed elements
elements[elementCount++] = element;
// Read terminator char following element
char terminator = chunk[offset + charsParsed++];
switch (terminator) {
// If semicolon, store end-of-instruction
case ';':
state = State.COMPLETE;
parsedInstruction = new GuacamoleInstruction(elements[0],
Arrays.asList(elements).subList(1, elementCount));
break;
// If comma, move on to next element
case ',':
state = State.PARSING_LENGTH;
break;
// Otherwise, parse error
default:
state = State.ERROR;
throw new GuacamoleServerException("Element terminator of instruction was not ';' nor ','");
}
} // end parse content
return charsParsed;
}
|
Appends data from the given buffer to the current instruction.
@param chunk
The buffer containing the data to append.
@param offset
The offset within the buffer where the data begins.
@param length
The length of the data to append.
@return
The number of characters appended, or 0 if complete instructions
have already been parsed and must be read via next() before more
data can be appended.
@throws GuacamoleException
If an error occurs while parsing the new data.
|
append
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleParser.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleParser.java
|
Apache-2.0
|
public boolean isSupported(GuacamoleProtocolVersion version) {
return version.atLeast(this.version);
}
|
Returns whether this capability is supported in the given Guacamole
protocol version.
@param version
The Guacamole protocol version to check.
@return
true if this capability is supported by the given protocol version,
false otherwise.
|
isSupported
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolCapability.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolCapability.java
|
Apache-2.0
|
public boolean atLeast(GuacamoleProtocolVersion otherVersion) {
// If major is not the same, return inequality
if (major != otherVersion.major())
return this.major > otherVersion.major();
// Major is the same, but minor is not, return minor inequality
if (minor != otherVersion.minor())
return this.minor > otherVersion.minor();
// Major and minor are equal, so return patch inequality
return patch >= otherVersion.patch();
}
|
Returns whether this GuacamoleProtocolVersion is at least as recent as
(greater than or equal to) the given version.
@param otherVersion The version to which this GuacamoleProtocolVersion should be compared.
@return true if this object is at least as recent as the given version,
false if the given version is newer.
|
atLeast
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolVersion.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolVersion.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleServerException(message);
}
|
The operation could not be performed due to an internal failure.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleServerBusyException(message);
}
|
The operation could not be performed as the server is busy.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleUpstreamTimeoutException(message);
}
|
The operation could not be performed because the upstream server is not
responding.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleUpstreamException(message);
}
|
The operation was unsuccessful due to an error or otherwise unexpected
condition of the upstream server.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleResourceNotFoundException(message);
}
|
The operation could not be performed as the requested resource does not
exist.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleResourceConflictException(message);
}
|
The operation could not be performed as the requested resource is already
in use.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleResourceClosedException(message);
}
|
The operation could not be performed as the requested resource is now
closed.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleUpstreamNotFoundException(message);
}
|
The operation could not be performed because the upstream server does
not appear to exist.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleUpstreamUnavailableException(message);
}
|
The operation could not be performed because the upstream server is not
available to service the request.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleSessionConflictException(message);
}
|
The session within the upstream server has ended because it conflicted
with another session.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleSessionTimeoutException(message);
}
|
The session within the upstream server has ended because it appeared to
be inactive.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleSessionClosedException(message);
}
|
The session within the upstream server has been forcibly terminated.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleClientException(message);
}
|
The operation could not be performed because bad parameters were given.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleUnauthorizedException(message);
}
|
Permission was denied to perform the operation, as the user is not yet
authorized (not yet logged in, for example). As HTTP 401 has implications
for HTTP-specific authorization schemes, this status continues to map to
HTTP 403 ("Forbidden"). To do otherwise would risk unintended effects.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleSecurityException(message);
}
|
Permission was denied to perform the operation, and this operation will
not be granted even if the user is authorized.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleClientTimeoutException(message);
}
|
The client took too long to respond.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleClientOverrunException(message);
}
|
The client sent too much data.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleClientBadTypeException(message);
}
|
The client sent data of an unsupported or unexpected type.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
@Override
public GuacamoleException toException(String message) {
return new GuacamoleClientTooManyException(message);
}
|
The operation failed because the current client is already using too
many resources.
|
toException
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
public int getGuacamoleStatusCode() {
return guac_code;
}
|
Returns the corresponding Guacamole protocol status code.
@return The corresponding Guacamole protocol status code.
|
getGuacamoleStatusCode
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
public static GuacamoleStatus fromGuacamoleStatusCode(int code) {
// Search for a GuacamoleStatus having the given status code
for (GuacamoleStatus status : values()) {
if (status.getGuacamoleStatusCode() == code)
return status;
}
// No such status found
return null;
}
|
Returns the GuacamoleStatus corresponding to the given Guacamole
protocol status code. If no such GuacamoleStatus is defined, null is
returned.
@param code
The Guacamole protocol status code to translate into a
GuacamoleStatus.
@return
The GuacamoleStatus corresponding to the given Guacamole protocol
status code, or null if no such GuacamoleStatus is defined.
|
fromGuacamoleStatusCode
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/protocol/GuacamoleStatus.java
|
Apache-2.0
|
public void access() {
lastAccessedTime = System.currentTimeMillis();
}
|
Updates this tunnel, marking it as recently accessed.
|
access
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnel.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnel.java
|
Apache-2.0
|
@Override
public void run() {
// Get current time
long now = System.currentTimeMillis();
// For each tunnel, close and remove any tunnels which have expired
Iterator<Map.Entry<String, GuacamoleHTTPTunnel>> entries = tunnelMap.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, GuacamoleHTTPTunnel> entry = entries.next();
GuacamoleHTTPTunnel tunnel = entry.getValue();
// Get elapsed time since last access
long age = now - tunnel.getLastAccessedTime();
// If tunnel is too old, close and remove it
if (age >= tunnelTimeout) {
// Remove old entry
log.debug("HTTP tunnel \"{}\" has timed out.", entry.getKey());
entries.remove();
// Attempt to close tunnel
try {
tunnel.close();
}
catch (GuacamoleException e) {
log.debug("Unable to close expired HTTP tunnel.", e);
}
}
} // end for each tunnel
}
|
Creates a new task which automatically closes and removes tunnels
which have not been accessed for at least the given number of
milliseconds.
@param tunnelTimeout
The maximum amount of time to allow between separate tunnel
read/write requests, in milliseconds.
|
run
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
Apache-2.0
|
public GuacamoleHTTPTunnel get(String tunnelSessionToken) {
// Update the last access time
GuacamoleHTTPTunnel tunnel = tunnelMap.get(tunnelSessionToken);
if (tunnel != null)
tunnel.access();
// Return tunnel, if any
return tunnel;
}
|
Returns the GuacamoleTunnel associated with the given tunnel-specific
session token, wrapped within a GuacamoleHTTPTunnel. If the no tunnel
is associated with the given token, null is returned.
@param tunnelSessionToken
The tunnel-specific session token of the HTTP tunnel to retrieve.
@return
The GuacamoleTunnel associated with the given tunnel-specific
session token, wrapped within a GuacamoleHTTPTunnel, if such a
tunnel exists, or null if there is no such tunnel.
|
get
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
Apache-2.0
|
public void put(String tunnelSessionToken, GuacamoleTunnel tunnel) {
tunnelMap.put(tunnelSessionToken, new GuacamoleHTTPTunnel(tunnel));
}
|
Registers that a new connection has been established using HTTP via the
given GuacamoleTunnel.
@param tunnelSessionToken
The tunnel-specific session token of the HTTP tunnel being added
(registered).
@param tunnel
The GuacamoleTunnel being registered, its associated connection
having just been established via HTTP.
|
put
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
Apache-2.0
|
public GuacamoleHTTPTunnel remove(String tunnelSessionToken) {
return tunnelMap.remove(tunnelSessionToken);
}
|
Removes the GuacamoleTunnel associated with the given tunnel-specific
session token, if such a tunnel exists. The original tunnel is returned
wrapped within a GuacamoleHTTPTunnel.
@param tunnelSessionToken
The tunnel-specific session token of the HTTP tunnel to remove
(deregister).
@return
The GuacamoleTunnel having the given tunnel-specific session token,
if such a tunnel exists, wrapped within a GuacamoleHTTPTunnel, or
null if no such tunnel exists and no removal was performed.
|
remove
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelMap.java
|
Apache-2.0
|
protected String generateToken() {
byte[] bytes = new byte[33];
secureRandom.nextBytes(bytes);
return encoder.encodeToString(bytes);
}
|
Generates a new, securely-random session token that may be used to
represent the ongoing communication session of a distinct HTTP tunnel
connection.
@return
A new, securely-random session token.
|
generateToken
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
@Deprecated
protected void registerTunnel(GuacamoleTunnel tunnel) {
registerTunnel(tunnel.getUUID().toString(), tunnel);
}
|
Registers the given tunnel such that future read/write requests to that
tunnel will be properly directed.
@deprecated
This function has been deprecated in favor of {@link #registerTunnel(String, GuacamoleTunnel)},
which decouples identification of HTTP tunnel sessions from the
tunnel UUID.
@param tunnel
The tunnel to register.
|
registerTunnel
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
protected void registerTunnel(String tunnelSessionToken, GuacamoleTunnel tunnel) {
tunnels.put(tunnelSessionToken, tunnel);
logger.debug("Registered tunnel \"{}\".", tunnel.getUUID());
}
|
Registers the given HTTP tunnel such that future read/write requests
including the given tunnel-specific session token will be properly
directed. The session token must be unpredictable (securely-random) and
unique across all active HTTP tunnels. It is recommended that each HTTP
tunnel session token be obtained through calling {@link #generateToken()}.
@param tunnelSessionToken
The tunnel-specific session token to associate with the HTTP tunnel
being registered.
@param tunnel
The tunnel to register.
|
registerTunnel
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
@Deprecated
protected void deregisterTunnel(GuacamoleTunnel tunnel) {
deregisterTunnel(tunnel.getUUID().toString());
}
|
Deregisters the given tunnel such that future read/write requests to
that tunnel will be rejected.
@deprecated
This function has been deprecated in favor of {@link #deregisterTunnel(String)},
which decouples identification of HTTP tunnel sessions from the
tunnel UUID.
@param tunnel
The tunnel to deregister.
|
deregisterTunnel
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
protected void deregisterTunnel(String tunnelSessionToken) {
GuacamoleTunnel tunnel = tunnels.remove(tunnelSessionToken);
if (tunnel != null)
logger.debug("Deregistered tunnel \"{}\".", tunnel.getUUID());
}
|
Deregisters the HTTP tunnel associated with the given tunnel-specific
session token such that future read/write requests to that tunnel will
be rejected. Each HTTP tunnel must be associated with a session token
unique to that tunnel via a call {@link #registerTunnel(String, GuacamoleTunnel)}.
@param tunnelSessionToken
The tunnel-specific session token associated with the HTTP tunnel
being deregistered.
|
deregisterTunnel
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
protected void sendError(HttpServletResponse response, int guacamoleStatusCode,
int guacamoleHttpCode, String message)
throws ServletException {
try {
// If response not committed, send error code and message
if (!response.isCommitted()) {
response.addHeader("Guacamole-Status-Code", Integer.toString(guacamoleStatusCode));
response.addHeader("Guacamole-Error-Message", message);
response.sendError(guacamoleHttpCode);
}
}
catch (IOException ioe) {
// If unable to send error at all due to I/O problems,
// rethrow as servlet exception
throw new ServletException(ioe);
}
}
|
Sends an error on the given HTTP response using the information within
the given GuacamoleStatus.
@param response
The HTTP response to use to send the error.
@param guacamoleStatusCode
The GuacamoleStatus code to send.
@param guacamoleHttpCode
The numeric HTTP code to send.
@param message
The human-readable error message to send.
@throws ServletException
If an error prevents sending of the error code.
|
sendError
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
protected void handleTunnelRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
try {
String query = request.getQueryString();
if (query == null)
throw new GuacamoleClientException("No query string provided.");
// If connect operation, call doConnect() and return tunnel
// session token and UUID in response
if (query.equals("connect")) {
GuacamoleTunnel tunnel = doConnect(request);
if (tunnel == null)
throw new GuacamoleResourceNotFoundException("No tunnel created.");
// Register newly-created tunnel
String tunnelSessionToken = generateToken();
registerTunnel(tunnelSessionToken, tunnel);
try {
// Ensure buggy browsers do not cache response
response.setHeader("Cache-Control", "no-cache");
// Include tunnel session token for future requests
response.setHeader(TUNNEL_TOKEN_HEADER_NAME, tunnelSessionToken);
// Send UUID to client
response.getWriter().print(tunnel.getUUID().toString());
}
catch (IOException e) {
throw new GuacamoleServerException(e);
}
// Connection successful
return;
}
// Pull tunnel-specific session token from request
String tunnelSessionToken = request.getHeader(TUNNEL_TOKEN_HEADER_NAME);
if (tunnelSessionToken == null)
throw new GuacamoleClientException("The HTTP tunnel session "
+ "token is required for all requests after "
+ "connecting.");
// Dispatch valid tunnel read/write operations
if (query.startsWith(READ_PREFIX))
doRead(request, response, tunnelSessionToken);
else if (query.startsWith(WRITE_PREFIX))
doWrite(request, response, tunnelSessionToken);
// Otherwise, invalid operation
else
throw new GuacamoleClientException("Invalid tunnel operation: " + query);
}
// Catch any thrown guacamole exception and attempt to pass within the
// HTTP response, logging each error appropriately.
catch (GuacamoleClientException e) {
logger.warn("HTTP tunnel request rejected: {}", e.getMessage());
sendError(response, e.getStatus().getGuacamoleStatusCode(),
e.getStatus().getHttpStatusCode(), e.getMessage());
}
catch (GuacamoleException e) {
logger.error("HTTP tunnel request failed: {}", e.getMessage());
logger.debug("Internal error in HTTP tunnel.", e);
sendError(response, e.getStatus().getGuacamoleStatusCode(),
e.getStatus().getHttpStatusCode(), "Internal server error.");
}
}
|
Dispatches every HTTP GET and POST request to the appropriate handler
function based on the query string.
@param request
The HttpServletRequest associated with the GET or POST request
received.
@param response
The HttpServletResponse associated with the GET or POST request
received.
@throws ServletException
If an error occurs while servicing the request.
|
handleTunnelRequest
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
protected void doRead(HttpServletRequest request,
HttpServletResponse response, String tunnelSessionToken)
throws GuacamoleException {
// Get tunnel, ensure tunnel exists
GuacamoleTunnel tunnel = getTunnel(tunnelSessionToken);
// Ensure tunnel is open
if (!tunnel.isOpen())
throw new GuacamoleResourceNotFoundException("Tunnel is closed.");
// Obtain exclusive read access
GuacamoleReader reader = tunnel.acquireReader();
try {
// Note that although we are sending text, Webkit browsers will
// buffer 1024 bytes before starting a normal stream if we use
// anything but application/octet-stream.
response.setContentType("application/octet-stream");
response.setHeader("Cache-Control", "no-cache");
// Get writer for response
Writer out = new BufferedWriter(new OutputStreamWriter(
response.getOutputStream(), StandardCharsets.UTF_8));
// Stream data to response, ensuring output stream is closed
try {
// Deregister tunnel and throw error if we reach EOF without
// having ever sent any data
char[] message = reader.read();
if (message == null)
throw new GuacamoleConnectionClosedException("Tunnel reached end of stream.");
// For all messages, until another stream is ready (we send at least one message)
do {
// Get message output bytes
out.write(message, 0, message.length);
// Flush if we expect to wait
if (!reader.available()) {
out.flush();
response.flushBuffer();
}
// No more messages another stream can take over
if (tunnel.hasQueuedReaderThreads())
break;
} while (tunnel.isOpen() && (message = reader.read()) != null);
// Close tunnel immediately upon EOF
if (message == null) {
deregisterTunnel(tunnelSessionToken);
tunnel.close();
}
// End-of-instructions marker
out.write("0.;");
out.flush();
response.flushBuffer();
}
// Send end-of-stream marker and close tunnel if connection is closed
catch (GuacamoleConnectionClosedException e) {
// Deregister and close
deregisterTunnel(tunnelSessionToken);
tunnel.close();
// End-of-instructions marker
out.write("0.;");
out.flush();
response.flushBuffer();
}
catch (GuacamoleException e) {
// Deregister and close
deregisterTunnel(tunnelSessionToken);
tunnel.close();
throw e;
}
// Always close output stream
finally {
out.close();
}
}
catch (IOException e) {
// Log typically frequent I/O error if desired
logger.debug("Error writing to servlet output stream", e);
// Deregister and close
deregisterTunnel(tunnelSessionToken);
tunnel.close();
}
finally {
tunnel.releaseReader();
}
}
|
Called whenever the JavaScript Guacamole client makes a read request.
This function should in general not be overridden, as it already
contains a proper implementation of the read operation.
@param request
The HttpServletRequest associated with the read request received.
@param response
The HttpServletResponse associated with the write request received.
Any data to be sent to the client in response to the write request
should be written to the response body of this HttpServletResponse.
@param tunnelSessionToken
The tunnel-specific session token of the HTTP tunnel to read from,
as specified in the read request. This tunnel must have been created
by a previous call to doConnect().
@throws GuacamoleException
If an error occurs while handling the read request.
|
doRead
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
|
Apache-2.0
|
private void closeConnection(Session session, int guacamoleStatusCode,
int webSocketCode) {
try {
CloseCode code = CloseReason.CloseCodes.getCloseCode(webSocketCode);
String message = Integer.toString(guacamoleStatusCode);
session.close(new CloseReason(code, message));
}
catch (IOException e) {
logger.debug("Unable to close WebSocket connection.", e);
}
}
|
Sends the numeric Guacaomle Status Code and Web Socket
code and closes the connection.
@param session
The outbound WebSocket connection to close.
@param guacamoleStatusCode
The numeric Guacamole status to send.
@param webSocketCode
The numeric WebSocket status to send.
|
closeConnection
|
java
|
ixrjog/opscloud4
|
opscloud-guacamole/src/main/java/org/apache/guacamole/websocket/GuacamoleWebSocketTunnelEndpoint.java
|
https://github.com/ixrjog/opscloud4/blob/master/opscloud-guacamole/src/main/java/org/apache/guacamole/websocket/GuacamoleWebSocketTunnelEndpoint.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.