views:

29

answers:

0

I tried the following code:

Appsprovisioning.java

public void calluser() throws AppsForYourDomainExceptiion IOException
{
    for(UserEntry userEntry : retrieveAllUsers().getEntries())
    {
        m[x]= userEntry.getTitle().getPlainText();
        x++;
    }

    try
    {
        for(int i=0;i<x;i++)
        {
            String sd=m[i];
            stud greeting1 = new stud(sd);
            em.persist(greeting1);
            System.out.println("jk");
        }
    }
    finally
    {
        em.close();
    }
}

public UserFeed retrieveAllUsers()throws  ,ServiceException, IOException{
    userService = new UserService("Myapplication");
    userService.setUserCredentials("[email protected]","xxxxxxxx");

    URL retrieveUrl = new URL("https://www.google.com/a/feeds/montfortperungudi.edu.in/user/2.0/");
    UserFeed allUsers = new UserFeed();
    UserFeed currentPage;

    Link nextLink;
    do {
        currentPage = userService.getFeed(retrieveUrl, UserFeed.class);
        allUsers.getEntries().addAll(currentPage.getEntries());

        nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
        if (nextLink != null) {
            retrieveUrl = new URL(nextLink.getHref());
        }
    } while (nextLink != null);

    return allUsers;
}

Servlet.java

public class servlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private static final Logger log = Logger.getLogger(servlet.class.getName());
    //  EntityManager em=null;
    AppsProvisioning aa=new AppsProvisioning();

    public void doGet(HttpServletRequest req, HttpServletResponse resp)throws IOException {
        //em = EMFService.get().createEntityManager();
        try {
            aa.calluser();
        } catch(Exception e){
            System.out.println("SEF "+e);
        } finally {
            // em.clear();
            //  em.close();
        }
    }
}

Table Creation

import javax.persistence.Entity;
import javax.persistence.Id;
@Entity(name="stud")
public class stud {
    @Id
    private String fathername;
    public stud(String fathername)
    {// TODO Auto-generated constructor stub
        this.fathername=fathername;
    }

    public void setFathername(String fathername) {
        this.fathername = fathername;
    }

    public String getFathername() {
        return fathername;
    }
}

I retrieved users from domain but i cant able to store entire details in the table.... Its returning Time session Error.