Skip to content
Browse files

jpa entity

  • Loading branch information...
0 parents commit 706a3e6992a83df9d6480c333adcf6c8253e0ac8 Jan Holman committed
Showing with 843 additions and 0 deletions.
  1. +7 −0 pa165 projekt/.classpath
  2. +33 −0 pa165 projekt/.project
  3. +5 −0 pa165 projekt/.settings/com.google.appengine.eclipse.core.prefs
  4. +4 −0 pa165 projekt/.settings/com.google.gdt.eclipse.core.prefs
  5. +15 −0 pa165 projekt/src/META-INF/jdoconfig.xml
  6. +38 −0 pa165 projekt/src/jpa/dao/CardDao.java
  7. +15 −0 pa165 projekt/src/jpa/dao/EMF.java
  8. +29 −0 pa165 projekt/src/jpa/dao/GroupDao.java
  9. +109 −0 pa165 projekt/src/jpa/dao/JpaCardDao.java
  10. +101 −0 pa165 projekt/src/jpa/dao/JpaGroupDao.java
  11. +114 −0 pa165 projekt/src/jpa/domain/Card.java
  12. +76 −0 pa165 projekt/src/jpa/domain/Group.java
  13. +97 −0 pa165 projekt/src/jpa/domain/Tag.java
  14. +24 −0 pa165 projekt/src/log4j.properties
  15. +26 −0 pa165 projekt/src/servlet/Pa165_projektServlet.java
  16. +4 −0 pa165 projekt/war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
  17. BIN pa165 projekt/war/WEB-INF/appengine-generated/local_db.bin
  18. +33 −0 pa165 projekt/war/WEB-INF/appengine-web.xml
  19. +15 −0 pa165 projekt/war/WEB-INF/classes/META-INF/jdoconfig.xml
  20. +16 −0 pa165 projekt/war/WEB-INF/classes/META-INF/persistence.xml
  21. BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/CardDao.class
  22. BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/EMF.class
  23. BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/GroupDao.class
  24. BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/JpaCardDao.class
  25. BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/JpaGroupDao.class
  26. BIN pa165 projekt/war/WEB-INF/classes/jpa/domain/Card.class
  27. BIN pa165 projekt/war/WEB-INF/classes/jpa/domain/Group.class
  28. BIN pa165 projekt/war/WEB-INF/classes/jpa/domain/Tag.class
  29. +24 −0 pa165 projekt/war/WEB-INF/classes/log4j.properties
  30. BIN pa165 projekt/war/WEB-INF/classes/servlet/Pa165_projektServlet.class
  31. BIN pa165 projekt/war/WEB-INF/lib/appengine-api-1.0-sdk-1.6.3.jar
  32. BIN pa165 projekt/war/WEB-INF/lib/appengine-api-labs-1.6.3.jar
  33. BIN pa165 projekt/war/WEB-INF/lib/appengine-jsr107cache-1.6.3.jar
  34. BIN pa165 projekt/war/WEB-INF/lib/datanucleus-appengine-1.0.10.final.jar
  35. BIN pa165 projekt/war/WEB-INF/lib/datanucleus-core-1.1.5.jar
  36. BIN pa165 projekt/war/WEB-INF/lib/datanucleus-jpa-1.1.5.jar
  37. BIN pa165 projekt/war/WEB-INF/lib/geronimo-jpa_3.0_spec-1.1.1.jar
  38. BIN pa165 projekt/war/WEB-INF/lib/geronimo-jta_1.1_spec-1.1.1.jar
  39. BIN pa165 projekt/war/WEB-INF/lib/jdo2-api-2.3-eb.jar
  40. BIN pa165 projekt/war/WEB-INF/lib/jsr107cache-1.1.jar
  41. +13 −0 pa165 projekt/war/WEB-INF/logging.properties
  42. +18 −0 pa165 projekt/war/WEB-INF/web.xml
  43. BIN pa165 projekt/war/favicon.ico
  44. +27 −0 pa165 projekt/war/index.html
7 pa165 projekt/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="war/WEB-INF/classes"/>
+</classpath>
33 pa165 projekt/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>pa165 projekt</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.appengine.eclipse.core.projectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.appengine.eclipse.core.enhancerbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>com.google.appengine.eclipse.core.gaeNature</nature>
+ </natures>
+</projectDescription>
5 pa165 projekt/.settings/com.google.appengine.eclipse.core.prefs
@@ -0,0 +1,5 @@
+#Sun Mar 18 15:34:08 CET 2012
+eclipse.preferences.version=1
+filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.6.3.jar|appengine-api-labs-1.6.3.jar|appengine-jsr107cache-1.6.3.jar|jsr107cache-1.1.jar|datanucleus-appengine-1.0.10.final.jar|datanucleus-core-1.1.5.jar|datanucleus-jpa-1.1.5.jar|geronimo-jpa_3.0_spec-1.1.1.jar|geronimo-jta_1.1_spec-1.1.1.jar|jdo2-api-2.3-eb.jar
+gaeHrdEnabled=true
+gaeIsEclipseDefaultInstPath=true
4 pa165 projekt/.settings/com.google.gdt.eclipse.core.prefs
@@ -0,0 +1,4 @@
+#Sun Mar 18 15:34:05 CET 2012
+eclipse.preferences.version=1
+warSrcDir=war
+warSrcDirIsOutput=true
15 pa165 projekt/src/META-INF/jdoconfig.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
+
+ <persistence-manager-factory name="transactions-optional">
+ <property name="javax.jdo.PersistenceManagerFactoryClass"
+ value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
+ <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
+ <property name="javax.jdo.option.NontransactionalRead" value="true"/>
+ <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
+ <property name="javax.jdo.option.RetainValues" value="true"/>
+ <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
+ </persistence-manager-factory>
+</jdoconfig>
38 pa165 projekt/src/jpa/dao/CardDao.java
@@ -0,0 +1,38 @@
+package jpa.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.users.User;
+
+import jpa.domain.Card;
+import jpa.domain.Group;
+import jpa.domain.Tag;
+
+public interface CardDao {
+
+ public Card addCard(Card card);
+
+ public void removeCard(Card card);
+
+ public Card updateCard(Card card);
+
+ public List<Card> getAllCards();
+
+ public Card findCardByKey(Key key);
+
+ public List<Card> findCardsByOwner(User owner);
+
+ public List<Group> getAllGroupsOfCard(Card card);
+
+ public Card addTag(Card card, Tag tag);
+
+ public Card removeTag(Card card, Tag tag);
+
+// public Card updateTag(Card card, Tag tag);
+ // zbytecna metoda? (zmenit tag a zavolat updateCard())
+
+ public Map<String, Tag> getAllTags(Card card);
+
+}
15 pa165 projekt/src/jpa/dao/EMF.java
@@ -0,0 +1,15 @@
+package jpa.dao;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+public final class EMF {
+ private static final EntityManagerFactory emfInstance =
+ Persistence.createEntityManagerFactory("transactions-optional");
+
+ private EMF() {}
+
+ public static EntityManagerFactory get() {
+ return emfInstance;
+ }
+}
29 pa165 projekt/src/jpa/dao/GroupDao.java
@@ -0,0 +1,29 @@
+package jpa.dao;
+
+import java.util.List;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.users.User;
+import jpa.domain.Card;
+import jpa.domain.Group;
+
+public interface GroupDao {
+
+ public Group addGroup(Group group);
+
+ public void removeGroup(Group group);
+
+ public Group updateGroup(Group group);
+
+ public List<Group> getAllGroups();
+
+ public Group findGroupByKey(Key key);
+
+ public List<Group> findGroupsByOwner(User owner);
+
+ public Group addCardToGroup(Group group, Card card);
+
+ public Group removeCardFomGroup(Group group, Card card);
+
+ public List<Card> getCardsInGroup(Group group);
+
+}
109 pa165 projekt/src/jpa/dao/JpaCardDao.java
@@ -0,0 +1,109 @@
+package jpa.dao;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.users.User;
+import jpa.domain.Card;
+import jpa.domain.Group;
+import jpa.domain.Tag;
+
+public class JpaCardDao implements CardDao {
+
+ EntityManager em = EMF.get().createEntityManager();
+
+ @Override
+ public Card addCard(Card card) {
+ em.persist(card);
+ em.refresh(card);
+ return card;
+ }
+
+ @Override
+ public void removeCard(Card card) {
+ em.getTransaction().begin();
+ em.remove(card);
+ em.getTransaction().commit();
+ }
+
+ @Override
+ public Card updateCard(Card card) {
+ if (card.getGaeKey() == null) {
+ em.persist(card);
+ } else {
+ em.merge(card);
+ }
+ return card;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<Card> getAllCards() {
+ Query query = em.createQuery("SELECT c FROM Card c");
+ return (List<Card>)query.getResultList();
+ }
+
+ @Override
+ public Card findCardByKey(Key key) {
+ Card card = em.find(Card.class, key);
+ return card;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<Card> findCardsByOwner(User owner) {
+ Query query = em.createQuery("SELECT c FROM Card c WHERE owner = ?1").setParameter(1, owner);
+ return (List<Card>)query.getResultList();
+ }
+
+ @Override
+ public List<Group> getAllGroupsOfCard(Card card) {
+ ArrayList<Group> groupList = new ArrayList<Group>();
+ for (Key groupKey : card.getGroupKeys()) {
+ groupList.add(em.find(Group.class, groupKey));
+ }
+ return groupList;
+ }
+
+ @Override
+ public Card addTag(Card card, Tag tag) {
+ em.persist(tag);
+ card.getTags().add(tag);
+ em.merge(card);
+ return card;
+ }
+
+ @Override
+ public Card removeTag(Card card, Tag tag) {
+ em.getTransaction().begin();
+ card.getTags().remove(tag);
+ em.remove(tag);
+ em.getTransaction().commit();
+ em.merge(card);
+ return card;
+ }
+
+// @Override
+// public Card updateTag(Card card, Tag tag) {
+// // TODO Auto-generated method stub
+// return null;
+// }
+
+ @Override
+ public Map<String, Tag> getAllTags(Card card) {
+ HashMap<String, Tag> map = new HashMap<String, Tag>();
+ List<Tag> cardList = (List<Tag>) card.getTags();
+
+ System.out.println(cardList.size());
+
+ for (Tag tag : cardList) {
+ map.put(tag.getKey(), tag);
+ }
+ return map;
+ }
+
+}
101 pa165 projekt/src/jpa/dao/JpaGroupDao.java
@@ -0,0 +1,101 @@
+package jpa.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.users.User;
+import jpa.domain.Card;
+import jpa.domain.Group;
+
+public class JpaGroupDao implements GroupDao {
+
+ EntityManager em = EMF.get().createEntityManager();
+
+ @Override
+ public Group addGroup(Group group) {
+ if (group.getGaeKey() == null) {
+ em.persist(group);
+ em.refresh(group);
+ return group;
+ }
+ em.merge(group);
+ return group;
+ }
+
+ @Override
+ public void removeGroup(Group group) {
+ em.getTransaction().begin();
+ em.remove(group);
+ em.getTransaction().commit();
+ }
+
+ @Override
+ public Group updateGroup(Group group) {
+ if (group == null) {
+ em.persist(group);
+ } else {
+ em.merge(group);
+ }
+ return group;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<Group> getAllGroups() {
+ Query query = em.createQuery("SELECT g FROM Group g");
+ return (List<Group>)query.getResultList();
+ }
+
+ @Override
+ public Group findGroupByKey(Key key) {
+ return em.find(Group.class, key);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<Group> findGroupsByOwner(User owner) {
+ Query query = em.createQuery("SELECT g FROM Group g WHERE owner = ?1").setParameter(1, owner);
+ return (List<Group>)query.getResultList();
+ }
+
+ @Override
+ public Group addCardToGroup(Group group, Card card) {
+ if (card.getGaeKey() == null) {
+ em.persist(card);
+ }
+ if (group.getGaeKey() == null) {
+ em.persist(group);
+ }
+ group.getCardKeys().add(card.getGaeKey());
+ card.getGroupKeys().add(group.getGaeKey());
+ em.merge(group);
+ return group;
+ }
+
+ @Override
+ public Group removeCardFomGroup(Group group, Card card) {
+ if (card.getGaeKey() == null) {
+ em.persist(card);
+ }
+ if (group.getGaeKey() == null) {
+ em.persist(group);
+ }
+ group.getCardKeys().remove(card.getGaeKey());
+ card.getGroupKeys().remove(group.getGaeKey());
+ em.merge(group);
+ em.merge(card);
+ return group;
+ }
+
+ @Override
+ public ArrayList<Card> getCardsInGroup(Group group) {
+ ArrayList<Card> cardList = new ArrayList<Card>();
+ for (Key cardKey : group.getCardKeys()) {
+ cardList.add(em.find(Card.class, cardKey));
+ }
+ return cardList;
+ }
+
+}
114 pa165 projekt/src/jpa/domain/Card.java
@@ -0,0 +1,114 @@
+package jpa.domain;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.users.User;
+
+@Entity
+public class Card {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Key gaeKey;
+
+ @OneToMany(cascade=CascadeType.ALL)
+ private List<Tag> tags;
+
+ private File img;
+ private User owner;
+ private boolean privacy;
+ private Date created;
+
+ @ManyToMany(mappedBy="cards")
+ private Set<Key> groupKeys;
+
+ public Card(File img, User owner, boolean privacy) {
+ this.setImg(img);
+ this.setOwner(owner);
+ this.setPrivacy(privacy);
+ this.tags = new ArrayList<Tag>();
+ this.setCreated(new Date());
+ this.setGroupKeys(new HashSet<Key>());
+ }
+
+ public Card(String imgPath, User owner, boolean privac) {
+ this.setImg(new File(imgPath));
+ this.setOwner(owner);
+ this.setPrivacy(privacy);
+ this.setCreated(created);
+ this.tags = new ArrayList<Tag>();
+ this.setCreated(new Date());
+ this.setGroupKeys(new HashSet<Key>());
+ }
+
+ public Key getGaeKey() {
+ return gaeKey;
+ }
+
+ public void setGaeKey(Key key) {
+ this.gaeKey = key;
+ }
+
+ public List<Tag> getTags() {
+ return tags;
+ }
+
+ public void setTags(List<Tag> tags) {
+ this.tags = tags;
+ }
+
+ public File getImg() {
+ return img;
+ }
+
+ public void setImg(File img) {
+ this.img = img;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public void setOwner(User owner) {
+ this.owner = owner;
+ }
+
+ public boolean isPrivacy() {
+ return privacy;
+ }
+
+ public void setPrivacy(boolean privacy) {
+ this.privacy = privacy;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ // pristupovat pres CardDao.getAllGroupsOfCard(Card card)
+ public Set<Key> getGroupKeys() {
+ return groupKeys;
+ }
+
+ public void setGroupKeys(Set<Key> groups) {
+ this.groupKeys = groups;
+ }
+
+}
76 pa165 projekt/src/jpa/domain/Group.java
@@ -0,0 +1,76 @@
+package jpa.domain;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.users.User;
+
+@Entity
+public class Group {
+
+ public Group(String name, User owner) {
+ this.setName(name);
+ this.setOwner(owner);
+ this.setCardKeys(new HashSet<Key>());
+ this.setCreated(new Date());
+ }
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Key gaeKey;
+
+ private String name;
+ private User owner;
+ private Date created;
+
+ @ManyToMany(mappedBy="groups")
+ private Set<Key> cardKeys;
+
+
+ public Key getGaeKey() {
+ return gaeKey;
+ }
+
+ public void setGaeKey(Key key) {
+ this.gaeKey = key;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public void setOwner(User owner) {
+ this.owner = owner;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ // pristupovat pres GroupDao.getCardsInGroup(Group group)
+ public Set<Key> getCardKeys() {
+ return cardKeys;
+ }
+
+ public void setCardKeys(Set<Key> cards) {
+ this.cardKeys = cards;
+ }
+}
97 pa165 projekt/src/jpa/domain/Tag.java
@@ -0,0 +1,97 @@
+package jpa.domain;
+
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.users.User;
+
+@Entity
+public class Tag {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Key gaeKey;
+
+ private String key;
+ private String content;
+ private String note;
+ private User owner;
+ private boolean privacy;
+ private Date created;
+
+ // private Card card;
+
+ public Tag(String key, String content, boolean privacy) {
+ this.setKey(key);
+ this.setContent(content);
+ this.setPrivacy(privacy);
+ this.setCreated(new Date());
+ }
+
+ public Key getGaeKey() {
+ return gaeKey;
+ }
+
+ public void setGaeKey(Key gaeKey) {
+ this.gaeKey = gaeKey;
+ }
+
+ public String getName() {
+ return key;
+ }
+
+ public void setName(String name) {
+ this.key = name;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getNote() {
+ return note;
+ }
+
+ public void setNote(String note) {
+ this.note = note;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public void setOwner(User owner) {
+ this.owner = owner;
+ }
+
+ public boolean isPrivacy() {
+ return privacy;
+ }
+
+ public void setPrivacy(boolean privacy) {
+ this.privacy = privacy;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+}
24 pa165 projekt/src/log4j.properties
@@ -0,0 +1,24 @@
+# A default log4j configuration for log4j users.
+#
+# To use this configuration, deploy it into your application's WEB-INF/classes
+# directory. You are also encouraged to edit it as you like.
+
+# Configure the console as our one appender
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
+
+# tighten logging on the DataNucleus Categories
+log4j.category.DataNucleus.JDO=WARN, A1
+log4j.category.DataNucleus.Persistence=WARN, A1
+log4j.category.DataNucleus.Cache=WARN, A1
+log4j.category.DataNucleus.MetaData=WARN, A1
+log4j.category.DataNucleus.General=WARN, A1
+log4j.category.DataNucleus.Utility=WARN, A1
+log4j.category.DataNucleus.Transaction=WARN, A1
+log4j.category.DataNucleus.Datastore=WARN, A1
+log4j.category.DataNucleus.ClassLoading=WARN, A1
+log4j.category.DataNucleus.Plugin=WARN, A1
+log4j.category.DataNucleus.ValueGeneration=WARN, A1
+log4j.category.DataNucleus.Enhancer=WARN, A1
+log4j.category.DataNucleus.SchemaTool=WARN, A1
26 pa165 projekt/src/servlet/Pa165_projektServlet.java
@@ -0,0 +1,26 @@
+package servlet;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import com.google.appengine.api.users.User;
+import com.google.appengine.api.users.UserService;
+import com.google.appengine.api.users.UserServiceFactory;
+
+public class Pa165_projektServlet extends HttpServlet {
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+ UserService userService = UserServiceFactory.getUserService();
+ User user = userService.getCurrentUser();
+
+ if (user != null) {
+ resp.setContentType("text/plain");
+ resp.getWriter().println("Hello, " + user.getNickname());
+ } else {
+ resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
+ }
+
+ }
+
+}
4 pa165 projekt/war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
@@ -0,0 +1,4 @@
+<!-- Indices written at Wed, 28 Mar 2012 20:07:35 GMT+01:00 -->
+
+<datastore-indexes/>
+
BIN pa165 projekt/war/WEB-INF/appengine-generated/local_db.bin
Binary file not shown.
33 pa165 projekt/war/WEB-INF/appengine-web.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
+ <application></application>
+ <version>1</version>
+
+ <!--
+ By default, App Engine sends requests serially to a given web server.
+ To allow App Engine to send multiple requests in parallel specify:
+
+ <threadsafe>true</threadsafe>
+ -->
+
+ <!-- Configure java.util.logging -->
+ <system-properties>
+ <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
+ </system-properties>
+
+ <!--
+ HTTP Sessions are disabled by default. To enable HTTP sessions specify:
+
+ <sessions-enabled>true</sessions-enabled>
+
+ It's possible to reduce request latency by configuring your application to
+ asynchronously write HTTP session data to the datastore:
+
+ <async-session-persistence enabled="true" />
+
+ With this feature enabled, there is a very small chance your app will see
+ stale session data. For details, see
+ http://code.google.com/appengine/docs/java/config/appconfig.html#Enabling_Sessions
+ -->
+
+</appengine-web-app>
15 pa165 projekt/war/WEB-INF/classes/META-INF/jdoconfig.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
+
+ <persistence-manager-factory name="transactions-optional">
+ <property name="javax.jdo.PersistenceManagerFactoryClass"
+ value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
+ <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
+ <property name="javax.jdo.option.NontransactionalRead" value="true"/>
+ <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
+ <property name="javax.jdo.option.RetainValues" value="true"/>
+ <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
+ </persistence-manager-factory>
+</jdoconfig>
16 pa165 projekt/war/WEB-INF/classes/META-INF/persistence.xml
@@ -0,0 +1,16 @@
+<?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>
BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/CardDao.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/EMF.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/GroupDao.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/JpaCardDao.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/classes/jpa/dao/JpaGroupDao.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/classes/jpa/domain/Card.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/classes/jpa/domain/Group.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/classes/jpa/domain/Tag.class
Binary file not shown.
24 pa165 projekt/war/WEB-INF/classes/log4j.properties
@@ -0,0 +1,24 @@
+# A default log4j configuration for log4j users.
+#
+# To use this configuration, deploy it into your application's WEB-INF/classes
+# directory. You are also encouraged to edit it as you like.
+
+# Configure the console as our one appender
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
+
+# tighten logging on the DataNucleus Categories
+log4j.category.DataNucleus.JDO=WARN, A1
+log4j.category.DataNucleus.Persistence=WARN, A1
+log4j.category.DataNucleus.Cache=WARN, A1
+log4j.category.DataNucleus.MetaData=WARN, A1
+log4j.category.DataNucleus.General=WARN, A1
+log4j.category.DataNucleus.Utility=WARN, A1
+log4j.category.DataNucleus.Transaction=WARN, A1
+log4j.category.DataNucleus.Datastore=WARN, A1
+log4j.category.DataNucleus.ClassLoading=WARN, A1
+log4j.category.DataNucleus.Plugin=WARN, A1
+log4j.category.DataNucleus.ValueGeneration=WARN, A1
+log4j.category.DataNucleus.Enhancer=WARN, A1
+log4j.category.DataNucleus.SchemaTool=WARN, A1
BIN pa165 projekt/war/WEB-INF/classes/servlet/Pa165_projektServlet.class
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/appengine-api-1.0-sdk-1.6.3.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/appengine-api-labs-1.6.3.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/appengine-jsr107cache-1.6.3.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/datanucleus-appengine-1.0.10.final.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/datanucleus-core-1.1.5.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/datanucleus-jpa-1.1.5.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/geronimo-jpa_3.0_spec-1.1.1.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/geronimo-jta_1.1_spec-1.1.1.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/jdo2-api-2.3-eb.jar
Binary file not shown.
BIN pa165 projekt/war/WEB-INF/lib/jsr107cache-1.1.jar
Binary file not shown.
13 pa165 projekt/war/WEB-INF/logging.properties
@@ -0,0 +1,13 @@
+# A default java.util.logging configuration.
+# (All App Engine logging is through java.util.logging by default).
+#
+# To use this configuration, copy it into your application's WEB-INF
+# folder and add the following to your appengine-web.xml:
+#
+# <system-properties>
+# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
+# </system-properties>
+#
+
+# Set the default logging level for all loggers to WARNING
+.level = WARNING
18 pa165 projekt/war/WEB-INF/web.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns="http://java.sun.com/xml/ns/javaee"
+xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
+ <servlet>
+ <servlet-name>Pa165_projektServlet</servlet-name>
+ <servlet-class>servlet.Pa165_projektServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Pa165_projektServlet</servlet-name>
+ <url-pattern>/Pa165_projektServlet</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+</web-app>
BIN pa165 projekt/war/favicon.ico
Binary file not shown.
27 pa165 projekt/war/index.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!-- The HTML 4.01 Transitional DOCTYPE declaration-->
+<!-- above set at the top of the file will set -->
+<!-- the browser's rendering engine into -->
+<!-- "Quirks Mode". Replacing this declaration -->
+<!-- with a "Standards Mode" doctype is supported, -->
+<!-- but may lead to some differences in layout. -->
+
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Hello App Engine</title>
+ </head>
+
+ <body>
+ <h1>Hello App Engine!</h1>
+
+ <table>
+ <tr>
+ <td colspan="2" style="font-weight:bold;">Available Servlets:</td>
+ </tr>
+ <tr>
+ <td><a href="Pa165_projektServlet">Pa165_projekt</a></td>
+ </tr>
+ </table>
+ </body>
+</html>

0 comments on commit 706a3e6

Please sign in to comment.
Something went wrong with that request. Please try again.