Package org.javlo.helper
Class MacroHelper
- java.lang.Object
-
- org.javlo.helper.MacroHelper
-
public class MacroHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringALPHABETstatic intCALENDAR_LONGstatic intCALENDAR_SHORTstatic StringMACRO_DATE_KEY
-
Constructor Summary
Constructors Constructor Description MacroHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String value, boolean inList, User authors)static StringaddContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String renderer, String value, User authors)add content to a pagestatic StringaddContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String value, User authors, String renderer, String colStyle, int colSize)add content to a pagestatic StringaddContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String value, User authors)static StringaddContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String value, User authors, String renderer, String colStyle, int colSize)add content to a pagestatic StringaddContent(String lg, MenuElement page, String parentCompId, String contentType, String value, User authors)static StringaddContent(String lg, MenuElement page, String parentCompId, String contentType, String value, User authors, String renderer, String colStyle, int colSize)add content to a pagestatic StringaddContentIfNotExist(ContentContext ctx, MenuElement page, String parentCompId, String contentType, String value)add content to a pagestatic StringaddContentIfNotExist(ContentContext ctx, MenuElement page, String parentCompId, String contentType, String value, String style)add content to a pagestatic voidaddContentInPage(ContentContext ctx, MenuElement newPage, String pageStructureName)static voidaddContentInPage(ContentContext ctx, MenuElement newPage, String pageStructureName, Date date, Collection<String> tags)static MenuElementaddPage(ContentContext ctx, String parentName, String pagePrefix, boolean top)insert a page in the navigation.static MenuElementaddPage(ContentContext ctx, MenuElement parentPage, String pageName, boolean top, boolean store)static MenuElementaddPageIfNotExist(ContentContext ctx, String parentName, String pageName, boolean top)insert a page in the navigation if she does'nt exist.static MenuElementaddPageIfNotExist(ContentContext ctx, MenuElement parentPage, String pageName, boolean top, boolean store)static MenuElementaddPageIfNotExistWithoutMessage(ContentContext ctx, MenuElement parentPage, String pageName, boolean top)insert a page in the navigation if she does'nt exist.static MenuElementaddPageIfNotExistWithoutMessage(ContentContext ctx, MenuElement parentPage, MenuElement subPage, boolean top, boolean store)insert the page in the navigation if she does not exist and add not existing parent page too.static StringcopyChildren(ContentContext ctx, MenuElement source, MenuElement target, String sourcePattern, String targetPattern)static voidcopyLanguageStructure(MenuElement currentPage, ContentContext ctx, List<ContentContext> otherLanguageContexts, boolean withContent, boolean translate)Copy all component in the current language to the otherLanguageContexts BUT with an empty value.static voidcopyLocalContent(MenuElement fromPage, ContentContext fromCtx, MenuElement toPage, ContentContext toCtx)Copy the local content of the current language totoPage.static voidcreateAlphabeticChildren(ContentContext ctx, MenuElement parentPage)static MenuElementcreateArticlePage(ContentContext ctx, MenuElement rootPage, Date date)static MenuElementcreateArticlePageName(ContentContext ctx, MenuElement parentPage)static voidcreateMonthStructure(ContentContext ctx, MenuElement yearPage)static voidcreatePageStructure(ContentContext ctx, MenuElement page, Map componentsType, boolean fakeContent)static voidcreatePageStructure(ContentContext ctx, MenuElement page, Map componentsType, boolean fakeContent, Date date, Collection<String> tags)static MenuElementcreatePathIfNotExist(ContentContext ctx, String path)create all pages of a path or return the existing page.static voiddeleteContentByLanguage(ContentContext ctx, MenuElement page, String lg)static voiddeleteLocalContent(MenuElement currentPage, ContentContext ctx)Delete local content of the current language for the page specified.static MenuElementduplicatePage(ContentContext ctx, MenuElement page, String newname, boolean mirror)static StringgetAlphabeticChildrenName(MenuElement parentPage, Character letter)static DategetCurrentMacroDate(javax.servlet.http.HttpSession session)static StringgetDisplayName(Calendar cal, int field, int style, Locale locale)code from JDK 1.7 for compatibility to for JDK < 1.6static StringgetLaunchMacroXHTML(ContentContext ctx, String macro, String label, String css)static StringgetMonthPageName(ContentContext ctx, String yearPageName, Date date)static StringgetXHTMLMacroSelection(ContentContext ctx)static StringgetXHTMLMacroSelection(ContentContext ctx, boolean adminMode, boolean preview)static voidinsertContent(ContentContext ctx, MenuElement page, String content)add content to a page.static booleanisMacro(ContentContext ctx)static voidmain(String[] args)static booleanremoveContent(ContentContext ctx, String id)static List<MenuElement>searchArticleRoot(ContentContext ctx)return a list of page with only year as children.static List<MenuElement>searchPageWidthLayout(ContentContext ctx)return a list of page with only year as children.static voidsetCurrentMacroDate(javax.servlet.http.HttpSession session, Date date)
-
-
-
Field Detail
-
ALPHABET
public static final String ALPHABET
- See Also:
- Constant Field Values
-
MACRO_DATE_KEY
public static String MACRO_DATE_KEY
-
CALENDAR_SHORT
public static final int CALENDAR_SHORT
- See Also:
- Constant Field Values
-
CALENDAR_LONG
public static final int CALENDAR_LONG
- See Also:
- Constant Field Values
-
-
Method Detail
-
addContent
public static final String addContent(String lg, MenuElement page, String parentCompId, String contentType, String value, User authors, String renderer, String colStyle, int colSize) throws Exception
add content to a page- Parameters:
ctx- the current content contextpage- the page when the content must be inseredparentComp- the parent componentcontentType- the type of the componentvalue- the value of the component- Returns:
- the if of the new component
- Throws:
Exception
-
addContent
public static final String addContent(String lg, MenuElement page, String parentCompId, String contentType, String value, User authors) throws Exception
- Throws:
Exception
-
addContent
public static final String addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String value, User authors, String renderer, String colStyle, int colSize) throws Exception
add content to a page- Parameters:
page- the page when the content must be inseredparentCompId- the parent component idcontentType- the type of the componentstyle- the style of the componentvalue- the value of the component- Returns:
- the if of the new component
- Throws:
Exception
-
addContent
public static final String addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String value, User authors) throws Exception
- Throws:
Exception
-
addContent
public static final String addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String value, User authors, String renderer, String colStyle, int colSize) throws Exception
add content to a page- Parameters:
lg-page- the page when the content must be inseredparentCompId- the parent component idcontentType- the type of the componentstyle- the style of the componentarea- the area of the componentvalue- the value of the component- Returns:
- the if of the new component
- Throws:
Exception
-
addContent
public static final String addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String renderer, String value, User authors) throws Exception
add content to a page- Parameters:
lg-page- the page when the content must be inseredparentCompId- the parent component idcontentType- the type of the componentstyle- the style of the componentrenderer- the renderer selection of the componentarea- the area of the componentvalue- the value of the component- Returns:
- the if of the new component
- Throws:
Exception
-
addContent
public static final String addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String value, boolean inList, User authors) throws Exception
- Throws:
Exception
-
addContentIfNotExist
public static final String addContentIfNotExist(ContentContext ctx, MenuElement page, String parentCompId, String contentType, String value) throws Exception
add content to a page- Parameters:
ctx- the current content contextpage- the page when the content must be inseredparentComp- the parent componentcontentType- the type of the componentvalue- the value of the component- Returns:
- the if of the new component
- Throws:
Exception
-
addContentIfNotExist
public static final String addContentIfNotExist(ContentContext ctx, MenuElement page, String parentCompId, String contentType, String value, String style) throws Exception
add content to a page- Parameters:
ctx- the current content contextpage- the page when the content must be inseredparentComp- the parent componentcontentType- the type of the componentvalue- the value of the component- Returns:
- the if of the new component
- Throws:
Exception
-
addPage
public static final MenuElement addPage(ContentContext ctx, String parentName, String pagePrefix, boolean top) throws Exception
insert a page in the navigation.- Parameters:
parentName- the name of the parent pagepagePrefix- the prefix of the new page (suffix in the number). sp. : prefix : news- page name : news-12- Returns:
- the new page
- Throws:
Exception
-
addPageIfNotExist
public static final MenuElement addPageIfNotExist(ContentContext ctx, MenuElement parentPage, String pageName, boolean top, boolean store) throws Exception
- Throws:
Exception
-
addPage
public static final MenuElement addPage(ContentContext ctx, MenuElement parentPage, String pageName, boolean top, boolean store) throws Exception
- Throws:
Exception
-
addPageIfNotExist
public static final MenuElement addPageIfNotExist(ContentContext ctx, String parentName, String pageName, boolean top) throws Exception
insert a page in the navigation if she does'nt exist.- Parameters:
parentName- the name of the parent pagepageName- the name of the new page- Returns:
- the new page of the page with the same name
- Throws:
Exception
-
addPageIfNotExistWithoutMessage
public static final MenuElement addPageIfNotExistWithoutMessage(ContentContext ctx, MenuElement parentPage, MenuElement subPage, boolean top, boolean store) throws Exception
insert the page in the navigation if she does not exist and add not existing parent page too.- Parameters:
ctx-parentPage-subPage-top-- Returns:
- Throws:
Exception
-
addPageIfNotExistWithoutMessage
public static final MenuElement addPageIfNotExistWithoutMessage(ContentContext ctx, MenuElement parentPage, String pageName, boolean top) throws Exception
insert a page in the navigation if she does'nt exist.- Parameters:
parentName- the name of the parent pagepageName- the name of the new page- Returns:
- the new page of the page with the same name
- Throws:
Exception
-
copyLanguageStructure
public static void copyLanguageStructure(MenuElement currentPage, ContentContext ctx, List<ContentContext> otherLanguageContexts, boolean withContent, boolean translate) throws Exception
Copy all component in the current language to the otherLanguageContexts BUT with an empty value.- Parameters:
currentPage-ctx-otherLanguageContexts-- Throws:
Exception
-
copyLocalContent
public static void copyLocalContent(MenuElement fromPage, ContentContext fromCtx, MenuElement toPage, ContentContext toCtx) throws Exception
Copy the local content of the current language totoPage. Create the page or the parent page if they don't exists.- Parameters:
fromPage-fromCtx-toPage-toCtx-- Throws:
Exception
-
createPathIfNotExist
public static MenuElement createPathIfNotExist(ContentContext ctx, String path) throws Exception
create all pages of a path or return the existing page.- Parameters:
ctx- current contentpath- the new path.- Returns:
- a page.
- Throws:
Exception
-
deleteLocalContent
public static void deleteLocalContent(MenuElement currentPage, ContentContext ctx) throws Exception
Delete local content of the current language for the page specified.- Parameters:
currentPage-ctx-- Throws:
Exception
-
removeContent
public static boolean removeContent(ContentContext ctx, String id) throws Exception
- Throws:
Exception
-
getCurrentMacroDate
public static Date getCurrentMacroDate(javax.servlet.http.HttpSession session)
-
getDisplayName
public static String getDisplayName(Calendar cal, int field, int style, Locale locale)
code from JDK 1.7 for compatibility to for JDK < 1.6
-
getXHTMLMacroSelection
public static final String getXHTMLMacroSelection(ContentContext ctx) throws FileNotFoundException, IOException
- Throws:
FileNotFoundExceptionIOException
-
insertContent
public static void insertContent(ContentContext ctx, MenuElement page, String content) throws Exception
add content to a page.- Parameters:
ctx- Current Contextpage- page with new contentcontent- the content formated in a string.
format: [TYPE]:content;[TYPE]:content.
sample : title:first title;subtitle;paragraph:lorem- Throws:
Exception
-
getXHTMLMacroSelection
public static final String getXHTMLMacroSelection(ContentContext ctx, boolean adminMode, boolean preview) throws FileNotFoundException, IOException
- Throws:
FileNotFoundExceptionIOException
-
isMacro
public static final boolean isMacro(ContentContext ctx)
-
setCurrentMacroDate
public static void setCurrentMacroDate(javax.servlet.http.HttpSession session, Date date)
-
createArticlePageName
public static MenuElement createArticlePageName(ContentContext ctx, MenuElement parentPage) throws Exception
- Throws:
Exception
-
searchArticleRoot
public static List<MenuElement> searchArticleRoot(ContentContext ctx) throws Exception
return a list of page with only year as children.- Parameters:
ctx-- Returns:
- Throws:
Exception
-
searchPageWidthLayout
public static List<MenuElement> searchPageWidthLayout(ContentContext ctx) throws Exception
return a list of page with only year as children.- Parameters:
ctx-- Returns:
- Throws:
Exception
-
createPageStructure
public static void createPageStructure(ContentContext ctx, MenuElement page, Map componentsType, boolean fakeContent) throws Exception
- Throws:
Exception
-
createPageStructure
public static void createPageStructure(ContentContext ctx, MenuElement page, Map componentsType, boolean fakeContent, Date date, Collection<String> tags) throws Exception
- Throws:
Exception
-
addContentInPage
public static void addContentInPage(ContentContext ctx, MenuElement newPage, String pageStructureName) throws IOException, Exception
- Throws:
IOExceptionException
-
addContentInPage
public static void addContentInPage(ContentContext ctx, MenuElement newPage, String pageStructureName, Date date, Collection<String> tags) throws IOException, Exception
- Throws:
IOExceptionException
-
getMonthPageName
public static String getMonthPageName(ContentContext ctx, String yearPageName, Date date)
-
createMonthStructure
public static void createMonthStructure(ContentContext ctx, MenuElement yearPage) throws Exception
- Throws:
Exception
-
createArticlePage
public static MenuElement createArticlePage(ContentContext ctx, MenuElement rootPage, Date date) throws IOException, Exception
- Throws:
IOExceptionException
-
getAlphabeticChildrenName
public static String getAlphabeticChildrenName(MenuElement parentPage, Character letter)
-
createAlphabeticChildren
public static void createAlphabeticChildren(ContentContext ctx, MenuElement parentPage) throws Exception
- Throws:
Exception
-
deleteContentByLanguage
public static void deleteContentByLanguage(ContentContext ctx, MenuElement page, String lg)
-
getLaunchMacroXHTML
public static String getLaunchMacroXHTML(ContentContext ctx, String macro, String label, String css)
-
duplicatePage
public static MenuElement duplicatePage(ContentContext ctx, MenuElement page, String newname, boolean mirror) throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
copyChildren
public static String copyChildren(ContentContext ctx, MenuElement source, MenuElement target, String sourcePattern, String targetPattern) throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
main
public static void main(String[] args)
-
-