Exemplo n.º 1
0
 public ServiceResult<Void> updatePage(Page editPage) {
   ServiceResult<Void> result = new ServiceResult<Void>();
   Page page = null;
   PersistenceManager pm = null;
   try {
     pm = PMF.get().getPersistenceManager();
     page = pm.getObjectById(Page.class, editPage.getId());
     if (page == null) {
       result.setOK(false);
       result.setMessage(Global.messages.getString("no_page_found"));
     } else {
       page.setContent(editPage.getContent());
       page.setDate_post(editPage.getDate_post());
       page.setLast_modified(editPage.getLast_modified());
       page.setLink_thumbnail(editPage.getLink_thumbnail());
       page.setName(editPage.getName());
       page.setPage_view(editPage.getPage_view());
       page.setSetCategoryKeys(editPage.getSetCategoryKeys());
       page.setSetProduct(editPage.getSetProduct());
       result.setOK(true);
       result.setMessage(Global.messages.getString("update_page_successfully"));
     }
   } catch (Exception e) {
     result.setMessage(Global.messages.getString("update_page_fail"));
     result.setOK(false);
     e.printStackTrace();
   } finally {
     try {
       pm.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return result;
 }
Exemplo n.º 2
0
 public ServiceResult<Long> insertPage(Page page) {
   // updateFTSStuffForPage(page);
   page.updateFTS();
   ServiceResult<Long> result = new ServiceResult<Long>();
   PersistenceManager pm = PMF.get().getPersistenceManager();
   try {
     page = pm.makePersistent(page);
     if (page == null) {
       result.setMessage(Global.messages.getString("insert_page_fail"));
     } else {
       result.setResult(page.getId());
       result.setMessage(Global.messages.getString("insert_page_successfully"));
       result.setOK(true);
     }
   } catch (Exception e) {
     e.printStackTrace();
     result.setMessage(Global.messages.getString("insert_page_fail"));
   } finally {
     try {
       pm.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return result;
 }