예제 #1
0
파일: Blog.java 프로젝트: pcolusso/social
  @WebMethod
  public void deleteArticle(User user, String title) {
    SocialApp app = null;
    try {
      app = getSocialApp();
    } catch (JAXBException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    for (Article article : user.getBlog()) {
      if (article.getTitle().equals(title)) user.getBlog().remove(article);
    }

    try {
      app.save();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (JAXBException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
예제 #2
0
파일: Blog.java 프로젝트: pcolusso/social
 @WebMethod
 public String getPassword(String email) throws JAXBException, IOException {
   SocialApp app = getSocialApp();
   Users users = app.getUsers();
   User user = users.getUser(email);
   return user.getPassword();
 }
예제 #3
0
파일: Blog.java 프로젝트: pcolusso/social
 private SocialApp getSocialApp() throws JAXBException, IOException {
   ServletContext application =
       (ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
   synchronized (application) {
     SocialApp socialApp = (SocialApp) application.getAttribute("socialApp");
     if (socialApp == null) {
       socialApp = new SocialApp();
       socialApp.setFilePath(application.getRealPath("users.xml"));
       application.setAttribute("socialApp", socialApp);
     }
     return socialApp;
   }
 }
예제 #4
0
파일: Blog.java 프로젝트: pcolusso/social
 @WebMethod
 public User login(String email, String password) throws JAXBException, IOException {
   SocialApp app = getSocialApp();
   Users users = app.getUsers();
   return users.logon(email, password);
 }
예제 #5
0
파일: Blog.java 프로젝트: pcolusso/social
 @WebMethod
 public User getUser(String email) throws JAXBException, IOException {
   SocialApp app = getSocialApp();
   Users users = app.getUsers();
   return users.getUser(email);
 }