ラベル Google の投稿を表示しています。 すべての投稿を表示
ラベル Google の投稿を表示しています。 すべての投稿を表示

2009年10月15日木曜日

Google App Engine 1.2.6の起動時エラー

EclipseのApp Engine Pluginを1.2.6にアップしたら
既存プロジェクトの起動がエラーになってしまった。こんな。。

java.lang.RuntimeException: Unable to locate the App Engine agent. Please use dev_appserver, KickStart,  or set the jvm flag: "-javaagent:<sdk_root>/lib/agent/appengine-agent.jar"
....
Caused by: java.lang.ClassNotFoundException: com.google.appengine.tools.development.agent.AppEngineDevAgent
....

エラー内容に書いてあるとおりに
vmオプションに"-javaagent:<sdk_root>/lib/agent/appengine-agent.jar"を付けってやると動くようになった。


これはプラグインのバグなのか?( ´д`)

2009年8月26日水曜日

Google Calendar APIを使ってみた。

RESTfulでJSON形式を利用してみた。
これはAndroidで使える。

alt=jsonを付けないとXML形式(デフォールト)になる。

gsessionidを取得するのは最初一回やる必要がある。登録、変更処理で必要。


1.認証
[URL]
POST https://www.google.com/accounts/ClientLogin

[Parameters]
Email=BABUKUMATEST@gmail.com
Passwd=XXXXXXXXX
source=BABUKUMAAPP
service=cl

[Http Request]
POST /accounts/ClientLogin HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: http4e/1.5.4
Host: www.google.com
Content-Length: 73

Email=BABUKUMATEST@gmail.com&Passwd=XXXXXXXXX&source=BABUKUMAAPP&service=cl&

[Http Response]
HTTP/1.1 200 OK
Content-Type: text/plain
Cache-control: no-cache, no-store
Pragma: no-cache
Expires: Mon, 01-Jan-1990 00:00:00 GMT
Date: Wed, 26 Aug 2009 04:48:07 GMT
X-Content-Type-Options: nosniff
Content-Length: 563
Server: GFE/2.0

SID=BABUKUMABABUKUMABABUKUMABABUKUMABABUKUMABABUKUMA
LSID=BABUKUMABABUKUMABABUKUMABABUKUMABABUKUMABABUKUMA
Auth=「ごごにGoogleLogin auth Tokenが」


2. カレンダーリスト取得
[URL]
GET http://www.google.com/calendar/feeds/default/allcalendars/full
[Headers]
Content-Type=application/x-www-form-urlencoded
Authorization: GoogleLogin auth=「GoogleLogin auth Token」

[Parameters]
alt=json

[Http Request]
GET /calendar/feeds/default/allcalendars/full?alt=json& HTTP/1.1
Authorization: GoogleLogin auth=「GoogleLogin auth Token」
Content-Type: application/x-www-form-urlencoded
User-Agent: http4e/1.5.4
Host: www.google.com

GET /calendar/feeds/default/allcalendars/full?alt=json&&gsessionid=BABUKUMABAB HTTP/1.1
Authorization: GoogleLogin auth=「GoogleLogin auth Token」
Content-Type: application/x-www-form-urlencoded
User-Agent: http4e/1.5.4
Host: www.google.com
Cookie: $Version=0; S=calendar=BABUKUMABABUKUMA

[Http Response]
HTTP/1.1 200 OK
Expires: Wed, 26 Aug 2009 05:20:27 GMT
Date: Wed, 26 Aug 2009 05:20:27 GMT
Content-Type: application/json; charset=UTF-8
Cache-Control: private, max-age=0, must-revalidate, no-transform
Vary: Accept, X-GData-Authorization, GData-Version
GData-Version: 1.0
Last-Modified: Wed, 26 Aug 2009 05:20:27 GMT
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
Server: GFE/2.0

{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gCal":"http://schemas.google.com/gCal/2005","xmlns$gd":"http://schemas.google.com/g/2005","id":{"$t":"http://www.google.com/calendar/feeds/default/allcalendars/full"},"updated":{"$t":"2009-08-26T05:20:27.500Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/gCal/2005#calendarmeta"}],".....................................................................}


3. gsessionid取得

一回登録処理をするとレスポンスのLocation部分にgsessionidが入ってる。これを保存する。


4. 予定登録
[URL]
POST http://www.google.com/calendar/feeds/「User_ID」/private/full?alt=json&gsessionid=「取得したgsessionid」

[Headers]
Content-Type=application/atom+xml
Authorization: GoogleLogin auth=「GoogleLogin auth Token」

[Body]
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/g/2005#event'></category>
<title type='text'>Babukuma Test 2</title>
<content type='text'>日本語 Test Test</content>
<gd:transparency
value='http://schemas.google.com/g/2005#event.opaque'>
</gd:transparency>
<gd:eventStatus
value='http://schemas.google.com/g/2005#event.confirmed'>
</gd:eventStatus>
<gd:where valueString='神田'></gd:where>
<gd:when startTime='2009-08-26T15:00:00.000Z'
endTime='2009-08-26T23:00:00.000Z'></gd:when>
</entry>

[Http Request]
HTTP/1.1 201 Created
Expires: Wed, 26 Aug 2009 05:37:13 GMT
Date: Wed, 26 Aug 2009 05:37:13 GMT
Content-Type: application/json; charset=UTF-8
Cache-Control: private, max-age=0, must-revalidate, no-transform
Vary: Accept, X-GData-Authorization, GData-Version
GData-Version: 1.0
Location: http://www.google.com/calendar/feeds/「User_ID」/private/full/babukumababukuma/63386948233
Content-Location: http://www.google.com/calendar/feeds/「User_ID」/private/full/babukumababukuma/63386948233
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
Server: GFE/2.0

{"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gml":"http://www.opengis.net/gml","xmlns$georss":"http://www.georss.org/georss","xmlns$batch":"http://schemas.google.com/gdata/batch","xmlns$gCal":"http://schemas.google.com/gCal/2005","xmlns$gd":"http://schemas.google.com/g/2005","id":.....................................................................}



5. 予定取得
[URL]
GET http://www.google.com/calendar/feeds/「User_ID」/private/full?alt=json

[Headers]
Content-Type=application/x-www-form-urlencoded
Authorization: GoogleLogin auth=「GoogleLogin auth Token」

[Parameters]
alt=json
max-results=15
singleevents=true
sortorder=ascending
futureevents=true

[Http Request]
GET /calendar/feeds/「User_ID」/private/full?alt=json&max-results=15&singleevents=true&sortorder=ascending&futureevents=true& HTTP/1.1
Authorization: GoogleLogin auth=「GoogleLogin auth Token」
Content-Type: application/x-www-form-urlencoded
User-Agent: http4e/1.5.4
Host: www.google.com

GET /calendar/feeds/「User_ID」/private/full?alt=json&max-results=15&singleevents=true&sortorder=ascending&futureevents=true&&gsessionid=「取得したgsessionid」 HTTP/1.1
Authorization: GoogleLogin auth=「GoogleLogin auth Token」
Content-Type: application/x-www-form-urlencoded
User-Agent: http4e/1.5.4
Host: www.google.com
Cookie: $Version=0; S=calendar=babukumababukuma


[Http Response]
HTTP/1.1 200 OK
Expires: Wed, 26 Aug 2009 05:34:39 GMT
Date: Wed, 26 Aug 2009 05:34:39 GMT
Content-Type: application/json; charset=UTF-8
Cache-Control: private, max-age=0, must-revalidate, no-transform
Vary: Accept, X-GData-Authorization, GData-Version
GData-Version: 1.0
Last-Modified: Wed, 26 Aug 2009 05:30:27 GMT
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
Server: GFE/2.0

{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gml":"http://www.opengis.net/gml","xmlns$georss":"http://www.georss.org/georss","xmlns$batch":"http://schemas.google.com/gdata/batch","xmlns$gC.....................................................................}


2009年8月14日金曜日

Chromeにテーマが適用

気づくのが遅かったけど、いつの間にかChromeにテーマが適用された。



不思議な感じがする。(´∀`)

2009年7月9日木曜日

2009年6月30日火曜日

GAE/JのJPA

GAE/JでBigTableをJPAで利用してみた。

① META-INF/persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">

<persistence-unit name="transactions-optional">
<provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
<properties>
<property name="datanucleus.NontransactionalRead" value="true" />
<property name="datanucleus.NontransactionalWrite" value="true" />
<property name="datanucleus.ConnectionURL" value="appengine" />
</properties>
</persistence-unit>

</persistence>


② EMF
package com.babukuma.gae.test.jpa;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class EMF {
private static final EntityManagerFactory emfInstance = Persistence
.createEntityManagerFactory("transactions-optional");

private EMF() {
}

public static EntityManagerFactory get() {
return emfInstance;
}
}

③ エンティティ

package com.babukuma.gae.test.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import com.google.appengine.api.users.User;

@Entity
public class SimpleBoard {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false)
private Long id;

@Column
private User author;

@Column
private String content;

@Column(nullable = false)
private Date date;

public SimpleBoard(User author, String content, Date date) {
this.author = author;
this.content = content;
this.date = date;
}

public Long getId() {
return id;
}

public User getAuthor() {
return author;
}

public String getContent() {
return content;
}

public Date getDate() {
return date;
}

public void setAuthor(User author) {
this.author = author;
}

public void setContent(String content) {
this.content = content;
}

public void setDate(Date date) {
this.date = date;
}
}

④ テストコード

package com.babukuma.gae.test;

import java.io.IOException;
import java.util.Date;

import javax.persistence.EntityManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.babukuma.gae.test.entity.SimpleBoard;
import com.babukuma.gae.test.jpa.EMF;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

@SuppressWarnings("serial")
public class DataStoreTestServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();

String content = req.getParameter("content");

System.out.println("content=" + content);
Date date = new Date();
SimpleBoard board = new SimpleBoard(user, content, date);

EntityManager manager = EMF.get().createEntityManager();
try {
System.out.println("before insert");
manager.persist(board);
System.out.println("after insert");
} catch (Exception e) {
e.printStackTrace();
} finally {
manager.close();
}

resp.setContentType("text/plain");
resp.getWriter().println("Hello, world");
}
}


これ以外に簡単にできるんだな。。(^(エ)^)

2009年6月15日月曜日

Linux版Chromeが使えるようになった


Linux版Chromeが使えるようになった。
何故か今日Ubuntuのシステムアップグレードしてから疲れる気がする。
勝手にバージョンアップされたかな?

でも。。。なぜかHtmlのテキストボックス(input, textarea)では日本語が書けない。。

(・(エ)・;)

2009年6月8日月曜日

Linux版 Chrome

(-(エ)-)これが最初のステップだ



(-(エ)-)