Ok, so I hex dumped my local file, and it has the app id all over the
place.

You may be able to try out the remote api between local installations,
or you're going to need to grep/cat find/replace the app ids in a copy
of your local ds....

If you don't like either of these options, write a servlet that takes
a namespace, parent key, kind, id/name value, and a fields param.
You can loop through all namespaces, then all kinds/tables with
metadata queries.
http://code.google.com/appengine/docs/java/datastore/metadataqueries.html

Post each entity from one server of old app id, to a second server on
new appid.

Send all of the key data, and all of the fields.  You can say "any
request parameter that isn't a key value is a field", or use a
fields=name_of_other_fields,.... param to identify other request
params that are fields.

old server loops through all data, posts to new server, where a
listening servlet reconstructs and saves the entity.

Your only big worry would be field serialization / class cast problems
{putting a double where a long goes}.

If your data is simple, no worries.

Otherwise, I would prefix the field name with data type.

! NS : Parent/23 : Kind/Name = {
one: "data"
two: 1.0
three: [45,71,3]
}

example url:
/localhost_save?ns=NS &kind=Kind &name=Name &parent=Parent%2023
&str_fields=one &one=data &dbl_fields=two &two=1 ...

I will leave it to you to decide if this is worth your time and how to
properly serialize your data to urls.

A very lazy way to serialize would be to make a DeferredTask class
that takes your entities as a parameter, save them to typed,
serializable java fields,
then just use an object output stream to convert to byte[], encode
bytes in UTF-8, post to the other server that has same DeferredTask
class,
where it uses ObjectInputStream to deserialize the job, call .run(),
which just saves the entity/ies, and you don't have to deal with url
serialization.

public class DataPort implements DeferredTask{
YourPojo data;
public DataPort(YourPojo data){
this.data = data;
}

public void run(){
DatastoreServiceFactory.getDatastoreService().put(convertToEntity(data));
}
}


Note, you can probably send pojos, or you could save raw entities to a
bunch of HashMaps,
HashMap<String, Double> doubles, HashMap<String, Long> longs,
HashMap<String, ....>

This would also mean you could use a single class to do all your data.

Here is the code from TaskOptions.Builder.payload(DeferredTask task)


public TaskOptions payload(DeferredTask deferredTask) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream(1024);
    ObjectOutputStream objectStream = null;
    try {
      objectStream = new ObjectOutputStream(stream);
      objectStream.writeObject(deferredTask);
    } catch (IOException e) {
      throw new DeferredTaskCreationException(e);
    }
    payload = stream.toByteArray();
    if (getMethod() != Method.PULL) {
      header("content-type",
DeferredTaskContext.RUNNABLE_TASK_CONTENT_TYPE);
      method(Method.POST);
      if (getUrl() == null) {
        url(DeferredTaskContext.DEFAULT_DEFERRED_URL);
      }
    }
    return this;
  }


You quite likely cannot post save tasks directly from one app to
another with task queue api,
but you can serialize that byte array, mimic the headers and use url
fetch to post to the /_ah/queue/deferred of your other app.


...Whatever you choose to use, you are to, never, ever upload a script
this insecure to production!
...just saying.

On Dec 3, 11:03 am, Vivek Puri <[email protected]> wrote:
> I have moved my app from MS to HRD and as a result the app name has
> changed. As a result all the local data is associated with the old app
> name and i have to keep switching back and forth between app names
> while deploying and developing. Would anyone know how to migrate data
> from one local app to another local app.
>
> Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to