Example usage for org.joda.time DateTime toString

List of usage examples for org.joda.time DateTime toString

Introduction

In this page you can find the example usage for org.joda.time DateTime toString.

Prototype

public String toString(String pattern) 

Source Link

Document

Output the instant using the specified format pattern.

Usage

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

/**
 * Adds the values of the {@link UserAccount} to the provided {@link Map}.
 *
 * @param userAccount The {@link UserAccount}.
 * @param values      The {@link Map} to add the values to.
 * @throws SystemException Thrown in case of an internal error.
 */// w w  w.  j a va  2s. c om
private static void addUserAccountValues(final UserAccount userAccount, final Map<String, Object> values) {
    DateTime lmdDateTime = new DateTime(userAccount.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("userAccountLastModificationDate", lmd);
    values.put("userAccountHref", userAccount.getHref());
    DateTime creationDateTime = new DateTime(userAccount.getCreationDate());
    creationDateTime = creationDateTime.withZone(DateTimeZone.UTC);
    final String creationDate = creationDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("userAccountCreationDate", creationDate);
    values.put("userAccountName", userAccount.getName());
    values.put("userAccountLoginName", userAccount.getLoginname());
    values.put(USER_ACCOUNT_ID, userAccount.getId());
    values.put("userAccountActive", userAccount.getActive());

    final UserAccount createdBy = userAccount.getUserAccountByCreatorId();
    values.put("userAccountCreatedByTitle", createdBy.getName());
    values.put("userAccountCreatedByHref", createdBy.getHref());
    values.put("userAccountCreatedById", createdBy.getId());

    final UserAccount modifiedBy = userAccount.getUserAccountByModifiedById();
    values.put("userAccountModifiedByTitle", modifiedBy.getName());
    values.put("userAccountModifiedByHref", modifiedBy.getHref());
    values.put("userAccountModifiedById", modifiedBy.getId());

    addResourcesValues(userAccount, values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

/**
 * See Interface for functional description.
 *///  w w  w . j  a va  2s  . co  m
@Override
public String renderCurrentGrants(final UserAccount userAccount, final List<RoleGrant> currentGrants)
        throws WebserverSystemException {

    final Map<String, Object> values = new HashMap<String, Object>();
    values.put("isRootCurrentGrants", XmlTemplateProviderConstants.TRUE);
    values.put("grantNamespacePrefix", Constants.GRANTS_NS_PREFIX);
    values.put("grantNamespace", Constants.GRANTS_NS_URI);
    values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS_PREFIX, Constants.PROPERTIES_NS_PREFIX);
    values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS, Constants.PROPERTIES_NS_URI);
    values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS_PREFIX, Constants.STRUCTURAL_RELATIONS_NS_PREFIX);
    values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS, Constants.STRUCTURAL_RELATIONS_NS_URI);
    values.put("currentGrantsTitle", "Grants of " + userAccount.getLoginname());
    values.put("currentGrantsHref", XmlUtility.getCurrentGrantsHref(userAccount.getId()));
    if (currentGrants != null && !currentGrants.isEmpty()) {
        values.put("currentGrants", currentGrants);
    }
    DateTime lmdDateTime = new DateTime(userAccount.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put(XmlTemplateProviderConstants.VAR_LAST_MODIFICATION_DATE, lmd);
    addEscidocBaseUrl(values);
    return getUserAccountXmlProvider().getCurrentGrantsXml(values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

/**
 * See Interface for functional description.
 *///ww w  .j  a v  a 2s  . c o  m
@Override
public String renderGrant(final RoleGrant grant) throws WebserverSystemException {

    final Map<String, Object> values = new HashMap<String, Object>();

    values.put("isRootGrant", XmlTemplateProviderConstants.TRUE);
    values.put("grantNamespacePrefix", Constants.GRANTS_NS_PREFIX);
    values.put("grantNamespace", Constants.GRANTS_NS_URI);
    values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS_PREFIX, Constants.PROPERTIES_NS_PREFIX);
    values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS, Constants.PROPERTIES_NS_URI);
    values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS_PREFIX, Constants.STRUCTURAL_RELATIONS_NS_PREFIX);
    values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS, Constants.STRUCTURAL_RELATIONS_NS_URI);
    values.put("grantTitle", grant.getTitle());
    values.put("grantHref", grant.getHref());
    values.put("grantId", grant.getId());
    if (grant.getUserAccountByUserId() != null) {
        values.put("grantUserTitle", grant.getUserAccountByUserId().getName());
        values.put("grantUserHref", grant.getUserAccountByUserId().getHref());
        values.put("grantUserId", grant.getUserAccountByUserId().getId());
    } else if (grant.getUserGroupByGroupId() != null) {
        values.put("grantGroupTitle", grant.getUserGroupByGroupId().getName());
        values.put("grantGroupHref", grant.getUserGroupByGroupId().getHref());
        values.put("grantGroupId", grant.getUserGroupByGroupId().getId());
    }
    final EscidocRole escidocRole = grant.getEscidocRole();
    values.put("grantRoleTitle", escidocRole.getRoleName());
    final String roleId = escidocRole.getId();
    values.put("grantRoleHref", XmlUtility.getRoleHref(roleId));
    values.put("grantRoleId", roleId);
    values.put("grantObjectRefHref", grant.getObjectHref());
    values.put("grantObjectRefTitle", grant.getObjectTitle());
    values.put("grantObjectRefId", grant.getObjectId());
    DateTime creationDateTime = new DateTime(grant.getCreationDate());
    creationDateTime = creationDateTime.withZone(DateTimeZone.UTC);
    final String creationDate = creationDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("grantCreationDate", creationDate);
    values.put("grantCreatedByTitle", grant.getUserAccountByCreatorId().getName());
    values.put("grantCreatedByHref", grant.getUserAccountByCreatorId().getHref());
    values.put("grantCreatedById", grant.getUserAccountByCreatorId().getId());
    values.put("grantRemark", grant.getGrantRemark());

    final Date revocationDate = grant.getRevocationDate();
    if (revocationDate != null) {
        DateTime revokationDateTime = new DateTime(revocationDate);
        revokationDateTime = revokationDateTime.withZone(DateTimeZone.UTC);
        final String revokationDate = revokationDateTime.toString(Constants.TIMESTAMP_FORMAT);
        values.put("grantRevocationDate", revokationDate);
        final UserAccount revokedBy = grant.getUserAccountByRevokerId();
        values.put("grantRevokedByHref", revokedBy.getHref());
        values.put("grantRevokedById", revokedBy.getId());
        values.put("grantRevokedByTitle", revokedBy.getName());
        values.put("grantRevocationRemark", grant.getRevocationRemark());
    }

    addEscidocBaseUrl(values);
    DateTime lmdDateTime = new DateTime(grant.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("grantLastModificationDate", lmd);
    return getUserAccountXmlProvider().getGrantXml(values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

/**
 * See Interface for functional description.
 *
 * @see UserAccountRendererInterface #renderResources(de.escidoc.core.aa.business.UserAccount)
 *///  ww w  .ja va 2 s. com
@Override
public String renderResources(final UserAccount userAccount) throws WebserverSystemException {

    final Map<String, Object> values = new HashMap<String, Object>();
    values.put("isRootResources", XmlTemplateProviderConstants.TRUE);
    addResourcesValues(userAccount, values);
    addCommonValues(values);
    DateTime lmdDateTime = new DateTime(userAccount.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("userAccountLastModificationDate", lmd);
    return getUserAccountXmlProvider().getResourcesXml(values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

private static String renderPreference(final UserAccount userAccount, final UserPreference preference,
        final boolean isRootPreference) throws WebserverSystemException {

    final Map<String, Object> values = new HashMap<String, Object>();

    addPreferencesCommonValues(values);// www . ja  v  a2  s  .c o  m
    if (isRootPreference) {
        values.put("isRootPreference", XmlTemplateProviderConstants.TRUE);
        DateTime lmdDateTime = new DateTime(userAccount.getLastModificationDate());
        lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
        final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
        values.put("userAccountLastModificationDate", lmd);
        values.put(USER_ACCOUNT_ID, userAccount.getId());
        addEscidocBaseUrl(values);
    }

    values.put("userAccountPreferenceName", preference.getName());
    values.put("userAccountPreferenceValue", preference.getValue());
    return getUserAccountXmlProvider().getPreferenceXml(values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

@Override
public String renderPreferences(final UserAccount userAccount, final Set<UserPreference> preferences)
        throws WebserverSystemException {

    final Map<String, Object> values = new HashMap<String, Object>();

    values.put("isRootPreference", false);
    addPreferencesCommonValues(values);// w ww. j a v  a  2s .  c  o  m
    DateTime lmdDateTime = new DateTime(userAccount.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("userAccountLastModificationDate", lmd);
    values.put(USER_ACCOUNT_ID, userAccount.getId());
    addEscidocBaseUrl(values);

    final Collection<Map<String, String>> userAccountPreferencesValues = new ArrayList<Map<String, String>>();
    ;
    for (final UserPreference preference : preferences) {
        final Map<String, String> m = new HashMap<String, String>();
        m.put("userAccountPreferenceName", preference.getName());
        m.put("userAccountPreferenceValue", preference.getValue());
        userAccountPreferencesValues.add(m);
    }
    values.put("userAccountPreferences", userAccountPreferencesValues);
    return getUserAccountXmlProvider().getPreferencesXml(values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

/**
 * renders one user-attribute.//from  w  w  w  .  j a v a 2  s.  c  o  m
 *
 * @param attribute       attribute
 * @param isRootAttribute if root attribute
 * @return String rendered attribute
 * @throws WebserverSystemException e
 */
private String renderAttribute(final UserAttribute attribute, final String isRootAttribute)
        throws WebserverSystemException {

    final Map<String, Object> values = new HashMap<String, Object>();

    values.put("isRootAttribute", isRootAttribute);
    addAttributesCommonValues(values);
    if (XmlTemplateProviderConstants.TRUE.equals(isRootAttribute)) {
        DateTime lmdDateTime = new DateTime(attribute.getUserAccountByUserId().getLastModificationDate());
        lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
        final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
        values.put(XmlTemplateProviderConstants.VAR_LAST_MODIFICATION_DATE, lmd);
        values.put(USER_ACCOUNT_ID, attribute.getUserAccountByUserId().getId());
    }
    values.put("userAccountAttributeId", attribute.getId());
    values.put("userAccountAttributeName", attribute.getName());
    values.put("userAccountAttributeValue", attribute.getValue());
    values.put("userAccountAttributeIsInternal", attribute.getInternal());
    return getUserAccountXmlProvider().getAttributeXml(values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserAccountRenderer.java

License:Open Source License

/**
 * See Interface for functional description.
 *
 * @param userAccount user-account-do/*from  w ww .ja  v  a2s .  com*/
 * @param attributes  set containing the attributes
 * @return String rendered attributes
 */
@Override
public String renderAttributes(final UserAccount userAccount, final Set<UserAttribute> attributes)
        throws WebserverSystemException {

    final Map<String, Object> values = new HashMap<String, Object>();

    addAttributesCommonValues(values);
    DateTime lmdDateTime = new DateTime(userAccount.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put(XmlTemplateProviderConstants.VAR_LAST_MODIFICATION_DATE, lmd);
    values.put(USER_ACCOUNT_ID, userAccount.getId());
    addEscidocBaseUrl(values);

    final Collection<Map<String, Object>> userAccountAttributesValues = new ArrayList<Map<String, Object>>();
    for (final UserAttribute attribute : attributes) {
        final Map<String, Object> m = new HashMap<String, Object>();
        m.put(USER_ACCOUNT_ID, userAccount.getId());
        m.put("userAccountAttributeId", attribute.getId());
        m.put("userAccountAttributeName", attribute.getName());
        m.put("userAccountAttributeValue", attribute.getValue());
        m.put("userAccountAttributeIsInternal", attribute.getInternal());
        userAccountAttributesValues.add(m);
    }
    values.put("userAccountAttributes", userAccountAttributesValues);
    return getUserAccountXmlProvider().getAttributesXml(values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserGroupRenderer.java

License:Open Source License

/**
 * Adds the values of the {@link UserGroup} to the provided {@link Map}.
 *
 * @param userGroup The {@link UserGroup}.
 * @param values    The {@link Map} to add the values to.
 * @throws SystemException Thrown in case of an internal error.
 *///w  ww .ja  va2s  .  c o  m
private static void addUserGroupValues(final UserGroup userGroup, final Map<String, Object> values) {
    DateTime lmdDateTime = new DateTime(userGroup.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("userGroupLastModificationDate", lmd);
    values.put("userGroupHref", userGroup.getHref());
    DateTime creationDateTime = new DateTime(userGroup.getCreationDate());
    creationDateTime = creationDateTime.withZone(DateTimeZone.UTC);
    final String creationDate = creationDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put("userGroupCreationDate", creationDate);
    values.put("userGroupName", userGroup.getName());
    values.put("userGroupLabel", userGroup.getLabel());
    values.put("userGroupType", userGroup.getType());
    values.put("userGroupEmail", userGroup.getEmail());
    values.put("userGroupDescription", userGroup.getDescription());
    values.put("userGroupId", userGroup.getId());
    values.put("userGroupActive", userGroup.getActive());
    values.put("userGroupSelectors", userGroup.getMembers());

    final UserAccount createdBy = userGroup.getCreatorId();

    values.put("userGroupCreatedByTitle", createdBy.getName());
    values.put("userGroupCreatedByHref", createdBy.getHref());
    values.put("userGroupCreatedById", createdBy.getId());

    final UserAccount modifiedBy = userGroup.getModifiedById();

    values.put("userGroupModifiedByTitle", modifiedBy.getName());
    values.put("userGroupModifiedByHref", modifiedBy.getHref());
    values.put("userGroupModifiedById", modifiedBy.getId());

    addResourcesValues(userGroup, values);
}

From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserGroupRenderer.java

License:Open Source License

/**
 * See Interface for functional description.
 *
 *//*  w w w.ja  va 2 s.  c o m*/
@Override
public String renderCurrentGrants(final UserGroup userGroup, final List<RoleGrant> currentGrants)
        throws WebserverSystemException {
    final Map<String, Object> values = new HashMap<String, Object>();

    values.put("isRootCurrentGrants", XmlTemplateProviderConstants.TRUE);
    values.put("grantNamespacePrefix", Constants.GRANTS_NS_PREFIX);
    values.put("grantNamespace", Constants.GRANTS_NS_URI);
    values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS_PREFIX, Constants.PROPERTIES_NS_PREFIX);
    values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS, Constants.PROPERTIES_NS_URI);
    values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS_PREFIX, Constants.STRUCTURAL_RELATIONS_NS_PREFIX);
    values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS, Constants.STRUCTURAL_RELATIONS_NS_URI);
    values.put("currentGrantsTitle", "Grants of " + userGroup.getLabel());
    values.put("currentGrantsHref", XmlUtility.getUserGroupCurrentGrantsHref(userGroup.getId()));
    if (currentGrants != null && !currentGrants.isEmpty()) {
        values.put("currentGrants", currentGrants);
    }
    DateTime lmdDateTime = new DateTime(userGroup.getLastModificationDate());
    lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC);
    final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT);
    values.put(XmlTemplateProviderConstants.VAR_LAST_MODIFICATION_DATE, lmd);

    addEscidocBaseUrl(values);
    return getUserGroupXmlProvider().getCurrentGrantsXml(values);
}