Search in sources :

Example 1 with URLHandler

use of org.broadleafcommerce.cms.url.domain.URLHandler in project BroadleafCommerce by BroadleafCommerce.

the class URlHandlerDaoImpl method findAllURLHandlers.

@Override
public List<URLHandler> findAllURLHandlers() {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<URLHandler> criteria = builder.createQuery(URLHandler.class);
    Root<URLHandlerImpl> handler = criteria.from(URLHandlerImpl.class);
    criteria.select(handler);
    TypedQuery<URLHandler> query = em.createQuery(criteria);
    query.setHint(QueryHints.HINT_CACHEABLE, true);
    try {
        return query.getResultList();
    } catch (NoResultException e) {
        return new ArrayList<URLHandler>();
    }
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) URLHandler(org.broadleafcommerce.cms.url.domain.URLHandler) URLHandlerImpl(org.broadleafcommerce.cms.url.domain.URLHandlerImpl) NoResultException(javax.persistence.NoResultException)

Example 2 with URLHandler

use of org.broadleafcommerce.cms.url.domain.URLHandler in project BroadleafCommerce by BroadleafCommerce.

the class URLHandlerServiceTest method testRegExStartsWithSpecialRegExChar.

@Test
public void testRegExStartsWithSpecialRegExChar() {
    URLHandler h = handlerService.checkForMatches("/merchandise/shirts-tops/mens");
    String expectedNewURL = "/merchandise/shirts/mens";
    assertTrue(h != null);
    assertTrue(expectedNewURL.equals(h.getNewURL()));
}
Also used : URLHandler(org.broadleafcommerce.cms.url.domain.URLHandler) Test(org.junit.Test)

Example 3 with URLHandler

use of org.broadleafcommerce.cms.url.domain.URLHandler in project BroadleafCommerce by BroadleafCommerce.

the class URLHandlerServiceTest method createHandler.

protected URLHandler createHandler(String incomingUrl, String newUrl) {
    URLHandler handler = new URLHandlerImpl();
    handler.setIncomingURL(incomingUrl);
    handler.setNewURL(newUrl);
    handler.setUrlRedirectType(URLRedirectType.REDIRECT_PERM);
    return handler;
}
Also used : URLHandler(org.broadleafcommerce.cms.url.domain.URLHandler) URLHandlerImpl(org.broadleafcommerce.cms.url.domain.URLHandlerImpl)

Example 4 with URLHandler

use of org.broadleafcommerce.cms.url.domain.URLHandler in project BroadleafCommerce by BroadleafCommerce.

the class URLHandlerServiceTest method testForSubPackageBadMatchSimpleUrl.

@Test
public void testForSubPackageBadMatchSimpleUrl() {
    URLHandler h = handlerService.checkForMatches("/simple_url/test");
    assertTrue(h == null);
}
Also used : URLHandler(org.broadleafcommerce.cms.url.domain.URLHandler) Test(org.junit.Test)

Example 5 with URLHandler

use of org.broadleafcommerce.cms.url.domain.URLHandler in project BroadleafCommerce by BroadleafCommerce.

the class URLHandlerServiceTest method testFoundSimpleUrl.

@Test
public void testFoundSimpleUrl() {
    URLHandler h = handlerService.checkForMatches("/simple_url");
    assertTrue(h.getNewURL().equals("/NewSimpleUrl"));
}
Also used : URLHandler(org.broadleafcommerce.cms.url.domain.URLHandler) Test(org.junit.Test)

Aggregations

URLHandler (org.broadleafcommerce.cms.url.domain.URLHandler)11 Test (org.junit.Test)6 NullURLHandler (org.broadleafcommerce.cms.url.domain.NullURLHandler)2 URLHandlerDTO (org.broadleafcommerce.cms.url.domain.URLHandlerDTO)2 URLHandlerImpl (org.broadleafcommerce.cms.url.domain.URLHandlerImpl)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 NoResultException (javax.persistence.NoResultException)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Element (net.sf.ehcache.Element)1 Site (org.broadleafcommerce.common.site.domain.Site)1