MapGuide API Reference
|
virtual void MgResourceService::SetResourceData | ( | MgResourceIdentifier * | resource, |
CREFSTRING | dataName, | ||
CREFSTRING | dataType, | ||
MgByteReader * | data | ||
) | [pure virtual] |
Adds resource data to the specified resource.
virtual void SetResourceData(MgResourceIdentifier resource, string dataName, string dataType, MgByteReader data); |
virtual void SetResourceData(MgResourceIdentifier resource, String dataName, String dataType, MgByteReader data); |
virtual void SetResourceData(MgResourceIdentifier resource, string dataName, string dataType, MgByteReader data); |
resource | (MgResourceIdentifier) Resource to which this data is to be associated. |
dataName | (String/string) Name for the data. This name must match an element name within the XML content document. If the data name is UserCredentials , then MgResourceTag::Username and MgResourceTag::Password can be inserted into the XML content document to represent provider specific username and/or password. If resource data with the same name has already been set for this resource, the API will overwrite the old setting. No exception is generated. The data name may be any valid UTF-8 string |
dataType | (String/string) Data type for the resource data. It must match one of the types defined in MgResourceDataType and is case sensitive. Data names must be unique. |
data | (MgByteReader) Data to set. |
// Assuming that $resourceService has already been initialized // Assuming that 'Library://Geography/Calgary points of interest.FeatureSource' has already been added to the repository $resourceID = new MgResourceIdentifier('Library://Geography/Calgary points of interest.FeatureSource'); $byteSource = new MgByteSource('C:\Data\Calgary\Data\Calgary_points.sdf'); $data = $byteSource->GetReader(); $resourceService->SetResourceData($resourceID, 'locations of points of interest', 'File', $data);
This example sets resource data and stores it as a stream:
// Assuming that 'Library://Geography/Calgary symbols.SymbolSet' has already been added to the repository $resourceID = new MgResourceIdentifier('Library://Geography/Trees.SymbolLibrary'); $byteSource = new MgByteSource('C:\Data\Calgary\Data\markers.dwf'); $data = $byteSource->GetReader(); $resourceService->SetResourceData($resourceID, 'symbols for points of interest', 'Stream', $data);
This example sets the embedded credentials for a resource and stores it as a string. The string data type must be used for embedded credentials. The data name must be MgResourceDataName::UserCredentials.
// Assuming that 'Library://Geography/database connnection.FeatureSource' has already been added to the repository $resourceID = new MgResourceIdentifier('Library://Geography/database connnection.FeatureSource'); $byteSource = new MgByteSource('C:\Data\Calgary\Data\credentials.txt'); $data = $byteSource->GetReader(); $dataName = new MgResourceDataName(); $resourceService->SetResourceData($resourceID, MgResourceDataName::UserCredentials, 'String', $data);
MgInvalidRepositoryTypeException | |
MgInvalidResourceTypeException | if resource is a folder type |
MgInvalidResourceDataTypeException | if the specified dataType is not in MgResourceDataType |