How to verify your credentials and access a catalog
How to verify your credentials and access a catalog
Objectives: Verify that you set up the platform credentials and the Maven settings correctly, and introduce the concepts of HRN, Catalogs and Layers.
Complexity: Beginner
Time to complete: 20 min
Prerequisites: Verify Maven Settings
Source code: Download
This section demonstrates how to write a program that queries catalog
information from the
HERE Map Content
data catalog (hrn: hrn:here:data::olp-here:rib-2).
After running this example successfully, you can be assured that your repository credentials and the platform credentials are set up correctly.
You can create this project in the verify-credentials folder, using the same
structure and pom from the previous tutorial.
The following dependencies are needed for this example:
<dependencies>
<dependency>
<groupId>com.here.platform.data.client</groupId>
<artifactId>data-client_${scala.compat.version}</artifactId>
</dependency>
</dependencies>To gather information about a catalog, create code using either Scala or Java in the source folder.
If you have not generated your repository settings or platform credentials yet,
see
Get Credentials.
After you have followed these instructions, you should have both a
settings.xml with repository credentials, and a
credentials.properties with platform credentials.
The program queries the HERE Map Content catalog (the catalog with all the traditional HERE map data) using Data Client Library to get the latest available catalog version, information about the latest catalog update date and available layers in the catalog.
/*
* Copyright (c) 2018-2026 HERE Europe B.V.
*
* 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.
*/
import org.apache.pekko.actor.CoordinatedShutdown.UnknownReason
import org.apache.pekko.actor.{ActorSystem, CoordinatedShutdown}
import com.here.hrn.HRN
import com.here.platform.data.client.scaladsl.DataClient
import scala.concurrent._
import scala.concurrent.duration._
import scala.language.postfixOps
object CatalogInfoScala extends App {
// Initialize the Pekko Actor System used by the Data Client Library
implicit lazy val actorSystem = ActorSystem()
// The Here Map Content identifier is an HRN (Here Resource Name)
private val hereMapContentHrn = HRN("hrn:here:data::olp-here:rib-2")
// Initialize the query API for the catalog
val queryApi = DataClient().queryApi(hereMapContentHrn)
// Initialize the admin API for the catalog
val adminApi = DataClient().adminApi()
// Get the latest available catalog version
val latestVersion = Await.result(queryApi.getLatestVersion(), 5 seconds)
// Retrieve more metadata for the version, if any
latestVersion match {
case Some(version) =>
println(s"The latest Here Map Content version is $version")
val latestVersionInfo = Await.result(queryApi.getVersion(version), 5 seconds)
println(s"The catalog was last updated on ${new java.util.Date(latestVersionInfo.timestamp)}")
case None =>
println("No version for this catalog")
}
// Get available layers in the Here Map Content catalog
val catalogConfiguration = Await.result(adminApi.getConfiguration(hereMapContentHrn), 5 seconds)
println("The Here Map Content catalog contains the following layers: ")
catalogConfiguration.layers.foreach(layer => println(layer.getId))
// In production code this would be in a finally block
val shutdown = CoordinatedShutdown(actorSystem).run(UnknownReason)
Await.result(shutdown, Duration.Inf)
}/*
* Copyright (c) 2018-2026 HERE Europe B.V.
*
* 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.
*/
import static java.lang.System.out;
import com.here.hrn.HRN;
import com.here.platform.data.client.javadsl.AdminApi;
import com.here.platform.data.client.javadsl.DataClient;
import com.here.platform.data.client.javadsl.QueryApi;
import java.util.OptionalLong;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.actor.CoordinatedShutdown;
public class CatalogInfoJava {
public static void main(String[] args) {
// Initialize the Pekko Actor System used by the Data Client Library
ActorSystem actorSystem = ActorSystem.create();
// The Here Map Content identifier is an HRN (Here Resource Name)
HRN hereMapContentHrn = HRN.fromString("hrn:here:data::olp-here:rib-2");
// Initialize the query API for the catalog
QueryApi queryApi = DataClient.get(actorSystem).queryApi(hereMapContentHrn);
// Initialize the admin API for the catalog
AdminApi adminApi = DataClient.get(actorSystem).adminApi();
// Get the latest available catalog version
queryApi
.getLatestVersion(OptionalLong.empty())
.thenAccept(
version -> {
if (version.isPresent()) {
out.println("The latest Here Map Content version is " + version.getAsLong());
queryApi
.getVersion(version.getAsLong())
.thenAccept(
versionInfo -> {
out.println(
"The catalog was last updated on "
+ new java.util.Date(versionInfo.getTimestamp()));
})
.toCompletableFuture()
.join();
} else {
out.println("No version for this catalog");
}
})
.toCompletableFuture()
.join();
// Get available layers in the Here Map Content catalog
adminApi
.getConfiguration(hereMapContentHrn)
.thenAccept(
catalog -> {
out.println("The Here Map Content catalog contains the following layers: ");
catalog.getLayers().forEach(layer -> out.println(layer.getId()));
})
.toCompletableFuture()
.join();
// In production code this would be in a finally block
CoordinatedShutdown.get(actorSystem)
.runAll(CoordinatedShutdown.unknownReason())
.toCompletableFuture()
.join();
}
}You can now run your code either using your IDE, or from the command line using
mvn:
mvn compile exec:java -Dexec.mainClass=CatalogInfoScalamvn compile exec:java -Dexec.mainClass=CatalogInfoJavaThe expected output should look like this, with the confirmation that your code was successful in fetching the token:
[INFO] [...] [CatalogInfoJava.main()] [DataClientSettingsExt] Reading credentials from default credentials file XXXX
[INFO] [...] [default-pekko.actor.default-dispatcher-5] [HereAccountProvider] OAuth token fetched successfully with expiration of 86399s, next refresh scheduled in 57599s.
The latest Here Map Content version is 5913
The catalog was last updated on Sun Apr 14 00:59:07 EEST 2024
The Here Map Content catalog contains the following layers:
state
history
address-locations
building-footprints
3d-buildings
cartography
administrative-places
traffic-patterns
street-names
lane-attributes
address-attributes
adas-attributes
topology-attributes
topology-geometry
administrative-locations
truck-attributes
cartography-metadata
building-metadata
here-places
places-metadata
distance-markers
indexed-locations
sign-text
environmental-zones
here-places-essential-map
landmarks-3d
landmarks-2d
vehicle-regulations
flag-images
postal-code-points
postal-area-boundaries
toll-cost
electric-vehicle-charging-stations
electric-vehicle-charging-locations
here-truck-service-locations
here-fueling-stations
generalized-junctions-signs
enhanced-buildings
parking-areas
annotations
bicycle-attributes
warning-locations
complex-road-attributes
administrative-place-profiles
commercial-vehicle-regulations
The application prints the latest catalog version, latest update date and available layers.
Further information
The Data Client Library is a complete API for accessing the Data Service. You can use this API to query the catalog metadata (versions, layers, partitions inside the layers) and data (actual partition payload). For more details, see Data Client Library Developer Guide.
The Data Client Library documentation covers more detailed workflows such as how to introspect more metadata fields, fetching data from partitions, and examining content changes between versions.
The following sections explain how to create your own catalog and layers and explore the available layer types and configurations:
- The Data API documentation provides information about the available layer types and configurations.
- The OLP CLI documentation and the Data section of the portal explain the interactive querying and manipulation of catalogs.
- The Data Client Library Developer Guide describes the Scala and Java APIs that can access the services.
Once you have verified your platform credentials to access the HERE Map Content, you can get familiar with the project concepts to work with catalogs within the project scope.
Updated 22 days ago