use of org.jdom2.output.Format in project mycore by MyCoRe-Org.
the class MCRAccessControlSystem method getRule.
@Override
public Element getRule(String objID, String permission) {
MCRAccessRule accessRule = getAccessRule(objID, permission);
MCRRuleParser parser = new MCRRuleParser();
Element rule = parser.parse(accessRule.rule).toXML();
Element condition = new Element("condition");
condition.setAttribute("format", "xml");
if (rule != null) {
condition.addContent(rule);
}
return condition;
}
use of org.jdom2.output.Format in project mycore by MyCoRe-Org.
the class MCRAccessManager method getFalseRule.
/**
* return a rule, that forbids something for all, but superuser
*
* @return a rule, that forbids something for all, but superuser
*/
public static Element getFalseRule() {
Element condition = new Element("condition");
condition.setAttribute("format", "xml");
Element booleanOp = new Element("boolean");
booleanOp.setAttribute("operator", "false");
condition.addContent(booleanOp);
return condition;
}
use of org.jdom2.output.Format in project mycore by MyCoRe-Org.
the class MCRDirectoryXML method addTime.
private void addTime(Element parent, String type, int hh, int mm, int ss) {
Element xTime = new Element(type);
parent.addContent(xTime);
GregorianCalendar date = new GregorianCalendar(TimeZone.getDefault(), Locale.ROOT);
date.set(2002, Calendar.FEBRUARY, 1, hh, mm, ss);
String time = timeFormatter.format(date.getTime());
xTime.setAttribute("format", timeFormat);
xTime.addContent(time);
}
use of org.jdom2.output.Format in project mycore by MyCoRe-Org.
the class MCRWCMSUtil method convertToOldFormat.
/**
* Converts the navigation.xml to the old format.
*/
private static byte[] convertToOldFormat(byte[] xml) throws JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new ByteArrayInputStream(xml));
Element rootElement = doc.getRootElement();
rootElement.setAttribute("href", rootElement.getName());
List<org.jdom2.Element> children = rootElement.getChildren();
for (Element menu : children) {
String id = menu.getAttributeValue("id");
menu.setName(id);
menu.setAttribute("href", id);
menu.removeAttribute("id");
}
XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
ByteArrayOutputStream bout = new ByteArrayOutputStream(xml.length);
out.output(doc, bout);
return bout.toByteArray();
}
use of org.jdom2.output.Format in project mycore by MyCoRe-Org.
the class MCRXMLFunctions method getISODateFromMCRHistoryDate.
/**
* The method get a date String in format yyyy-MM-ddThh:mm:ssZ for ancient date values.
*
* @param date_value the date string
* @param field_name the name of field of MCRMetaHistoryDate, it should be 'von' or 'bis'
* @param calendar_name the name if the calendar defined in MCRCalendar
* @return the date in format yyyy-MM-ddThh:mm:ssZ
*/
public static String getISODateFromMCRHistoryDate(String date_value, String field_name, String calendar_name) throws ParseException {
String formatted_date;
if (field_name == null || field_name.trim().length() == 0) {
return "";
}
boolean use_last_value = false;
if ("bis".equals(field_name)) {
use_last_value = true;
}
try {
Calendar calendar = MCRCalendar.getHistoryDateAsCalendar(date_value, use_last_value, calendar_name);
GregorianCalendar g_calendar = MCRCalendar.getGregorianCalendarOfACalendar(calendar);
formatted_date = MCRCalendar.getCalendarDateToFormattedString(g_calendar, "yyyy-MM-dd") + "T00:00:00.000Z";
if (g_calendar.get(GregorianCalendar.ERA) == GregorianCalendar.BC) {
formatted_date = "-" + formatted_date;
}
} catch (Exception e) {
String errorMsg = "Error while converting date string : " + date_value + " - " + use_last_value + " - " + calendar_name;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errorMsg, e);
}
LOGGER.warn(errorMsg);
return "";
}
return formatted_date;
}
Aggregations