java.net.HttpURLConnection#HTTP_NOT_FOUND源码实例Demo

下面列出了java.net.HttpURLConnection#HTTP_NOT_FOUND 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_maplib   文件: NGWVectorLayer.java
protected void log(SyncResult syncResult, String code) {
    int responseCode = Integer.parseInt(code);
    switch (responseCode) {
        case HttpURLConnection.HTTP_UNAUTHORIZED:
        case HttpURLConnection.HTTP_FORBIDDEN:
            syncResult.stats.numAuthExceptions++;
            break;
        case 1:
            syncResult.stats.numParseExceptions++;
            break;
        case 0:
        default:
        case HttpURLConnection.HTTP_NOT_FOUND:
        case HttpURLConnection.HTTP_INTERNAL_ERROR:
            syncResult.stats.numIoExceptions++;
            syncResult.stats.numEntries++;
            break;
    }
}
 
源代码2 项目: grpc-nebula-java   文件: GrpcUtil.java
private static Status.Code httpStatusToGrpcCode(int httpStatusCode) {
  if (httpStatusCode >= 100 && httpStatusCode < 200) {
    // 1xx. These headers should have been ignored.
    return Status.Code.INTERNAL;
  }
  switch (httpStatusCode) {
    case HttpURLConnection.HTTP_BAD_REQUEST:  // 400
    case 431: // Request Header Fields Too Large
      // TODO(carl-mastrangelo): this should be added to the http-grpc-status-mapping.md doc.
      return Status.Code.INTERNAL;
    case HttpURLConnection.HTTP_UNAUTHORIZED:  // 401
      return Status.Code.UNAUTHENTICATED;
    case HttpURLConnection.HTTP_FORBIDDEN:  // 403
      return Status.Code.PERMISSION_DENIED;
    case HttpURLConnection.HTTP_NOT_FOUND:  // 404
      return Status.Code.UNIMPLEMENTED;
    case 429:  // Too Many Requests
    case HttpURLConnection.HTTP_BAD_GATEWAY:  // 502
    case HttpURLConnection.HTTP_UNAVAILABLE:  // 503
    case HttpURLConnection.HTTP_GATEWAY_TIMEOUT:  // 504
      return Status.Code.UNAVAILABLE;
    default:
      return Status.Code.UNKNOWN;
  }
}
 
源代码3 项目: opencps-v2   文件: DossierFileManagement.java
@POST
@Path("/import/files")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({
	MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
})
@ApiOperation(value = "import file xml)", response = DossierFileModel.class)
@ApiResponses(value = {
	@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the DossierFileModel was updated", response = DossierFileResultsModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class)
})
public Response uploadFileEntry(
	@Context HttpServletRequest request, @Context HttpHeaders header,
	@Context Company company, @Context Locale locale, @Context User user,
	@Context ServiceContext serviceContext,
	@ApiParam(value = "Attachment files", required = true) @Multipart("file") Attachment file);
 
源代码4 项目: hono   文件: StatusCodeMapper.java
/**
 * Creates an exception for an AMQP error condition.
 *
 * @param condition The error condition.
 * @param description The error description or {@code null} if not available.
 * @return The exception.
 * @throws NullPointerException if error is {@code null}.
 */
public static final ServiceInvocationException from(final Symbol condition, final String description) {

    Objects.requireNonNull(condition);

    if (AmqpError.RESOURCE_LIMIT_EXCEEDED.equals(condition)) {
        return new ClientErrorException(HttpURLConnection.HTTP_FORBIDDEN, description);
    } else if (AmqpError.UNAUTHORIZED_ACCESS.equals(condition)) {
        return new ClientErrorException(HttpURLConnection.HTTP_FORBIDDEN, description);
    } else if (AmqpError.INTERNAL_ERROR.equals(condition)) {
        return new ServerErrorException(HttpURLConnection.HTTP_INTERNAL_ERROR, description);
    } else if (Constants.AMQP_BAD_REQUEST.equals(condition)) {
        return new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST, description);
    } else {
        return new ClientErrorException(HttpURLConnection.HTTP_NOT_FOUND, description);
    }
}
 
源代码5 项目: kubernetes-client   文件: ClusterOperationsImpl.java
public VersionInfo fetchVersion() {
  try {
    Response response = handleVersionGet(versionEndpoint);
    // Handle Openshift 4 version case
    if (HttpURLConnection.HTTP_NOT_FOUND == response.code() && versionEndpoint.equals(OPENSHIFT_VERSION_ENDPOINT)) {
      response.close();
      return fetchOpenshift4Version();
    }

    Map<String, String> myMap = objectMapper.readValue(response.body().string(), HashMap.class);
    return fetchVersionInfoFromResponse(myMap);
  } catch(Exception e) {
    KubernetesClientException.launderThrowable(e);
  }
  return null;
}
 
源代码6 项目: opencps-v2   文件: DossierFileManagement.java
@POST
@Path("/{id}/files/{referenceUid}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({
	MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
})
@ApiOperation(value = "update DossierFile", response = String.class)
@ApiResponses(value = {
	@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the DossierFileModel was updated", response = DossierFileResultsModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class)
})
public Response updateDossierFile(
	@Context HttpServletRequest request, @Context HttpHeaders header,
	@Context Company company, @Context Locale locale, @Context User user,
	@Context ServiceContext serviceContext,
	@ApiParam(value = "id of dossier", required = true) @PathParam("id") long id,
	@ApiParam(value = "reference of dossierfile", required = true) @PathParam("referenceUid") String referenceUid,
	@ApiParam(value = "Attachment files", required = true) @Multipart("file") Attachment file);
 
源代码7 项目: opencps-v2   文件: DossierFileManagement.java
@PUT
@Path("/{id}/files/{referenceUid}/resetformdata")
@ApiOperation(value = "update DossierFile")
@ApiResponses(value = {
	@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
	@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
	@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class)
})
public Response resetformdataDossierFileFormData(
	@Context HttpServletRequest request, @Context HttpHeaders header,
	@Context Company company, @Context Locale locale, @Context User user,
	@Context ServiceContext serviceContext,
	@ApiParam(value = "id of dossier", required = true) @PathParam("id") long id,
	@ApiParam(value = "referenceUid of dossierfile", required = true) @PathParam("referenceUid") String referenceUid,
	@ApiParam(value = "formdata of dossierfile", required = true) @FormParam("formdata") String formdata);
 
源代码8 项目: opencps-v2   文件: ApplicantManagement.java
@GET
@Path("/ngsp/{applicantIdNo}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get the profile of applicant", response = JSONObject.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the profile of applicant", response = JSONObject.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response ngspGetApplicantInfo(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("applicantIdNo") String applicantIdNo);
 
源代码9 项目: opencps-v2   文件: EFormManagement.java
@GET
@Path("/{id}/report/{secret}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get a formdata of Plugin", response = DossierResultsModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a list of Plugins have been filtered", response = DossierResultsModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response printEFormReport(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") String id,
		@PathParam("secret") String secret);
 
源代码10 项目: azure-storage-android   文件: CloudFile.java
/**
 * Deletes the file if it exists, using the specified access condition, request options, and operation context.
 * 
 * @param accessCondition
 *            An {@link AccessCondition} object that represents the access conditions for the file.
 * @param options
 *            A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> will use the default request options from the associated service client (
 *            {@link CloudFileClient}).
 * @param opContext
 *            An {@link OperationContext} object that represents the context for the current operation. This object
 *            is used to track requests to the storage service, and to provide additional runtime information about
 *            the operation.
 * 
 * @return <code>true</code> if the file existed and was deleted; otherwise, <code>false</code>
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws URISyntaxException 
 */
@DoesServiceRequest
public final boolean deleteIfExists(final AccessCondition accessCondition, FileRequestOptions options,
        OperationContext opContext) throws StorageException, URISyntaxException {
    options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
    this.getShare().assertNoSnapshot();

    boolean exists = this.exists(true, accessCondition, options, opContext);
    if (exists) {
        try {
            this.delete(accessCondition, options, opContext);
            return true;
        }
        catch (StorageException e) {
            if (e.getHttpStatusCode() == HttpURLConnection.HTTP_NOT_FOUND
                    && StorageErrorCodeStrings.RESOURCE_NOT_FOUND.equals(e.getErrorCode())) {
                return false;
            }
            else {
                throw e;
            }
        }

    }
    else {
        return false;
    }
}
 
源代码11 项目: opencps-v2   文件: ServerConfigManagement.java
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get all ServerConfig", response = ServerConfigResultsModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a list of all ServerConfig", response = ServerConfigResultsModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response getServerConfigs(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @BeanParam ServerConfigSearchModel query);
 
源代码12 项目: opencps-v2   文件: DeliverableTypesManagement.java
@GET
@Path("/{id}/formreport")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "getFormReportByDeliverableTypeId", response = JSONObject.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a formdata", response = JSONObject.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response getFormReportByDeliverableTypeId(@Context HttpServletRequest request,
		@Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id of dossier", required = true) @PathParam("id") long id);
 
源代码13 项目: opencps-v2   文件: DossierTemplateManagement.java
@GET
@Path("/{id}/parts/{partno}/formreport")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get formreport of a DossierPart", response = DossierPartContentInputUpdateModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the formreport", response = DossierPartContentInputUpdateModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response getFormReport(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id, @PathParam("partno") String partNo);
 
源代码14 项目: opencps-v2   文件: DossierActionManagement.java
@GET
@Path("/{id}/rollback")
@ApiOperation(value = "rollback", response = String.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns rollback is success", response = String.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response getRollback(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") String id);
 
源代码15 项目: opencps-v2   文件: DossierManagement.java
@GET
@Path("/{id}/cancelling")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Owner requset cancalling for Dossier", response = DossierDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier has been cancelled", response = DossierDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response cancellingDossier(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") String id);
 
源代码16 项目: metacat   文件: MetacatController.java
/**
 * List of metacat view names.
 *
 * @param catalogName  catalog name
 * @param databaseName database name
 * @param tableName    table name
 * @return List of metacat view names.
 */
@RequestMapping(
    method = RequestMethod.GET,
    path = "/catalog/{catalog-name}/database/{database-name}/table/{table-name}/mviews"
)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(
    position = 1,
    value = "List of metacat views",
    notes = "List of metacat views for a catalog"
)
@ApiResponses(
    {
        @ApiResponse(
            code = HttpURLConnection.HTTP_OK,
            message = "The list of views is returned"
        ),
        @ApiResponse(
            code = HttpURLConnection.HTTP_NOT_FOUND,
            message = "The requested catalog cannot be located"
        )
    }
)
public List<NameDateDto> getMViews(
    @ApiParam(value = "The name of the catalog", required = true)
    @PathVariable("catalog-name") final String catalogName,
    @ApiParam(value = "The name of the database", required = true)
    @PathVariable("database-name") final String databaseName,
    @ApiParam(value = "The name of the table", required = true)
    @PathVariable("table-name") final String tableName
) {
    final QualifiedName name = this.requestWrapper.qualifyName(
        () -> QualifiedName.ofTable(catalogName, databaseName, tableName)
    );
    return this.requestWrapper.processRequest(
        name,
        "getMViews",
        () -> this.mViewService.list(name)
    );
}
 
源代码17 项目: opencps-v2   文件: DossierManagement.java
@POST
@Path("/{id}/fixDueDate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Owner submitting Dossier", response = DossierDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier has been submitted", response = DossierDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response fixDueDateDossier(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") String id, @FormParam("receiveDate") String receiveDate);
 
源代码18 项目: metacat   文件: PartitionController.java
/**
 * Return list of partition names for a view.
 *
 * @param catalogName             catalog name
 * @param databaseName            database name
 * @param tableName               table name
 * @param viewName                view name
 * @param sortBy                  sort by this name
 * @param sortOrder               sort order to use
 * @param offset                  offset of the list
 * @param limit                   size of the list
 * @param getPartitionsRequestDto request
 * @return list of partition names for a view
 */
@RequestMapping(
    method = RequestMethod.POST,
    path = "/catalog/{catalog-name}/database/{database-name}/table/{table-name}/mview/{view-name}/keys-request",
    consumes = MediaType.APPLICATION_JSON_VALUE
)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(
    value = "List of partition keys for a metacat view",
    notes = "List of partition keys for the given view name under the given catalog and database"
)
@ApiResponses(
    {
        @ApiResponse(
            code = HttpURLConnection.HTTP_OK,
            message = "The partitions keys were retrieved"
        ),
        @ApiResponse(
            code = HttpURLConnection.HTTP_NOT_FOUND,
            message = "The requested catalog or database or metacat view cannot be located"
        )
    }
)
public List<String> getPartitionKeysForRequest(
    @ApiParam(value = "The name of the catalog", required = true)
    @PathVariable("catalog-name") final String catalogName,
    @ApiParam(value = "The name of the database", required = true)
    @PathVariable("database-name") final String databaseName,
    @ApiParam(value = "The name of the table", required = true)
    @PathVariable("table-name") final String tableName,
    @ApiParam(value = "The name of the metacat view", required = true)
    @PathVariable("view-name") final String viewName,
    @ApiParam(value = "Sort the partition list by this value")
    @Nullable @RequestParam(name = "sortBy", required = false) final String sortBy,
    @ApiParam(value = "Sorting order to use")
    @Nullable @RequestParam(name = "sortOrder", required = false) final SortOrder sortOrder,
    @ApiParam(value = "Offset of the list returned")
    @Nullable @RequestParam(name = "offset", required = false) final Integer offset,
    @ApiParam(value = "Size of the partition list")
    @Nullable @RequestParam(name = "limit", required = false) final Integer limit,
    @ApiParam(value = "Request containing the filter expression for the partitions")
    @Nullable @RequestBody(required = false) final GetPartitionsRequestDto getPartitionsRequestDto
) {
    return this._getMViewPartitionKeys(
        catalogName,
        databaseName,
        tableName,
        viewName,
        sortBy,
        sortOrder,
        offset,
        limit,
        getPartitionsRequestDto
    );
}
 
源代码19 项目: go-bees   文件: OpenWeatherMapUtils.java
static MeteoRecord parseCurrentWeatherJson(String weatherJson) throws JSONException {
    // Get JSON
    JSONObject jsonObject = new JSONObject(weatherJson);

    // Check errors
    if (jsonObject.has(OWM_MESSAGE_CODE)) {
        int errorCode = jsonObject.getInt(OWM_MESSAGE_CODE);
        switch (errorCode) {
            case HttpURLConnection.HTTP_OK:
                break;
            case HttpURLConnection.HTTP_NOT_FOUND: // Location invalid
            default: // Server probably down
                return null;
        }
    }

    // Parse JSON
    Date timestamp = new Date();
    String cityName = null;
    int weatherCondition = 0;
    String weatherConditionIcon = null;
    double temperature = 0;
    double temperatureMin = 0;
    double temperatureMax = 0;
    int pressure = 0;
    int humidity = 0;
    double windSpeed = 0;
    double windDegrees = 0;
    int clouds = 0;
    double rain = 0;
    double snow = 0;

    // Get city
    if (jsonObject.has(OWM_CITY)) {
        cityName = jsonObject.getString(OWM_CITY);
    }

    // Get weather condition
    if (jsonObject.has(OWM_WEATHER)) {
        JSONArray jsonWeatherArray = jsonObject.getJSONArray(OWM_WEATHER);
        JSONObject jsonWeatherObject = jsonWeatherArray.getJSONObject(0);
        weatherCondition = jsonWeatherObject.has(OWM_WEATHER_ID) ?
                jsonWeatherObject.getInt(OWM_WEATHER_ID) : -1;
        weatherConditionIcon = jsonWeatherObject.has(OWM_WEATHER_ICON) ?
                jsonWeatherObject.getString(OWM_WEATHER_ICON) : "";
    }

    // Get main info
    if (jsonObject.has(OWM_MAIN)) {
        JSONObject jsonMainObject = jsonObject.getJSONObject(OWM_MAIN);
        temperature = jsonMainObject.has(OWM_MAIN_TEMPERATURE) ?
                jsonMainObject.getDouble(OWM_MAIN_TEMPERATURE) : 0;
        temperatureMin = jsonMainObject.has(OWM_MAIN_TEMPERATURE_MIN) ?
                jsonMainObject.getDouble(OWM_MAIN_TEMPERATURE_MIN) : 0;
        temperatureMax = jsonMainObject.has(OWM_MAIN_TEMPERATURE_MAX) ?
                jsonMainObject.getDouble(OWM_MAIN_TEMPERATURE_MAX) : 0;
        pressure = jsonMainObject.has(OWM_MAIN_PRESSURE) ?
                jsonMainObject.getInt(OWM_MAIN_PRESSURE) : 0;
        humidity = jsonMainObject.has(OWM_MAIN_HUMIDITY) ?
                jsonMainObject.getInt(OWM_MAIN_HUMIDITY) : 0;
    }

    // Get wind
    if (jsonObject.has(OWM_WIND)) {
        JSONObject jsonWindObject = jsonObject.getJSONObject(OWM_WIND);
        windSpeed = jsonWindObject.has(OWM_WIND_SPEED) ?
                jsonWindObject.getDouble(OWM_WIND_SPEED) : 0;
        windDegrees = jsonWindObject.has(OWM_WIND_DIRECTION) ?
                jsonWindObject.getDouble(OWM_WIND_DIRECTION) : 0;
    }

    // Get clouds
    if (jsonObject.has(OWM_CLOUDS)) {
        JSONObject jsonCloudsObject = jsonObject.getJSONObject(OWM_CLOUDS);
        clouds = jsonCloudsObject.has(OWM_CLOUDS_CLOUDINESS) ?
                jsonCloudsObject.getInt(OWM_CLOUDS_CLOUDINESS) : 0;
    }

    // Get rain
    if (jsonObject.has(OWM_RAIN)) {
        JSONObject jsonRainObject = jsonObject.getJSONObject(OWM_RAIN);
        rain = jsonRainObject.has(OWM_RAIN_3H) ?
                jsonRainObject.getDouble(OWM_RAIN_3H) : 0;
    }

    // Get snow
    if (jsonObject.has(OWM_SNOW)) {
        JSONObject jsonSnowObject = jsonObject.getJSONObject(OWM_SNOW);
        snow = jsonSnowObject.has(OWM_SNOW_3H) ?
                jsonSnowObject.getDouble(OWM_SNOW_3H) : 0;
    }

    return new MeteoRecord(timestamp, cityName, weatherCondition, weatherConditionIcon,
            temperature, temperatureMin, temperatureMax, pressure, humidity, windSpeed,
            windDegrees, clouds, rain, snow);
}
 
源代码20 项目: genie   文件: GenieNotFoundException.java
/**
 * Constructor.
 *
 * @param msg human readable message
 */
public GenieNotFoundException(final String msg) {
    super(HttpURLConnection.HTTP_NOT_FOUND, msg);
}