/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpGetSessionTimeout::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult; MG_HTTP_HANDLER_TRY() hResult = hResponse.GetResult(); // Check common parameters ValidateCommonParameters(); // Get the site Ptr<MgSite> mgSite = m_siteConn->GetSite(); // Run API command INT32 ret = mgSite->GetSessionTimeout(); Ptr<MgHttpPrimitiveValue> value = new MgHttpPrimitiveValue(ret); if(!value) throw new MgOutOfMemoryException(L"MgHttpGetSessionTimeout.Execute", __LINE__, __WFILE__, NULL, L"", NULL); hResult->SetResultObject(value, MgMimeType::Text); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpGetSessionTimeout.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpGetLegendImage::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult; MG_HTTP_HANDLER_TRY() hResult = hResponse.GetResult(); // Check common parameters ValidateCommonParameters(); // Create ProxyMappingService instance Ptr<MgMappingService> mgprService = (MgMappingService*)(CreateService(MgServiceType::MappingService)); // Create MgResourceIdentifier MgResourceIdentifier layerDefinition(m_layerDefinition); // Run API command Ptr<MgByteReader> byteReaderResult = mgprService->GenerateLegendImage(&layerDefinition, m_scale, m_width, m_height, m_format, m_type, m_themeCategory); if (byteReaderResult) { hResult->SetResultObject(byteReaderResult, byteReaderResult->GetMimeType()); } MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpGetLegendImage.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpEnumerateResources::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult; MG_HTTP_HANDLER_TRY() hResult = hResponse.GetResult(); // Check common parameters ValidateCommonParameters(); // Create ProxyResourceService instance Ptr<MgResourceService> mgprService = (MgResourceService*)(CreateService(MgServiceType::ResourceService)); // Create MgResourceIdentifier MgResourceIdentifier mgrIdentifier(m_resourceId); // Run API command Ptr<MgByteReader> byteReader = mgprService->EnumerateResources(&mgrIdentifier, m_depth, m_type, m_computeChildren); // Convert to requested response format, if necessary ProcessFormatConversion(byteReader); hResult->SetResultObject(byteReader, byteReader->GetMimeType()); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpEnumerateResources.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpKmlGetLayer::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult = hResponse.GetResult(); MG_HTTP_HANDLER_TRY() // Check common parameters ValidateCommonParameters(); if (m_boundingBox.empty()) { MgStringCollection arguments; arguments.Add(L"BBOX"); arguments.Add(MgResources::BlankArgument); throw new MgInvalidArgumentException(L"MgHttpKmlGetLayer.Execute", __LINE__, __WFILE__, &arguments, L"MgStringEmpty", NULL); } STRING sessionId = m_userInfo->GetMgSessionId(); // Get a resource service instance Ptr<MgResourceService> resourceService = dynamic_cast<MgResourceService*>(CreateService(MgServiceType::ResourceService)); // Create MgLayer Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(m_layerDefinition); Ptr<MgLayer> layer = new MgLayer(resId, resourceService); // Get a KML service instance Ptr<MgKmlService> kmlService = dynamic_cast<MgKmlService*>(CreateService(MgServiceType::KmlService)); // Create Extents Ptr<MgEnvelope> extents = MgHttpKmlGetFeatures::GetExtents(m_boundingBox); // Get the KML representation of the map Ptr<MgByteReader> reader = kmlService->GetLayerKml(layer, extents, m_width, m_height, m_dpi, m_drawOrder, m_agentUri, m_format); // Set the result hResult->SetResultObject(reader, reader->GetMimeType()); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpKmlGetLayer.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpGetDrawing::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult = hResponse.GetResult(); MG_HTTP_HANDLER_TRY() // Check common parameters ValidateCommonParameters(); MgResourceIdentifier resId(m_resId); // Create Proxy Drawing Service instance Ptr<MgDrawingService> service = (MgDrawingService*)(CreateService(MgServiceType::DrawingService)); // call the C++ API Ptr<MgByteReader> byteReaderResult = service->GetDrawing(&resId); hResult->SetResultObject(byteReaderResult, byteReaderResult->GetMimeType()); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpGetDrawing.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpCsConvertWktToCoordinateSystemCode::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult = hResponse.GetResult(); MG_HTTP_HANDLER_TRY() // Check common parameters ValidateCommonParameters(); Ptr<MgCoordinateSystemFactory> factory = new MgCoordinateSystemFactory(); STRING code = factory->ConvertWktToCoordinateSystemCode(m_ogcWkt); Ptr<MgHttpPrimitiveValue> value = new MgHttpPrimitiveValue(code); if(!value) throw new MgOutOfMemoryException(L"", __LINE__, __WFILE__, NULL, L"", NULL); hResult->SetResultObject(value, MgMimeType::Text); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpCsConvertWktToCoordinateSystemCode.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpEnumerateGroups::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult; MG_HTTP_HANDLER_TRY() hResult = hResponse.GetResult(); // Check common parameters ValidateCommonParameters(); // Open connection to Mg server Ptr<MgSite> mgSite = m_siteConn->GetSite(); // Run API command Ptr<MgByteReader> byteReaderResult = mgSite->EnumerateGroups(); hResult->SetResultObject(byteReaderResult, byteReaderResult->GetMimeType()); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpEnumerateGroups.Execute") }
void MgHttpCopyResource::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult; MG_HTTP_HANDLER_TRY() hResult = hResponse.GetResult(); // Check common parameters ValidateCommonParameters(); // Create ProxyResourceService instance Ptr<MgResourceService> mgprService = (MgResourceService*)(CreateService(MgServiceType::ResourceService)); // Create MgResourceIdentifier MgResourceIdentifier mgrSourceIdentifier(m_sourceResourceId); MgResourceIdentifier mgrDestIdentifier(m_destResourceId); // Run API command mgprService->CopyResource(&mgrSourceIdentifier, &mgrDestIdentifier, m_overwrite); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpCopyResource.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpGetMap::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult = hResponse.GetResult(); MG_HTTP_HANDLER_TRY() // Check common parameters ValidateCommonParameters(); Ptr<MgResourceIdentifier> mapDefinition = new MgResourceIdentifier(m_mapDefinition); Ptr<MgHttpRequestParam> params = m_hRequest->GetRequestParam(); Ptr<MgPropertyCollection> commands = params->GetParameters()->GetPropertyCollection(); //execute the request through a dwf controller MgDwfController controller(m_siteConn, m_hRequest->GetAgentUri()); Ptr<MgByteReader> map = controller.GetMap(mapDefinition, m_dwfVersion, m_emapVersion, commands); hResult->SetResultObject(map, map->GetMimeType()); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpGetMap.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpGetMapLegendImage::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult = hResponse.GetResult(); MG_HTTP_HANDLER_TRY() // Check common parameters ValidateCommonParameters(); // Determine the background color // TODO - Get background color from request Ptr<MgColor> backgroundColor = new MgColor(255, 255, 255); // Use the HTML controller to generate the map legend image MgHtmlController controller(m_siteConn); Ptr<MgByteReader> mapLegendImage = controller.GetMapLegendImage(m_mapName, m_mapFormat, backgroundColor, m_width, m_height); // Set the result hResult->SetResultObject(mapLegendImage, mapLegendImage->GetMimeType()); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpGetMapLegendImage.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpEnumerateUnmanagedData::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult; MG_HTTP_HANDLER_TRY() hResult = hResponse.GetResult(); // Check common parameters ValidateCommonParameters(); // Create ProxyResourceService instance Ptr<MgResourceService> mgprService = (MgResourceService*)(CreateService(MgServiceType::ResourceService)); // call the C++ API Ptr<MgByteReader> byteReader = mgprService->EnumerateUnmanagedData(m_path, m_recursive, m_type, m_filter); // Convert to requested response format, if necessary ProcessFormatConversion(byteReader); hResult->SetResultObject(byteReader, byteReader->GetMimeType()); MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpEnumerateUnmanagedData.Execute") }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgRestTask::Execute(MgHttpResponse& HttpResponse) { Ptr<MgHttpResult> hResult = HttpResponse.GetResult(); Ptr<MgHttpRequestParam> query_params = m_hRequest->GetRequestParam(); MG_HTTP_HANDLER_TRY() // // 1. URI for getting data about MAP // HttpMethod: GET URI: REST/SESSION[Id]/MAP[Id] // // 2. URI creating new MAP in Session // HttpMethod: POST URI: REST/SESSION[Id]/MAP ? MapDefName={Map Definition Name} // // 3. Get Image Extent // HttpMethod: GET URI: REST/SESSION[Id]/MAP[Id]/Extent // // 4. Get Image ( return png ) // HttpMethod: GET URI: REST/SESSION[Id]/MAP[Id]/Image.Png[...ImageCreationParameters...] {.jpg } // // 5. Set Image Extent // HttpMethod: PUT URI: REST/SESSION[Id]/MAP[Id]/Extent ? {SETCETNTERX=..}&{SETCENTERY=..}&.. // // Current Index should be on Map path parameter Ptr<MgRestUriPathParam> path_params = m_RestRequest-> GetUriPathParameters(); switch( m_RestRequest->GetHttpMethod() ) { case MgRestRequest::e_HttpMethod_Get: { } break; case MgRestRequest::e_HttpMethod_Post: { //Execute_Post_StartWebLayout(HttpResponse); } break; case MgRestRequest::e_HttpMethod_Put: break; case MgRestRequest::e_HttpMethod_Delete: break; default: break; } Execute_Post_StartWebLayout(HttpResponse); MG_CATCH(L"REST_Request_Hello.Execute") if (mgException != NULL) { if (hResult != NULL) { hResult->SetErrorInfo(m_hRequest, mgException); } (*mgException).AddRef(); mgException->Raise(); } }
/// <summary> /// Executes the specific request. /// </summary> /// <returns> /// MgHttpResponse /// This contains the response (including MgHttpResult and StatusCode) from the server. /// </returns> void MgHttpWfsDescribeFeatureType::Execute(MgHttpResponse& hResponse) { Ptr<MgHttpResult> hResult = hResponse.GetResult(); MG_HTTP_HANDLER_TRY() // We have to wrap the request parameters, since the outside // world is case-sensitive (with respect to names,) but // we need our parameters NOT to be so. Ptr<MgHttpRequestParam> origReqParams = m_hRequest->GetRequestParam(); MgHttpRequestParameters Parms(origReqParams); MgHttpResponseStream Out; MgOgcServer::SetLoader(GetDocument); MgUserInformation::SetCurrentUserInfo(m_userInfo); // Instance a server-lette MgOgcWfsServer Wfs(Parms,Out); // Determine required feature types CPSZ pszFeatureTypes = Wfs.RequestParameter(MgHttpResourceStrings::reqWfsTypeName.c_str()); STRING sFeatureTypes = pszFeatureTypes? pszFeatureTypes : _(""); Ptr<MgStringCollection> featureTypeList; if(sFeatureTypes.empty()) { featureTypeList = NULL; } else { featureTypeList = MgStringCollection::ParseCollection(sFeatureTypes, L","); } Ptr<MgResourceService> pResourceService = (MgResourceService*)(CreateService(MgServiceType::ResourceService)); Ptr<MgFeatureService> pFeatureService = (MgFeatureService*)(CreateService(MgServiceType::FeatureService)); // Retrieve feature definitions auto_ptr<MgWfsFeatureDefinitions> pFeatureTypes; if(NULL == featureTypeList) { pFeatureTypes.reset(new MgWfsFeatureDefinitions(pResourceService,pFeatureService)); } else { pFeatureTypes.reset(new MgWfsFeatureDefinitions(pResourceService,pFeatureService,featureTypeList)); } Wfs.SetFeatureDefinitions(pFeatureTypes.get()); // In order to validate request we have to invoke the ProcessRequest if(!Wfs.ProcessRequest(this)) { // Obtain the response byte reader Ptr<MgByteReader> errorResponse = Out.Stream().GetReader(); // Set the result hResult->SetResultObject(errorResponse, errorResponse->GetMimeType()); return; } // Determine required output format // This part must behind the Wfs.ProcessRequest, where parameters have been validated. CPSZ pszOutputFormat = Wfs.RequestParameter(MgHttpResourceStrings::reqWfsOutputFormat.c_str()); STRING sOutputFormat = pszOutputFormat? pszOutputFormat : _(""); if(sOutputFormat.empty()) { sOutputFormat = Wfs.GetDefaultDescribeFeatureTypeOutputFormat(STRING(Wfs.RequestParameter(MgHttpResourceStrings::reqWfsVersion.c_str()))); } if(pFeatureTypes->InSameNamespace()) { STRING sPrefix = L""; STRING sUrl = L""; STRING sResource = L""; // TODO: look for this in arg, since POST may put it there to save us trouble. STRING sSchemaHash = L""; Ptr<MgResourceIdentifier> idResource; Ptr<MgStringCollection> pFeatureClasses = new MgStringCollection(); while(pFeatureTypes->ReadNext()) { STRING sClassFullName = pFeatureTypes->GetClassFullName(); if(!sFeatureTypes.empty() && STRING::npos == sFeatureTypes.find(sClassFullName)) { continue; } STRING::size_type iPos = sClassFullName.find(_(":")); //NOXLATE if(iPos != STRING::npos) { if(sPrefix.empty()) { sPrefix = sClassFullName.substr(0,iPos); } STRING sClass = sClassFullName.substr(iPos+1); sUrl = pFeatureTypes->GetNamespaceUrl(); if(NULL == idResource) { if(pFeatureTypes->PrefixToFeatureSource(sPrefix, sResource, sSchemaHash)) { idResource = new MgResourceIdentifier(sResource); } else { // Badly formed feature type? Throw an exception. GenerateTypeNameException(hResult,sFeatureTypes); return; } } pFeatureClasses->Add(((sSchemaHash.size()==0) ? sClass : sSchemaHash + _(":") + sClass)); //NOXLATE } else { // Badly formed feature type? Throw an exception. GenerateTypeNameException(hResult,sFeatureTypes); return; } } if(pFeatureClasses->GetCount() == 0) { // Badly formed feature type? Throw an exception. GenerateTypeNameException(hResult,sFeatureTypes); return; } Ptr<MgByteReader> response = pFeatureService->DescribeWfsFeatureType(idResource, pFeatureClasses, sPrefix, sUrl); // Set the result hResult->SetResultObject(response, sOutputFormat); } else { // There's more than one feature, so we need to enumerate // them and have each get imported. // if(!pFeatureTypes->SubsetFeatureList(sFeatureTypes.c_str())) GenerateTypeNameException(hResult,sFeatureTypes); else { #ifdef _WFS_LOGGING MyLog.Write(_("WFS::DescribeFeatureType\r\n")); #endif // Execute the request //Wfs.ProcessRequest(this); // Slurp the results. Ptr<MgByteReader> capabilities = Out.Stream().GetReader(); // Set the result hResult->SetResultObject(capabilities, capabilities->GetMimeType()); } } MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpWfsDescribeFeatureType.Execute") }