CCM NG/ccm-cms: AssetSearchService including JAX-RS methods to support assets in RichTextEditor
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4670 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: 3227166333
pull/2/head
parent
8d54a8ffcb
commit
95531ee989
|
|
@ -1,6 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
|
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
|
||||||
bean-discovery-mode="annotated">
|
bean-discovery-mode="all">
|
||||||
</beans>
|
</beans>
|
||||||
|
|
@ -27,6 +27,15 @@
|
||||||
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
|
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
|
<!-- JAX-RS -->
|
||||||
|
<!--<servlet>
|
||||||
|
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||||
|
<url-pattern>/content-sections/*</url-pattern>
|
||||||
|
</servlet-mapping>-->
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>Faces Servlet</servlet-name>
|
<servlet-name>Faces Servlet</servlet-name>
|
||||||
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
|
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
|
||||||
|
|
@ -46,4 +55,19 @@
|
||||||
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
|
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
|
||||||
<param-value>true</param-value>
|
<param-value>true</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>vaadin-servlet</servlet-name>
|
||||||
|
<servlet-class>com.vaadin.cdi.server.VaadinCDIServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>vaadin-servlet</servlet-name>
|
||||||
|
<url-pattern>/vaadin/</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>vaadin-servlet</servlet-name>
|
||||||
|
<url-pattern>/VAADIN/</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,34 @@
|
||||||
<artifactId>log4j-api</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Vaadin dependencies for Vaadin prototype -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-server</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-shared</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-themes</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-themes</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-client-compiled</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-cdi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<reporting>
|
<reporting>
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,19 @@ import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.form.Submit;
|
import com.arsdigita.bebop.form.Submit;
|
||||||
import com.arsdigita.bebop.form.TextField;
|
import com.arsdigita.bebop.form.TextField;
|
||||||
import com.arsdigita.bebop.parameters.LongParameter;
|
import com.arsdigita.bebop.parameters.LongParameter;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
import com.arsdigita.cms.dispatcher.CMSPage;
|
import com.arsdigita.cms.dispatcher.CMSPage;
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||||
|
|
||||||
import org.librecms.CmsConstants;
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,6 +50,10 @@ public class AssetSearchPage extends CMSPage {
|
||||||
private static final String WIDGET_PARAM = "widget";
|
private static final String WIDGET_PARAM = "widget";
|
||||||
private static final String ASSET_TYPE_PARAM = "assettype";
|
private static final String ASSET_TYPE_PARAM = "assettype";
|
||||||
|
|
||||||
|
private static final int RESULTS_TABLE_COL_TITLE = 0;
|
||||||
|
private static final int RESULTS_TABLE_COL_PLACE = 1;
|
||||||
|
private static final int RESULTS_TABLE_COL_TYPE = 2;
|
||||||
|
|
||||||
private final LongParameter contentSectionId;
|
private final LongParameter contentSectionId;
|
||||||
|
|
||||||
private TextField query;
|
private TextField query;
|
||||||
|
|
@ -65,18 +73,19 @@ public class AssetSearchPage extends CMSPage {
|
||||||
|
|
||||||
final Form queryForm = new Form("asset-search-page-query-form");
|
final Form queryForm = new Form("asset-search-page-query-form");
|
||||||
queryForm.add(new Label(new GlobalizedMessage(
|
queryForm.add(new Label(new GlobalizedMessage(
|
||||||
"cms.ui.assets.search_page.query",
|
"cms.ui.assets.search_page.query",
|
||||||
CmsConstants.CMS_BUNDLE)));
|
CmsConstants.CMS_BUNDLE)));
|
||||||
query = new TextField("asset-search-page-query-form");
|
query = new TextField("asset-search-page-query-form");
|
||||||
queryForm.add(query);
|
queryForm.add(query);
|
||||||
final Submit querySubmit = new Submit(new GlobalizedMessage(
|
final Submit querySubmit = new Submit(new GlobalizedMessage(
|
||||||
"cms.ui.assets.search_page.query.submit"));
|
"cms.ui.assets.search_page.query.submit"));
|
||||||
queryForm.add(querySubmit);
|
queryForm.add(querySubmit);
|
||||||
|
|
||||||
queryForm.addInitListener(new FormInitListener() {
|
queryForm.addInitListener(new FormInitListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final FormSectionEvent event)
|
public void init(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
final FormData data = event.getFormData();
|
final FormData data = event.getFormData();
|
||||||
|
|
@ -84,8 +93,39 @@ public class AssetSearchPage extends CMSPage {
|
||||||
final String query = (String) data.get(QUERY_PARAM);
|
final String query = (String) data.get(QUERY_PARAM);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainPanel.setLeft(queryForm);
|
||||||
|
|
||||||
|
final Table resultsTable = new Table();
|
||||||
|
resultsTable.setEmptyView(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.search_page.none",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
resultsTable.setClassAttr("dataTable");
|
||||||
|
|
||||||
|
final TableColumnModel columnModel = resultsTable.getColumnModel();
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
RESULTS_TABLE_COL_TITLE,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.search_page.results_table.title",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
RESULTS_TABLE_COL_PLACE,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.search_page.results_table.place",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
RESULTS_TABLE_COL_TYPE,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.search_page.results_table.type",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
|
||||||
|
|
||||||
|
mainPanel.setBody(resultsTable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,321 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.assets;
|
||||||
|
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.librecms.contentsection.Asset;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
|
||||||
|
import org.librecms.contentsection.ContentSection;
|
||||||
|
import org.librecms.contentsection.ContentSectionRepository;
|
||||||
|
import org.librecms.contentsection.Folder;
|
||||||
|
import org.librecms.contentsection.FolderRepository;
|
||||||
|
import org.librecms.contentsection.FolderType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Path("/{content-section}/assets")
|
||||||
|
public class AssetSearchService {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetTypesManager assetTypesManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ContentSectionRepository sectionRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private FolderRepository folderRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
private Class<? extends Asset> toAssetClass(final String type) {
|
||||||
|
final Class<?> clazz;
|
||||||
|
try {
|
||||||
|
clazz = Class.forName(type);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Type '%s' is not a valid class.",
|
||||||
|
type));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clazz.isAssignableFrom(Asset.class)) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Class<? extends Asset> typeClass
|
||||||
|
= (Class<? extends Asset>) clazz;
|
||||||
|
return typeClass;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Type '%s is not a subclass of '%s'.",
|
||||||
|
type,
|
||||||
|
Asset.class.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Asset> findAssetsByQuery(final String query) {
|
||||||
|
return assetRepo.findByTitle(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Asset> findAssetsByType(final String type) {
|
||||||
|
return AssetSearchService.this.findAssets(toAssetClass(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Asset> findAssets(final Class<? extends Asset> type) {
|
||||||
|
return assetRepo.findByType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Asset> findAssets(final String query, final String type) {
|
||||||
|
|
||||||
|
final Class<?> clazz;
|
||||||
|
try {
|
||||||
|
clazz = Class.forName(type);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Type '%s' is not a valid class.",
|
||||||
|
type));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clazz.isAssignableFrom(Asset.class)) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Class<? extends Asset> typeClass
|
||||||
|
= (Class<? extends Asset>) clazz;
|
||||||
|
return AssetSearchService.this.findAssets(query, typeClass);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Type '%s is not a subclass of '%s'.",
|
||||||
|
type,
|
||||||
|
Asset.class.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Asset> findAssets(final ContentSection section,
|
||||||
|
final String path) {
|
||||||
|
final Optional<Folder> folder = folderRepo
|
||||||
|
.findByPath(section,
|
||||||
|
path,
|
||||||
|
FolderType.ASSETS_FOLDER);
|
||||||
|
|
||||||
|
if (!folder.isPresent()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return assetRepo.findByFolder(folder.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Asset> findAssets(final String query,
|
||||||
|
final Class<? extends Asset> type) {
|
||||||
|
return assetRepo.findByTitleAndType(query, type);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public List<Asset> findAssetsByType(final ContentSection section,
|
||||||
|
final String path,
|
||||||
|
final String type) {
|
||||||
|
|
||||||
|
final Optional<Folder> folder = folderRepo
|
||||||
|
.findByPath(section,
|
||||||
|
path,
|
||||||
|
FolderType.ASSETS_FOLDER);
|
||||||
|
|
||||||
|
if (!folder.isPresent()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return assetRepo.filterByFolderAndType(folder.get(),
|
||||||
|
toAssetClass(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public List<Asset> findAssetsByQuery(final ContentSection section,
|
||||||
|
final String path,
|
||||||
|
final String query) {
|
||||||
|
|
||||||
|
final Optional<Folder> folder = folderRepo
|
||||||
|
.findByPath(section,
|
||||||
|
path,
|
||||||
|
FolderType.ASSETS_FOLDER);
|
||||||
|
|
||||||
|
if (!folder.isPresent()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return assetRepo.filterByFolderAndTitle(folder.get(),
|
||||||
|
query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public List<Asset> findAssets(final ContentSection section,
|
||||||
|
final String path,
|
||||||
|
final String query,
|
||||||
|
final String type) {
|
||||||
|
|
||||||
|
final Optional<Folder> folder = folderRepo
|
||||||
|
.findByPath(section,
|
||||||
|
path,
|
||||||
|
FolderType.ASSETS_FOLDER);
|
||||||
|
|
||||||
|
if (!folder.isPresent()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return assetRepo.filterByFolderAndTypeAndTitle(folder.get(),
|
||||||
|
toAssetClass(type),
|
||||||
|
query);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces("text/json")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public List<Map<String, String>> findAssets(
|
||||||
|
@PathParam("content-section") final String section,
|
||||||
|
@QueryParam("query") final String query,
|
||||||
|
@QueryParam("type") final String type) {
|
||||||
|
|
||||||
|
return findAssets(section, "/", query, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{folder}")
|
||||||
|
@Produces("text/json")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public List<Map<String, String>> findAssets(
|
||||||
|
@PathParam("content-section") final String section,
|
||||||
|
@PathParam("folder") final String path,
|
||||||
|
@QueryParam("query") final String query,
|
||||||
|
@QueryParam("type") final String type) {
|
||||||
|
|
||||||
|
final ContentSection contentSection = sectionRepo.findByLabel(section);
|
||||||
|
|
||||||
|
final String folderPath;
|
||||||
|
if (path == null || path.trim().isEmpty() || "/".equals(path.trim())) {
|
||||||
|
folderPath = "/";
|
||||||
|
} else {
|
||||||
|
folderPath = String.format("/%s", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String assetType;
|
||||||
|
if (type == null || type.trim().isEmpty()) {
|
||||||
|
assetType = Asset.class.getName();
|
||||||
|
} else {
|
||||||
|
assetType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Optional<Folder> folder = folderRepo
|
||||||
|
.findByPath(contentSection, folderPath, FolderType.ASSETS_FOLDER);
|
||||||
|
if (!folder.isPresent()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
final List<Map<String, String>> subFolders = folder
|
||||||
|
.get()
|
||||||
|
.getSubFolders()
|
||||||
|
.stream()
|
||||||
|
.map(current -> createAssetMapEntry(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
final List<Asset> assets;
|
||||||
|
if (query == null || query.trim().isEmpty()) {
|
||||||
|
if (Asset.class.getName().equals(assetType)) {
|
||||||
|
assets = findAssets(contentSection, folderPath);
|
||||||
|
} else {
|
||||||
|
assets = findAssetsByType(contentSection, folderPath, assetType);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Asset.class.getName().equals(assetType)) {
|
||||||
|
assets = findAssetsByQuery(contentSection, folderPath, query);
|
||||||
|
} else {
|
||||||
|
assets
|
||||||
|
= findAssets(contentSection, folderPath, query, assetType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Map<String, String>> assetEntries = assets
|
||||||
|
.stream()
|
||||||
|
.map(asset -> createAssetMapEntry(asset))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
final List<Map<String, String>> result = new ArrayList<>();
|
||||||
|
result.addAll(subFolders);
|
||||||
|
result.addAll(assetEntries);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> createAssetMapEntry(final Folder folder) {
|
||||||
|
final Map<String, String> result = new HashMap<>();
|
||||||
|
|
||||||
|
result.put("title",
|
||||||
|
folder
|
||||||
|
.getTitle()
|
||||||
|
.getValue(KernelConfig.getConfig().getDefaultLocale()));
|
||||||
|
result.put("type",
|
||||||
|
Folder.class.getName());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> createAssetMapEntry(final Asset asset) {
|
||||||
|
final Map<String, String> result = new HashMap<>();
|
||||||
|
|
||||||
|
result.put("title",
|
||||||
|
asset.getTitle().getValue(globalizationHelper
|
||||||
|
.getNegotiatedLocale()));
|
||||||
|
|
||||||
|
result.put("type",
|
||||||
|
asset.getClass().getName());
|
||||||
|
|
||||||
|
final AssetTypeInfo typeInfo = assetTypesManager
|
||||||
|
.getAssetTypeInfo(asset.getClass());
|
||||||
|
final ResourceBundle bundle = ResourceBundle
|
||||||
|
.getBundle(typeInfo.getLabelBundle(),
|
||||||
|
globalizationHelper.getNegotiatedLocale());
|
||||||
|
result.put("typeLabel", bundle.getString(typeInfo.getLabelKey()));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -68,6 +68,15 @@ import static org.librecms.CmsConstants.*;
|
||||||
+ "WHERE a.uuid = :uuid "
|
+ "WHERE a.uuid = :uuid "
|
||||||
+ "AND TYPE(a) = :type")
|
+ "AND TYPE(a) = :type")
|
||||||
,
|
,
|
||||||
|
@NamedQuery(name = "Asset.findByTitle'",
|
||||||
|
query = "SELECT a FROM Asset a JOIN a.title.values t "
|
||||||
|
+ "WHERE t LIKE :query")
|
||||||
|
,
|
||||||
|
@NamedQuery(name = "Asset.findByTitleAndType",
|
||||||
|
query = "SELECT a FROM Asset a "
|
||||||
|
+ "WHERE :title MEMBER OF a.title.values "
|
||||||
|
+ "AND TYPE(a) = :type")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Asset.findByFolder",
|
name = "Asset.findByFolder",
|
||||||
query = "SELECT a FROM Asset a "
|
query = "SELECT a FROM Asset a "
|
||||||
|
|
@ -83,20 +92,22 @@ import static org.librecms.CmsConstants.*;
|
||||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "'")
|
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "'")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Asset.filterByFolderAndName",
|
name = "Asset.filterByFolderAndTitle",
|
||||||
query = "SELECT a FROM Asset a "
|
query = "SELECT a FROM Asset a "
|
||||||
+ "JOIN a.categories c "
|
+ "JOIN a.categories c "
|
||||||
|
+ "JOIN a.title.values t "
|
||||||
+ "WHERE c.category = :folder "
|
+ "WHERE c.category = :folder "
|
||||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||||
+ "AND LOWER(a.displayName) LIKE CONCAT(LOWER(:name), '%')")
|
+ "AND LOWER(t) LIKE CONCAT('%', LOWER(:title), '%')")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Asset.countFilterByFolderAndName",
|
name = "Asset.countFilterByFolderAndTitle",
|
||||||
query = "SELECT COUNT(a) FROM Asset a "
|
query = "SELECT COUNT(a) FROM Asset a "
|
||||||
+ "JOIN a.categories c "
|
+ "JOIN a.categories c "
|
||||||
|
+ "JOIN a.title.values t "
|
||||||
+ "WHERE c.category = :folder "
|
+ "WHERE c.category = :folder "
|
||||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||||
+ "AND LOWER(a.displayName) LIKE CONCAT(LOWER(:name), '%')")
|
+ "AND LOWER(t) LIKE CONCAT('%', LOWER(:title), '%')")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Asset.filterByFolderAndType",
|
name = "Asset.filterByFolderAndType",
|
||||||
|
|
@ -124,12 +135,13 @@ import static org.librecms.CmsConstants.*;
|
||||||
+ "AND TYPE(a) = :type")
|
+ "AND TYPE(a) = :type")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Asset.countFilterByFolderAndNameAndType",
|
name = "Asset.countFilterByFolderAndTitleAndType",
|
||||||
query = "SELECT COUNT(a) FROM Asset a "
|
query = "SELECT COUNT(a) FROM Asset a "
|
||||||
+ "JOIN a.categories c "
|
+ "JOIN a.categories c "
|
||||||
|
+ "JOIN a.title.values t "
|
||||||
+ "WHERE c.category = :folder "
|
+ "WHERE c.category = :folder "
|
||||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||||
+ "AND LOWER(a.displayName) LIKE CONCAT(LOWER(:name), '%') "
|
+ "AND LOWER(t) LIKE CONCAT('%', LOWER(:title), '%') "
|
||||||
+ "AND TYPE(a) = :type")
|
+ "AND TYPE(a) = :type")
|
||||||
})
|
})
|
||||||
public class Asset extends CcmObject {
|
public class Asset extends CcmObject {
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,16 @@ public class AssetRepository
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public List<Asset> findByTitle(final String title) {
|
||||||
|
|
||||||
|
final TypedQuery<Asset> query = entityManager.createNamedQuery(
|
||||||
|
"Asset.findByTitle", Asset.class);
|
||||||
|
query.setParameter("query", String.format("%%%s%%", title));
|
||||||
|
|
||||||
|
return query.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all shared {@link Asset}s of the specified type.
|
* Finds all shared {@link Asset}s of the specified type.
|
||||||
*
|
*
|
||||||
|
|
@ -208,6 +218,18 @@ public class AssetRepository
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public List<Asset> findByTitleAndType(final String title,
|
||||||
|
final Class<? extends Asset> type) {
|
||||||
|
|
||||||
|
final TypedQuery<Asset> query = entityManager.createNamedQuery(
|
||||||
|
"Asset.findByTitle", Asset.class);
|
||||||
|
query.setParameter("query", title);
|
||||||
|
query.setParameter("type", type);
|
||||||
|
|
||||||
|
return query.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all shared {@link Asset}s in a specific {@link Folder}.
|
* Finds all shared {@link Asset}s in a specific {@link Folder}.
|
||||||
*
|
*
|
||||||
|
|
@ -246,19 +268,19 @@ public class AssetRepository
|
||||||
*
|
*
|
||||||
* @param folder The {@link Folder} which {@link Asset}s are filtered using
|
* @param folder The {@link Folder} which {@link Asset}s are filtered using
|
||||||
* the provided {@code name}.
|
* the provided {@code name}.
|
||||||
* @param name The string used to fiter the {@link Assets} in the provided
|
* @param title The string used to fiter the {@link Assets} in the provided
|
||||||
* {@code folder}.
|
* {@code folder}.
|
||||||
*
|
*
|
||||||
* @return A list with all {@link Asset}s in the provided {@link Folder}
|
* @return A list with all {@link Asset}s in the provided {@link Folder}
|
||||||
* which name starts with the provided string.
|
* which name starts with the provided string.
|
||||||
*/
|
*/
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public List<Asset> filterByFolderAndName(final Folder folder,
|
public List<Asset> filterByFolderAndTitle(final Folder folder,
|
||||||
final String name) {
|
final String title) {
|
||||||
final TypedQuery<Asset> query = entityManager.createNamedQuery(
|
final TypedQuery<Asset> query = entityManager.createNamedQuery(
|
||||||
"Asset.filterByFolderAndName", Asset.class);
|
"Asset.filterByFolderAndTitle", Asset.class);
|
||||||
query.setParameter("folder", folder);
|
query.setParameter("folder", folder);
|
||||||
query.setParameter("name", name);
|
query.setParameter("title", title);
|
||||||
|
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
@ -334,22 +356,22 @@ public class AssetRepository
|
||||||
*
|
*
|
||||||
* @param folder The {@link Folder} which contains the assets.
|
* @param folder The {@link Folder} which contains the assets.
|
||||||
* @param type The type of the {@link Asset}s.
|
* @param type The type of the {@link Asset}s.
|
||||||
* @param name The name to filter the {@link Asset}s for.
|
* @param title The name to filter the {@link Asset}s for.
|
||||||
*
|
*
|
||||||
* @return A list of all {@link Asset}s of the provided type which name
|
* @return A list of all {@link Asset}s of the provided type which name
|
||||||
* starts with the provided string in the provided folder.
|
* starts with the provided string in the provided folder.
|
||||||
*/
|
*/
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public List<Asset> filterByFolderAndTypeAndName(
|
public List<Asset> filterByFolderAndTypeAndTitle(
|
||||||
final Folder folder,
|
final Folder folder,
|
||||||
final Class<? extends Asset> type,
|
final Class<? extends Asset> type,
|
||||||
final String name) {
|
final String title) {
|
||||||
|
|
||||||
final TypedQuery<Asset> query = entityManager.createNamedQuery(
|
final TypedQuery<Asset> query = entityManager.createNamedQuery(
|
||||||
"Asset.filterByFolderAndNameAndType", Asset.class);
|
"Asset.filterByFolderAndTitleAndType", Asset.class);
|
||||||
query.setParameter("folder", folder);
|
query.setParameter("folder", folder);
|
||||||
query.setParameter("type", type);
|
query.setParameter("type", type);
|
||||||
query.setParameter("name", name);
|
query.setParameter("title", title);
|
||||||
|
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
@ -360,22 +382,22 @@ public class AssetRepository
|
||||||
*
|
*
|
||||||
* @param folder The {@link Folder} which contains the assets.
|
* @param folder The {@link Folder} which contains the assets.
|
||||||
* @param type The type of the {@link Asset}s.
|
* @param type The type of the {@link Asset}s.
|
||||||
* @param name The name to filter the {@link Asset}s for.
|
* @param title The name to filter the {@link Asset}s for.
|
||||||
*
|
*
|
||||||
* @return The number of {@link Asset}s of the provided type which name
|
* @return The number of {@link Asset}s of the provided type which name
|
||||||
* starts with the provided string in the provided folder.
|
* starts with the provided string in the provided folder.
|
||||||
*/
|
*/
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public long countFilterByFolderAndTypeAndName(
|
public long countFilterByFolderAndTypeAndTitle(
|
||||||
final Folder folder,
|
final Folder folder,
|
||||||
final Class<? extends Asset> type,
|
final Class<? extends Asset> type,
|
||||||
final String name) {
|
final String title) {
|
||||||
|
|
||||||
final TypedQuery<Long> query = entityManager.createNamedQuery(
|
final TypedQuery<Long> query = entityManager.createNamedQuery(
|
||||||
"Asset.countFilterByFolderAndNameAndType", Long.class);
|
"Asset.countFilterByFolderAndTitleAndType", Long.class);
|
||||||
query.setParameter("folder", folder);
|
query.setParameter("folder", folder);
|
||||||
query.setParameter("type", type);
|
query.setParameter("type", type);
|
||||||
query.setParameter("name", name);
|
query.setParameter("title", title);
|
||||||
|
|
||||||
return query.getSingleResult();
|
return query.getSingleResult();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import org.libreccm.security.RequiresPrivilege;
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -117,12 +118,12 @@ public class FolderRepository extends AbstractEntityRepository<Long, Folder> {
|
||||||
public Optional<Folder> findByPath(final ContentSection section,
|
public Optional<Folder> findByPath(final ContentSection section,
|
||||||
final String path,
|
final String path,
|
||||||
final FolderType type) {
|
final FolderType type) {
|
||||||
if (section == null) {
|
|
||||||
throw new IllegalArgumentException("section can't be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == null || path.isEmpty()) {
|
Objects.requireNonNull(section, "section can't be null");
|
||||||
throw new IllegalArgumentException("Path can't be null or empty.");
|
|
||||||
|
Objects.requireNonNull(path, "Path can't be null.");
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Path can't be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// String normalizedPath = path.replace('.', '/');
|
// String normalizedPath = path.replace('.', '/');
|
||||||
|
|
@ -135,46 +136,45 @@ public class FolderRepository extends AbstractEntityRepository<Long, Folder> {
|
||||||
// normalizedPath.length());
|
// normalizedPath.length());
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
final ContentSection contentSection = sectionRepo
|
||||||
|
.findById(section.getObjectId())
|
||||||
|
.get();
|
||||||
|
|
||||||
final String normalizedPath = PathUtil.normalizePath(path);
|
final String normalizedPath = PathUtil.normalizePath(path);
|
||||||
|
|
||||||
LOGGER.debug("Trying to find folder with path \"{}\" and type {} in"
|
LOGGER.debug("Trying to find folder with path \"{}\" and type {} in"
|
||||||
+ "content section \"{}\".",
|
+ "content section \"{}\".",
|
||||||
normalizedPath,
|
normalizedPath,
|
||||||
type,
|
type,
|
||||||
section.getLabel());
|
contentSection.getLabel());
|
||||||
final String[] tokens = normalizedPath.split("/");
|
final String[] tokens = normalizedPath.split("/");
|
||||||
Folder current;
|
Folder current;
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case ASSETS_FOLDER:
|
case ASSETS_FOLDER:
|
||||||
current = section.getRootAssetsFolder();
|
current = contentSection.getRootAssetsFolder();
|
||||||
break;
|
break;
|
||||||
case DOCUMENTS_FOLDER:
|
case DOCUMENTS_FOLDER:
|
||||||
current = section.getRootDocumentsFolder();
|
current = contentSection.getRootDocumentsFolder();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(String.format(
|
throw new IllegalArgumentException(String.format(
|
||||||
"Unexpected folder type %s", type));
|
"Unexpected folder type %s", type));
|
||||||
}
|
}
|
||||||
for(final String token : tokens) {
|
if (normalizedPath.isEmpty()) {
|
||||||
|
return Optional.of(current);
|
||||||
|
}
|
||||||
|
for (final String token : tokens) {
|
||||||
if (current.getSubCategories() == null) {
|
if (current.getSubCategories() == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Optional<Category> result = current.getSubCategories()
|
final Optional<Category> result = current.getSubCategories()
|
||||||
.stream()
|
.stream()
|
||||||
.filter( c -> {
|
.filter(category -> category.getName().equals(token))
|
||||||
LOGGER.debug("#findByPath(ContentSection, String, FolderType: c = {}",
|
.findFirst();
|
||||||
c.toString());
|
|
||||||
LOGGER.debug("#findByPath(ContentSection, String, FolderType: c.getName = \"{}\"",
|
|
||||||
c.getName());
|
|
||||||
LOGGER.debug("#findByPath(ContentSection, String, FolderType: token = \"{}\"",
|
|
||||||
token);
|
|
||||||
return c.getName().equals(token);
|
|
||||||
})
|
|
||||||
.findFirst();
|
|
||||||
|
|
||||||
if (result.isPresent()
|
if (result.isPresent()
|
||||||
&& result.get() instanceof Folder) {
|
&& result.get() instanceof Folder) {
|
||||||
current = (Folder) result.get();
|
current = (Folder) result.get();
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import org.librecms.assets.AssetSearchService;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ws.rs.ApplicationPath;
|
||||||
|
import javax.ws.rs.core.Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@ApplicationPath("/content-sections")
|
||||||
|
public class JaxRsContentSections extends Application{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Class<?>> getClasses() {
|
||||||
|
final Set<Class<?>> classes = new HashSet<>();
|
||||||
|
|
||||||
|
classes.add(AssetSearchService.class);
|
||||||
|
|
||||||
|
return classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -349,7 +349,7 @@ public class AssetRepositoryTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to find {@link Asset}s in a {@link Folder} by using
|
* Tries to find {@link Asset}s in a {@link Folder} by using
|
||||||
* {@link AssetRepository#filterByFolderAndName(org.librecms.contentsection.Folder, java.lang.String)}.
|
* {@link AssetRepository#filterByFolderAndTitle(org.librecms.contentsection.Folder, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@InSequence(500)
|
@InSequence(500)
|
||||||
|
|
@ -358,9 +358,9 @@ public class AssetRepositoryTest {
|
||||||
public void filterAssetByFolderAndName() {
|
public void filterAssetByFolderAndName() {
|
||||||
final Folder media = folderRepo.findById(-400L).get();
|
final Folder media = folderRepo.findById(-400L).get();
|
||||||
|
|
||||||
final List<Asset> result1 = assetRepo.filterByFolderAndName(media,
|
final List<Asset> result1 = assetRepo.filterByFolderAndTitle(media,
|
||||||
"hea");
|
"hea");
|
||||||
final List<Asset> result2 = assetRepo.filterByFolderAndName(media,
|
final List<Asset> result2 = assetRepo.filterByFolderAndTitle(media,
|
||||||
"photo");
|
"photo");
|
||||||
|
|
||||||
assertThat(result1.size(), is(1));
|
assertThat(result1.size(), is(1));
|
||||||
|
|
@ -443,7 +443,7 @@ public class AssetRepositoryTest {
|
||||||
/**
|
/**
|
||||||
* Tries to filter the {@link Asset}s in a {@link Folder} by their type and
|
* Tries to filter the {@link Asset}s in a {@link Folder} by their type and
|
||||||
* name using
|
* name using
|
||||||
* {@link AssetRepository#filterByFolderAndTypeAndName(org.librecms.contentsection.Folder, java.lang.Class, java.lang.String)}.
|
* {@link AssetRepository#filterByFolderAndTypeAndTitle(org.librecms.contentsection.Folder, java.lang.Class, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@InSequence(600)
|
@InSequence(600)
|
||||||
|
|
@ -452,9 +452,9 @@ public class AssetRepositoryTest {
|
||||||
public void filterAssetsByFolderAndTypeAndName() {
|
public void filterAssetsByFolderAndTypeAndName() {
|
||||||
final Folder media = folderRepo.findById(-400L).get();
|
final Folder media = folderRepo.findById(-400L).get();
|
||||||
|
|
||||||
final List<Asset> result1 = assetRepo.filterByFolderAndTypeAndName(
|
final List<Asset> result1 = assetRepo.filterByFolderAndTypeAndTitle(
|
||||||
media, Image.class, "hea");
|
media, Image.class, "hea");
|
||||||
final List<Asset> result2 = assetRepo.filterByFolderAndTypeAndName(
|
final List<Asset> result2 = assetRepo.filterByFolderAndTypeAndTitle(
|
||||||
media, File.class, "hea");
|
media, File.class, "hea");
|
||||||
|
|
||||||
assertThat(result1.size(), is(1));
|
assertThat(result1.size(), is(1));
|
||||||
|
|
@ -465,7 +465,7 @@ public class AssetRepositoryTest {
|
||||||
/**
|
/**
|
||||||
* Tries to count the {@link Asset}s in a {@link Folder} which are of a
|
* Tries to count the {@link Asset}s in a {@link Folder} which are of a
|
||||||
* specific type and which name matches a specific pattern using
|
* specific type and which name matches a specific pattern using
|
||||||
* {@link AssetRepository#filterByFolderAndTypeAndName(org.librecms.contentsection.Folder, java.lang.Class, java.lang.String)}.
|
* {@link AssetRepository#filterByFolderAndTypeAndTitle(org.librecms.contentsection.Folder, java.lang.Class, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@InSequence(610)
|
@InSequence(610)
|
||||||
|
|
@ -474,10 +474,10 @@ public class AssetRepositoryTest {
|
||||||
public void countFilterAssetsByFolderAndTypeAndName() {
|
public void countFilterAssetsByFolderAndTypeAndName() {
|
||||||
final Folder media = folderRepo.findById(-400L).get();
|
final Folder media = folderRepo.findById(-400L).get();
|
||||||
|
|
||||||
assertThat(assetRepo.countFilterByFolderAndTypeAndName(
|
assertThat(assetRepo.countFilterByFolderAndTypeAndTitle(
|
||||||
media, Image.class, "hea"),
|
media, Image.class, "hea"),
|
||||||
is(1L));
|
is(1L));
|
||||||
assertThat(assetRepo.countFilterByFolderAndTypeAndName(
|
assertThat(assetRepo.countFilterByFolderAndTypeAndTitle(
|
||||||
media, File.class, "hea"),
|
media, File.class, "hea"),
|
||||||
is(0L));
|
is(0L));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,35 @@
|
||||||
<artifactId>primefaces</artifactId>
|
<artifactId>primefaces</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Vaadin dependencies for Vaadin prototype -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-server</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-shared</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-themes</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-client-compiled</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-client-compiled</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-cdi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Export Import Libraries -->
|
<!-- Export Import Libraries -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
|
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
|
||||||
bean-discovery-mode="annotated">
|
bean-discovery-mode="all">
|
||||||
|
|
||||||
<interceptors>
|
<interceptors>
|
||||||
<class>org.libreccm.security.AuthorizationInterceptor</class>
|
<class>org.libreccm.security.AuthorizationInterceptor</class>
|
||||||
|
|
|
||||||
22
pom.xml
22
pom.xml
|
|
@ -318,6 +318,28 @@
|
||||||
<version>6.0</version>
|
<version>6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Vaadin dependencies for Vaadin prototype -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-server</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-shared</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-compatibility-themes</artifactId>
|
||||||
|
<version>8.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin</groupId>
|
||||||
|
<artifactId>vaadin-cdi</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
*********************
|
*********************
|
||||||
Libraries used by CCM
|
Libraries used by CCM
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue