-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathLocalRasterServerRetriever.java
More file actions
229 lines (195 loc) · 6.26 KB
/
LocalRasterServerRetriever.java
File metadata and controls
229 lines (195 loc) · 6.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
* Copyright 2006-2009, 2017, 2020 United States Government, as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All rights reserved.
*
* The NASA World Wind Java (WWJ) platform is licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* NASA World Wind Java (WWJ) also contains the following 3rd party Open Source
* software:
*
* Jackson Parser – Licensed under Apache 2.0
* GDAL – Licensed under MIT
* JOGL – Licensed under Berkeley Software Distribution (BSD)
* Gluegen – Licensed under Berkeley Software Distribution (BSD)
*
* A complete listing of 3rd Party software notices and licenses included in
* NASA World Wind Java (WWJ) can be found in the WorldWindJava-v2.2 3rd-party
* notices and licenses PDF found in code directory.
*/
package gov.nasa.worldwind.retrieve;
import gov.nasa.worldwind.WWObjectImpl;
import gov.nasa.worldwind.avlist.*;
import gov.nasa.worldwind.data.RasterServer;
import gov.nasa.worldwind.exception.WWRuntimeException;
import gov.nasa.worldwind.util.*;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
/**
* @author tag
* @version $Id: LocalRasterServerRetriever.java 2257 2014-08-22 18:02:19Z tgaskins $
*/
public class LocalRasterServerRetriever extends WWObjectImpl implements Retriever
{
// protected AVList params;
protected RetrievalPostProcessor postProcessor;
protected RasterServer server = null;
protected volatile String state = RETRIEVER_STATE_NOT_STARTED;
protected volatile int contentLength = 0;
protected AtomicInteger contentLengthRead = new AtomicInteger(0);
protected ByteBuffer byteBuffer;
protected int staleRequestLimit = -1;
protected long submitTime;
protected long beginTime;
protected long endTime;
protected String basicAuthenticationEncodedString;
public LocalRasterServerRetriever(AVList params, RasterServer rasterServer, RetrievalPostProcessor postProcessor)
{
if (null != params)
this.setValues(params);
this.server = rasterServer;
this.postProcessor = postProcessor;
}
public RasterServer getServer()
{
return this.server;
}
public void setServer(RasterServer server)
{
this.server = server;
}
public ByteBuffer getBuffer()
{
return this.byteBuffer;
}
public int getContentLength()
{
return this.contentLength;
}
public int getContentLengthRead()
{
return this.contentLengthRead.get();
}
public String getName()
{
Object o = this.getStringValue(AVKey.DISPLAY_NAME);
return (WWUtil.isEmpty(o)) ? null : (String) o;
}
public String getState()
{
return this.state;
}
public String getContentType()
{
Object o = this.getValue(AVKey.IMAGE_FORMAT);
return (WWUtil.isEmpty(o)) ? null : (String) o;
}
/**
* {@inheritDoc}
*
* @return Always returns zero (no expiration).
*/
public long getExpirationTime()
{
return 0;
}
public long getSubmitTime()
{
return this.submitTime;
}
public void setSubmitTime(long submitTime)
{
this.submitTime = submitTime;
}
public long getBeginTime()
{
return this.beginTime;
}
public void setBeginTime(long beginTime)
{
this.beginTime = beginTime;
}
public long getEndTime()
{
return this.endTime;
}
public void setEndTime(long endTime)
{
this.endTime = endTime;
}
public int getConnectTimeout()
{
return 0;// Not applicable to this retriever type
}
public int getReadTimeout()
{
return 0;// Not applicable to this retriever type
}
public void setReadTimeout(int readTimeout)
{
// Not applicable to this retriever type
}
public void setConnectTimeout(int connectTimeout)
{
// Not applicable to this retriever type
}
public int getStaleRequestLimit()
{
return this.staleRequestLimit;
}
public void setStaleRequestLimit(int staleRequestLimit)
{
this.staleRequestLimit = staleRequestLimit;
}
@Override
public void setBasicAuthentication(String basicAuthorizationString) {
this.basicAuthenticationEncodedString = basicAuthorizationString;
}
public Retriever call() throws Exception
{
try
{
this.setState(RETRIEVER_STATE_STARTED);
if (null == this.server)
{
this.setState(RETRIEVER_STATE_ERROR);
String message = Logging.getMessage("nullValue.RasterServerIsNull");
Logging.logger().severe(message);
throw new WWRuntimeException(message);
}
this.byteBuffer = this.server.getRasterAsByteBuffer(this.copy());
if (null != this.byteBuffer)
{
this.setState(RETRIEVER_STATE_SUCCESSFUL);
this.contentLength = this.byteBuffer.capacity();
this.contentLengthRead.set(this.contentLength);
}
else
this.setState(RETRIEVER_STATE_ERROR);
if (this.postProcessor != null)
this.byteBuffer = this.postProcessor.run(this);
}
catch (Exception e)
{
this.setState(RETRIEVER_STATE_ERROR);
Logging.logger().log(Level.SEVERE, Logging.getMessage("Retriever.ErrorPostProcessing", this.getName()), e);
throw e;
}
return this;
}
protected void setState(String state)
{
String oldState = this.state;
this.state = state;
this.firePropertyChange(AVKey.RETRIEVER_STATE, oldState, this.state);
}
}