Java tutorial
/* Copyright (c) 2013-2016 Boundless and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Distribution License v1.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/org/documents/edl-v10.html * * Contributors: * Victor Olaya (Boundless) - initial implementation */ package org.geogig.osm.internal.log; import org.geogig.osm.internal.Mapping; import org.locationtech.geogig.repository.AbstractGeoGigOp; import org.locationtech.geogig.storage.BlobStore; import org.locationtech.geogig.storage.impl.Blobs; import com.google.common.base.Optional; import com.google.common.base.Preconditions; /** * Reads the mapping associated to a previously executed OSM mapping operation. */ public class ReadOSMMapping extends AbstractGeoGigOp<Optional<Mapping>> { private OSMMappingLogEntry entry; public ReadOSMMapping setEntry(OSMMappingLogEntry entry) { this.entry = entry; return this; } @Override protected Optional<Mapping> _call() { Preconditions.checkNotNull(entry); BlobStore blobStore = context().blobStore(); final String pathPrefix = "osm/map/"; final String path = pathPrefix + entry.getPostMappingId(); Optional<String> blob = Blobs.getBlobAsString(blobStore, path); Mapping mapping = null; if (blob.isPresent()) { mapping = Mapping.fromString(blob.get()); } return Optional.fromNullable(mapping); } }