Search in sources :

Example 1 with Page

use of model.Page in project manifoldcf by apache.

the class ConfluenceRepositoryConnector method processSeedAttachments.

/**
 * <p>
 * Process seed attachments for the given page
 * </p>
 *
 * @param page
 * @param activities
 */
private void processSeedAttachments(final Page page, final ISeedingActivity activities) throws ManifoldCFException, ServiceInterruption {
    long lastStart = 0;
    final long defaultSize = 50;
    if (Logging.connectors != null && Logging.connectors.isDebugEnabled()) {
        Logging.connectors.debug(new MessageFormat("Processing page {} attachments starting from {} and size {}", Locale.ROOT).format(new Object[] { page.getId(), lastStart, defaultSize }));
    }
    try {
        Boolean isLast = true;
        do {
            final ConfluenceResponse<Attachment> response = confluenceClient.getPageAttachments(page.getId(), (int) lastStart, (int) defaultSize);
            int count = 0;
            for (final Page resultPage : response.getResults()) {
                activities.addSeedDocument(ConfluenceUtil.generateRepositoryDocumentIdentifier(resultPage.getId(), page.getId()));
                count++;
            }
            if (Logging.connectors != null && Logging.connectors.isDebugEnabled()) {
                Logging.connectors.debug(new MessageFormat("Fetched and added {} seed document attachments for page {}", Locale.ROOT).format(new Object[] { new Integer(count), page.getId() }));
            }
            lastStart += count;
            isLast = response.isLast();
            if (Logging.connectors != null && Logging.connectors.isDebugEnabled()) {
                Logging.connectors.debug(new MessageFormat("New start {0} and size {1}", Locale.ROOT).format(new Object[] { lastStart, defaultSize }));
            }
        } while (!isLast);
    } catch (final Exception e) {
        handleConfluenceDownException(e, "seeding");
    }
}
Also used : MessageFormat(java.text.MessageFormat) JSONObject(org.json.simple.JSONObject) Attachment(org.apache.manifoldcf.crawler.connectors.confluence.v6.model.Attachment) Page(org.apache.manifoldcf.crawler.connectors.confluence.v6.model.Page) InterruptedIOException(java.io.InterruptedIOException) ParseException(org.json.simple.parser.ParseException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) IOException(java.io.IOException)

Example 2 with Page

use of model.Page in project BookShop by Eins51.

the class GoodsListServlet method doGet.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    int id = 0;
    if (request.getParameter("typeid") != null) {
        id = Integer.parseInt(request.getParameter("typeid"));
    }
    int pageNumber = 1;
    if (request.getParameter("pageNumber") != null) {
        try {
            pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
        } catch (Exception e) {
        }
    }
    Type t = null;
    if (id != 0) {
        t = tService.selectTypeNameByID(id);
    }
    request.setAttribute("t", t);
    if (pageNumber <= 0)
        pageNumber = 1;
    Page p = gService.selectPageByTypeID(id, pageNumber);
    if (p.getTotalPage() == 0) {
        p.setTotalPage(1);
        p.setPageNumber(1);
    } else {
        if (pageNumber >= p.getTotalPage() + 1) {
            p = gService.selectPageByTypeID(id, p.getTotalPage());
        }
    }
    request.setAttribute("p", p);
    request.setAttribute("id", String.valueOf(id));
    request.getRequestDispatcher("/goods_list.jsp").forward(request, response);
}
Also used : Type(model.Type) Page(model.Page) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 3 with Page

use of model.Page in project BookShop by Eins51.

the class GoodsService method selectPageByTypeID.

public Page selectPageByTypeID(int typeID, int pageNumber) {
    Page p = new Page();
    p.setPageNumber(pageNumber);
    int totalCount = 0;
    try {
        totalCount = gDao.getCountOfGoodsByTypeID(typeID);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    p.SetPageSizeAndTotalCount(8, totalCount);
    List list = null;
    try {
        list = gDao.selectGoodsByTypeID(typeID, pageNumber, 8);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    p.setList(list);
    return p;
}
Also used : SQLException(java.sql.SQLException) Page(model.Page) List(java.util.List)

Example 4 with Page

use of model.Page in project BookShop by Eins51.

the class UserService method getUserPage.

public Page getUserPage(int pageNumber) {
    Page p = new Page();
    p.setPageNumber(pageNumber);
    int pageSize = 7;
    int totalCount = 0;
    try {
        totalCount = uDao.selectUserCount();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    p.SetPageSizeAndTotalCount(pageSize, totalCount);
    List list = null;
    try {
        list = uDao.selectUserList(pageNumber, pageSize);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    p.setList(list);
    return p;
}
Also used : SQLException(java.sql.SQLException) Page(model.Page) List(java.util.List)

Example 5 with Page

use of model.Page in project BookShop by Eins51.

the class AdminGoodsListServlet method doGet.

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // 推荐类型
    int type = 0;
    if (request.getParameter("type") != null) {
        type = Integer.parseInt(request.getParameter("type"));
    }
    int pageNumber = 1;
    if (request.getParameter("pageNumber") != null) {
        try {
            pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
        } catch (Exception e) {
        }
    }
    if (pageNumber <= 0)
        pageNumber = 1;
    Page p = gService.getGoodsRecommendPage(type, pageNumber);
    if (p.getTotalPage() == 0) {
        p.setTotalPage(1);
        p.setPageNumber(1);
    } else {
        if (pageNumber >= p.getTotalPage() + 1) {
            p = gService.getGoodsRecommendPage(type, pageNumber);
        }
    }
    request.setAttribute("p", p);
    request.setAttribute("type", type);
    request.getRequestDispatcher("/admin/goods_list.jsp").forward(request, response);
}
Also used : Page(model.Page) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

Page (model.Page)9 IOException (java.io.IOException)8 List (java.util.List)5 ServletException (javax.servlet.ServletException)5 SQLException (java.sql.SQLException)4 Page (org.apache.manifoldcf.crawler.connectors.confluence.v6.model.Page)4 JSONObject (org.json.simple.JSONObject)4 InterruptedIOException (java.io.InterruptedIOException)3 MessageFormat (java.text.MessageFormat)3 ManifoldCFException (org.apache.manifoldcf.core.interfaces.ManifoldCFException)3 ParseException (org.json.simple.parser.ParseException)3 ArrayList (java.util.ArrayList)2 DateFormat (java.text.DateFormat)1 Date (java.util.Date)1 Goods (model.Goods)1 Type (model.Type)1 RepositoryDocument (org.apache.manifoldcf.agents.interfaces.RepositoryDocument)1 Attachment (org.apache.manifoldcf.crawler.connectors.confluence.v6.model.Attachment)1 Restrictions (org.apache.manifoldcf.crawler.connectors.confluence.v6.model.Restrictions)1 ReadRestrictions (org.apache.manifoldcf.crawler.connectors.confluence.v6.model.Restrictions.ReadRestrictions)1