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 String
ALPHABET
static int
CALENDAR_LONG
static int
CALENDAR_SHORT
static String
MACRO_DATE_KEY
-
Constructor Summary
Constructors Constructor Description MacroHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String value, boolean inList, User authors)
static String
addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String area, String renderer, String value, User authors)
add content to a pagestatic String
addContent(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 String
addContent(String lg, MenuElement page, String parentCompId, String contentType, String style, String value, User authors)
static String
addContent(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 String
addContent(String lg, MenuElement page, String parentCompId, String contentType, String value, User authors)
static String
addContent(String lg, MenuElement page, String parentCompId, String contentType, String value, User authors, String renderer, String colStyle, int colSize)
add content to a pagestatic String
addContentIfNotExist(ContentContext ctx, MenuElement page, String parentCompId, String contentType, String value)
add content to a pagestatic String
addContentIfNotExist(ContentContext ctx, MenuElement page, String parentCompId, String contentType, String value, String style)
add content to a pagestatic void
addContentInPage(ContentContext ctx, MenuElement newPage, String pageStructureName)
static void
addContentInPage(ContentContext ctx, MenuElement newPage, String pageStructureName, Date date, Collection<String> tags)
static MenuElement
addPage(ContentContext ctx, String parentName, String pagePrefix, boolean top)
insert a page in the navigation.static MenuElement
addPage(ContentContext ctx, MenuElement parentPage, String pageName, boolean top, boolean store)
static MenuElement
addPageIfNotExist(ContentContext ctx, String parentName, String pageName, boolean top)
insert a page in the navigation if she does'nt exist.static MenuElement
addPageIfNotExist(ContentContext ctx, MenuElement parentPage, String pageName, boolean top, boolean store)
static MenuElement
addPageIfNotExistWithoutMessage(ContentContext ctx, MenuElement parentPage, String pageName, boolean top)
insert a page in the navigation if she does'nt exist.static MenuElement
addPageIfNotExistWithoutMessage(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 String
copyChildren(ContentContext ctx, MenuElement source, MenuElement target, String sourcePattern, String targetPattern)
static void
copyLanguageStructure(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 void
copyLocalContent(MenuElement fromPage, ContentContext fromCtx, MenuElement toPage, ContentContext toCtx)
Copy the local content of the current language totoPage
.static void
createAlphabeticChildren(ContentContext ctx, MenuElement parentPage)
static MenuElement
createArticlePage(ContentContext ctx, MenuElement rootPage, Date date)
static MenuElement
createArticlePageName(ContentContext ctx, MenuElement parentPage)
static void
createMonthStructure(ContentContext ctx, MenuElement yearPage)
static void
createPageStructure(ContentContext ctx, MenuElement page, Map componentsType, boolean fakeContent)
static void
createPageStructure(ContentContext ctx, MenuElement page, Map componentsType, boolean fakeContent, Date date, Collection<String> tags)
static MenuElement
createPathIfNotExist(ContentContext ctx, String path)
create all pages of a path or return the existing page.static void
deleteContentByLanguage(ContentContext ctx, MenuElement page, String lg)
static void
deleteLocalContent(MenuElement currentPage, ContentContext ctx)
Delete local content of the current language for the page specified.static MenuElement
duplicatePage(ContentContext ctx, MenuElement page, String newname, boolean mirror)
static String
getAlphabeticChildrenName(MenuElement parentPage, Character letter)
static Date
getCurrentMacroDate(javax.servlet.http.HttpSession session)
static String
getDisplayName(Calendar cal, int field, int style, Locale locale)
code from JDK 1.7 for compatibility to for JDK < 1.6static String
getLaunchMacroXHTML(ContentContext ctx, String macro, String label, String css)
static String
getMonthPageName(ContentContext ctx, String yearPageName, Date date)
static String
getXHTMLMacroSelection(ContentContext ctx)
static String
getXHTMLMacroSelection(ContentContext ctx, boolean adminMode, boolean preview)
static void
insertContent(ContentContext ctx, MenuElement page, String content)
add content to a page.static boolean
isMacro(ContentContext ctx)
static void
main(String[] args)
static boolean
removeContent(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 void
setCurrentMacroDate(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:
FileNotFoundException
IOException
-
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:
FileNotFoundException
IOException
-
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:
IOException
Exception
-
addContentInPage
public static void addContentInPage(ContentContext ctx, MenuElement newPage, String pageStructureName, Date date, Collection<String> tags) throws IOException, Exception
- Throws:
IOException
Exception
-
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:
IOException
Exception
-
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)
-
-