public void testOneToManyReference() { ChromatticSession session = login(); WebSite site = session.insert(WebSite.class, "site"); Content content1 = session.create(Content.class, "1"); Content content2 = session.create(Content.class, "2"); site.getContents().add(content1); Page root = session.create(Page.class); site.setRootPage(root); // root.setContent(content1); }
@Override public boolean onContextItemSelected(MenuItem item) { // TODO Auto-generated method stub AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); if (menuItemIndex == 0) { RSSDatabaseHandler rssDb = new RSSDatabaseHandler(getApplicationContext()); WebSite site = new WebSite(); site.setId(Integer.parseInt(sqliteIds[info.position])); rssDb.deleteSite(site); Intent intent = getIntent(); finish(); startActivity(intent); } return true; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.rss_item_list); // get intent data Intent i = getIntent(); // SQLite Row id Integer site_id = Integer.parseInt(i.getStringExtra("id")); // Getting Single website from SQLite RSSDatabaseHandler rssDB = new RSSDatabaseHandler(getApplicationContext()); WebSite site = rssDB.getSite(site_id); String rss_link = site.getRSSLink(); /** * Calling a backgroung thread will loads recent articles of a website * * @param rss url of website */ new loadRSSFeedItems().execute(rss_link); // selecting single ListView item ListView lv = getListView(); // Launching new screen on Selecting Single ListItem lv.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent in = new Intent(getApplicationContext(), DisPlayWebPageActivity.class); // getting page url String page_url = ((TextView) view.findViewById(R.id.page_url)).getText().toString(); Toast.makeText(getApplicationContext(), page_url, Toast.LENGTH_SHORT).show(); in.putExtra("page_url", page_url); startActivity(in); } }); }
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { /* Usage of this servlet must be restricted to authenticated users, otherwise it'd be really easy to download the whole site */ UserInfo userInfo = (UserInfo) request.getSession(true).getAttribute("userInfo"); if (userInfo == null || userInfo.isGuest()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } WebSite webSite = (WebSite) request.getAttribute("webSite"); Path path = new Path(request.getPathInfo()); /* if (webSite.isSystem(path)) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } */ File file = webSite.getFile(path); if (!file.exists()) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "File not found on server"); return; } response.setContentType("application/x-download"); String fileName = request.getParameter("filename"); if (Utils.isNullOrEmpty(fileName)) { fileName = path.getLastElement(); } if (!file.isDirectory()) { fileName = Utils.removeExtension(fileName); } response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + ".zip\""); new ZipArchiver(file, response.getOutputStream()).process(); }