CCM NG/ccm-cms: Additional methods for the ContentTypesManager for retrieving informations about content types.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4436 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
4390a92891
commit
73ac7e77df
|
|
@ -78,9 +78,6 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
|
|||
*/
|
||||
public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
ContentSectionPage.class);
|
||||
|
||||
/**
|
||||
* The URL parameter that can be passed in in order to set the current
|
||||
* folder. This is used in getting back to the correct level of folder
|
||||
|
|
@ -127,6 +124,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
|||
*/
|
||||
public static final int CONTENTTYPES_TAB = 6;
|
||||
public static final int USER_ADMIN_TAB = 7;
|
||||
|
||||
private TabbedPane m_tabbedPane;
|
||||
private FolderAdminPane m_folderPane;
|
||||
//ToDo NG private BrowsePane m_browsePane;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,11 @@
|
|||
*/
|
||||
package org.librecms.contenttypes;
|
||||
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.libreccm.modules.CcmModule;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
@ -210,11 +213,67 @@ public class ContentTypesManager {
|
|||
|
||||
/**
|
||||
* Retrieves a list of all content types currently available on the system.
|
||||
*
|
||||
*
|
||||
* @return A list of all available content types.
|
||||
*/
|
||||
public List<ContentTypeInfo> getAvailableContentTypes() {
|
||||
return Collections.unmodifiableList(availableContentTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ContentTypeInfo} for a specific type.
|
||||
*
|
||||
* @param contentTypeClass The class representing the content type.
|
||||
*
|
||||
* @return A {@link ContentTypeInfo} describing the content type.
|
||||
*/
|
||||
public ContentTypeInfo getContentTypeInfo(
|
||||
final Class<? extends ContentItem> contentTypeClass) {
|
||||
|
||||
return createContentTypeInfo(contentTypeClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient method for getting the {@link ContentTypeInfo} about a
|
||||
* specific content type.
|
||||
*
|
||||
* @param contentTypeClass The name of the class representing the content
|
||||
* type.
|
||||
*
|
||||
* @return A {@link ContentTypeInfo} describing the content type.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ContentTypeInfo getContentTypeInfo(final String contentTypeClass) {
|
||||
final Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(contentTypeClass);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"There is not class \"%s\".", contentTypeClass),
|
||||
ex);
|
||||
}
|
||||
|
||||
if (!clazz.isAssignableFrom(ContentItem.class)) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Class \"%s\" is not a subclass of \"%s\".",
|
||||
contentTypeClass,
|
||||
ContentItem.class.getName()));
|
||||
}
|
||||
|
||||
return getContentTypeInfo((Class<? extends ContentItem>) clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient method for getting the {@link ContentTypeInfo} about a
|
||||
* specific content type.
|
||||
*
|
||||
* @param contentType The content type (from a content section} representing
|
||||
* the content type.
|
||||
*
|
||||
* @return A {@link ContentTypeInfo} describing the content type.
|
||||
*/
|
||||
public ContentTypeInfo getContentTypeInfo(final ContentType contentType) {
|
||||
return getContentTypeInfo(contentType.getContentItemClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue