use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class DatastoreViewerServlet method getIndexedProperties.
/**
* Return all (indexed) properties of kind in the current namespace.
*/
List<String> getIndexedProperties(String kind) throws UnsupportedEncodingException {
List<String> properties = new ArrayList<String>();
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Key kindKey = KeyFactory.createKey(Query.KIND_METADATA_KIND, kind);
Query q = new Query(Query.PROPERTY_METADATA_KIND).setKeysOnly().setAncestor(kindKey).addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
for (Entity e : ds.prepare(q).asIterable()) {
properties.add(urlencode(e.getKey().getName()));
}
return properties;
}
use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class LocalBlobImageServletTest method addServingUrlEntry.
void addServingUrlEntry(String blobKey) {
DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
String namespace = NamespaceManager.get();
try {
NamespaceManager.set("");
Entity blobServingUrlEntity = new Entity(ImagesReservedKinds.BLOB_SERVING_URL_KIND, blobKey);
blobServingUrlEntity.setProperty("blob_key", blobKey);
datastoreService.put(blobServingUrlEntity);
} finally {
NamespaceManager.set(namespace);
}
}
use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class LocalBlobImageServletTest method removeServingUrlEntry.
void removeServingUrlEntry(String blobKey) {
DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
String namespace = NamespaceManager.get();
try {
NamespaceManager.set("");
Key key = KeyFactory.createKey(null, ImagesReservedKinds.BLOB_SERVING_URL_KIND, blobKey);
datastoreService.delete(key);
} finally {
NamespaceManager.set(namespace);
}
}
use of com.google.appengine.api.datastore.DatastoreService in project appengine-java-standard by GoogleCloudPlatform.
the class MainServlet method performCron.
/**
* Inserts a "log" entity into the datastore with the current request URL and timestamp.
*
* @param w response writer
*/
private static void performCron(String url, PrintWriter w) {
DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
Entity log = new Entity(LOG_KIND);
log.setProperty(URL_PROPERTY, url);
log.setProperty(DATE_PROPERTY, new Date());
datastoreService.put(log);
emit(w, "Persisted log entry");
}
use of com.google.appengine.api.datastore.DatastoreService in project xuml-tools by davidmoten.
the class DatastoreTextGae method get.
@Override
public String get(String kind, String name, String property) {
System.out.println("getting");
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Key k = KeyFactory.createKey(kind, name);
String result;
try {
Entity ent = ds.get(k);
System.out.println(ent.getProperties());
Text prop = (Text) ent.getProperty(property);
System.out.println("Datastore.get " + k + "= " + prop);
if (prop != null)
result = prop.getValue();
else
result = null;
} catch (EntityNotFoundException e) {
System.out.println(e.getMessage());
result = null;
}
System.out.println("get returns " + result);
return result;
}
Aggregations