Example usage for java.io Serializable toString

List of usage examples for java.io Serializable toString

Introduction

In this page you can find the example usage for java.io Serializable toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.minlia.cloud.framework.test.common.web.util.ClientConstraintsUtil.java

public static Triple<String, ClientOperation, String> createIdConstraint(final ClientOperation operation,
        final Serializable idValue) {
    return createConstraint(operation, SearchField.id.toString(), idValue.toString());
}

From source file:org.pentaho.platform.plugin.action.ActionParams.java

private static void recreateStreamProvider(final Map<String, Serializable> params) {
    final Serializable spInputFile = params.get(ActionUtil.INVOKER_STREAMPROVIDER_INPUT_FILE);
    final String inputFile = spInputFile != null ? spInputFile.toString() : null;
    final Serializable spOutputFilePattern = params.get(ActionUtil.INVOKER_STREAMPROVIDER_OUTPUT_FILE_PATTERN);
    final String outputFilePattern = spOutputFilePattern != null ? spOutputFilePattern.toString() : null;

    if (inputFile == null || outputFilePattern == null) {
        if (logger.isWarnEnabled()) {
            logger.warn(Messages.getInstance().getMissingParamsCantReturnSp(
                    String.format("%s, %s", ActionUtil.INVOKER_STREAMPROVIDER_INPUT_FILE,
                            ActionUtil.INVOKER_STREAMPROVIDER_OUTPUT_FILE_PATTERN),
                    params)); //$NON-NLS-1$
        }/*from   w w  w . j av a 2s. c  o m*/

        return;
    }

    final boolean autoCreateUniqueFilename = params
            .containsKey(ActionUtil.INVOKER_STREAMPROVIDER_UNIQUE_FILE_NAME)
                    ? Boolean.parseBoolean(
                            params.get(ActionUtil.INVOKER_STREAMPROVIDER_UNIQUE_FILE_NAME).toString())
                    : true;

    params.put(ActionUtil.INVOKER_STREAMPROVIDER,
            new RepositoryFileStreamProvider(inputFile, outputFilePattern, autoCreateUniqueFilename));
}

From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileAclUtils.java

public static RepositoryFileAcl getAcl(final Session session, final PentahoJcrConstants pentahoJcrConstants,
        final Serializable id) throws RepositoryException {

    Node node = session.getNodeByIdentifier(id.toString());
    if (node == null) {
        throw new RepositoryException(Messages.getInstance()
                .getString("JackrabbitRepositoryFileAclDao.ERROR_0001_NODE_NOT_FOUND", id.toString())); //$NON-NLS-1$
    }/*from  w  w  w.j  av  a 2 s  . c  om*/
    String absPath = node.getPath();
    AccessControlManager acMgr = session.getAccessControlManager();
    AccessControlList acList = getAccessControlList(acMgr, absPath);

    RepositoryFileSid owner = null;
    String ownerString = JcrTenantUtils.getUserNameUtils().getPrincipleName(getOwner(session, absPath, acList));

    if (ownerString != null) {
        // for now, just assume all owners are users; only has UI impact
        owner = new RepositoryFileSid(ownerString, RepositoryFileSid.Type.USER);
    }

    RepositoryFileAcl.Builder aclBuilder = new RepositoryFileAcl.Builder(id, owner);

    aclBuilder.entriesInheriting(isEntriesInheriting(session, absPath, acList));

    List<AccessControlEntry> cleanedAcEntries = JcrRepositoryFileAclUtils
            .removeAclMetadata(Arrays.asList(acList.getAccessControlEntries()));

    for (AccessControlEntry acEntry : cleanedAcEntries) {
        aclBuilder.ace(toAce(session, acEntry));
    }
    return aclBuilder.build();

}

From source file:org.nuxeo.webengine.sites.utils.SiteUtils.java

public static String getString(DocumentModel d, String xpath) throws ClientException {
    Property p = d.getProperty(xpath);// www. j  a  va 2 s. com
    if (p != null) {
        Serializable v = p.getValue();
        if (v != null) {
            return v.toString();
        }
    }
    return "";
}

From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileAclUtils.java

public static RepositoryFileAcl createAcl(Session session, PentahoJcrConstants pentahoJcrConstants,
        Serializable fileId, RepositoryFileAcl acl) throws ItemNotFoundException, RepositoryException {
    Node node = session.getNodeByIdentifier(fileId.toString());
    String absPath = node.getPath();
    AccessControlManager acMgr = session.getAccessControlManager();
    AccessControlList acList = getAccessControlList(acMgr, absPath);
    acMgr.setPolicy(absPath, acList);/* www  . j  av a  2  s .  co m*/
    return internalUpdateAcl(session, pentahoJcrConstants, fileId, acl);
}

From source file:de.ingrid.interfaces.csw.tools.FileUtils.java

/**
 * Encode an id to be used in a filename.
 * //w ww.j  a v  a  2  s.  c  o m
 * @return String
 */
public static String encodeId(Serializable id) {
    if (id != null) {
        return encodeFileName(id.toString());
    } else {
        throw new IllegalArgumentException("Null is not allowed as id value.");
    }
}

From source file:de.ingrid.interfaces.csw.tools.FileUtils.java

/**
 * Decode an id that was used in a filename.
 * //  ww  w . j a  va2 s  .c o  m
 * @return String
 */
public static String decodeId(Serializable id) {
    if (id != null) {
        return decodeFileName(id.toString());
    } else {
        throw new IllegalArgumentException("Null is not allowed as id value.");
    }
}

From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileAclUtils.java

private static RepositoryFileAcl internalUpdateAcl(final Session session,
        final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final RepositoryFileAcl acl)
        throws RepositoryException {
    Node node = session.getNodeByIdentifier(fileId.toString());
    if (node == null) {
        throw new RepositoryException("Node not found"); //$NON-NLS-1$
    }/*from   w  ww  .  ja  v  a  2s .c  o  m*/
    String absPath = node.getPath();
    AccessControlManager acMgr = session.getAccessControlManager();
    AccessControlList acList = getAccessControlList(acMgr, absPath);

    // clear all entries
    AccessControlEntry[] acEntries = acList.getAccessControlEntries();
    for (int i = 0; i < acEntries.length; i++) {
        acList.removeAccessControlEntry(acEntries[i]);
    }

    JcrRepositoryFileAclUtils.setAclMetadata(session, absPath, acList,
            new AclMetadata(acl.getOwner().getName(), acl.isEntriesInheriting()));

    // add entries to now empty list but only if not inheriting; force user to start with clean slate
    if (!acl.isEntriesInheriting()) {
        for (RepositoryFileAce ace : acl.getAces()) {
            Principal principal = null;
            if (RepositoryFileSid.Type.ROLE == ace.getSid().getType()) {
                principal = new SpringSecurityRolePrincipal(
                        JcrTenantUtils.getTenantedRole(ace.getSid().getName()));
            } else {
                principal = new SpringSecurityUserPrincipal(
                        JcrTenantUtils.getTenantedUser(ace.getSid().getName()));
            }
            IPermissionConversionHelper permissionConversionHelper = new DefaultPermissionConversionHelper(
                    session);
            acList.addAccessControlEntry(principal,
                    permissionConversionHelper.pentahoPermissionsToPrivileges(session, ace.getPermissions()));
        }
    }
    acMgr.setPolicy(absPath, acList);
    session.save();
    return getAcl(session, pentahoJcrConstants, fileId);
}

From source file:com.bluexml.side.Integration.alfresco.xforms.webscript.XmlBuilder.java

@SuppressWarnings("unchecked")
private static Element buildAttributes(Document doc, Map<QName, Serializable> properties) {
    Element attributesE = doc.createElement(ENTRY_ATTRIBUTES_NODE);
    for (Entry<QName, Serializable> entry : properties.entrySet()) {
        Serializable value = entry.getValue();
        if (value != null) {
            Element att = null;/*from  w  w  w. j  a  v  a2s  . c o  m*/
            if (value instanceof Collection) {
                att = buildAttributeCollection(doc, entry.getKey().getLocalName(), (Collection<?>) value);
            } else {
                att = buildAttribute(doc, entry.getKey().getLocalName(), value.toString());
            }
            attributesE.appendChild(att);
        }
    }
    return attributesE;
}

From source file:org.openmrs.module.auditlog.util.AuditLogUtil.java

/**
 * Serializes the specified object to a String, typically it returns the object's uuid if it is
 * an OpenmrsObject, if not it returns the primary key value if it is a persistent object
 * otherwise to calls the toString method except for Date, Enum and Class objects that are
 * handled in a special way./*from www  . j a v a  2 s  .c o  m*/
 * 
 * @param obj the object to serialize
 * @return the serialized String form of the object
 */
public static String serializeObject(Object obj) {
    String serializedValue = null;
    if (obj != null) {
        Class<?> clazz = getActualType(obj);
        if (Date.class.isAssignableFrom(clazz)) {
            //TODO We need to handle time zones issues better
            serializedValue = new SimpleDateFormat(AuditLogConstants.DATE_FORMAT).format(obj);
        } else if (Enum.class.isAssignableFrom(clazz)) {
            //Use value.name() over value.toString() to ensure we always get back the enum
            //constant value and not the value returned by the implementation of value.toString()
            serializedValue = ((Enum<?>) obj).name();
        } else if (Class.class.isAssignableFrom(clazz)) {
            serializedValue = ((Class<?>) obj).getName();
        } else if (Collection.class.isAssignableFrom(clazz)) {
            serializedValue = serializeCollection((Collection) obj);
        } else if (Map.class.isAssignableFrom(clazz)) {
            serializedValue = serializeMap((Map) obj);
        }
        if (StringUtils.isBlank(serializedValue)) {
            ClassMetadata metadata = getClassMetadata(clazz);
            if (metadata != null) {
                Serializable id = metadata.getIdentifier(obj, EntityMode.POJO);
                if (id != null) {
                    serializedValue = id.toString();
                }
            }
        }

        if (StringUtils.isBlank(serializedValue)) {
            serializedValue = obj.toString();
        }
    }

    return serializedValue;
}