Beispiel #1
0
  @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();
    }
  }
Beispiel #2
0
 @WebMethod
 public String getPassword(String email) throws JAXBException, IOException {
   SocialApp app = getSocialApp();
   Users users = app.getUsers();
   User user = users.getUser(email);
   return user.getPassword();
 }
Beispiel #3
0
 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;
   }
 }
Beispiel #4
0
 @WebMethod
 public User login(String email, String password) throws JAXBException, IOException {
   SocialApp app = getSocialApp();
   Users users = app.getUsers();
   return users.logon(email, password);
 }
Beispiel #5
0
 @WebMethod
 public User getUser(String email) throws JAXBException, IOException {
   SocialApp app = getSocialApp();
   Users users = app.getUsers();
   return users.getUser(email);
 }