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.surevine.alfresco.esl.impl.ESCEntryVoter.java

protected String getSiteShortName(NodeRef siteNodeRef) {
    // Get the properties
    Serializable property = _nodeService.getProperty(siteNodeRef, ContentModel.PROP_NAME);
    String shortName = property.toString();
    return shortName;
}

From source file:net.mojodna.searchable.solr.SolrIndexer.java

@Override
protected void delete(final Serializable key) throws IndexingException {
    final Element delete = new Element("delete").addContent(
            new Element("query").addContent(IndexSupport.COMPOUND_ID_FIELD_NAME + ":" + key.toString()));

    // now do something with the delete block
    try {//  w w w  .j a v  a  2 s.c  om
        final XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
        final String deleteString = out.outputString(delete);
        final PostMethod post = new PostMethod(solrPath);
        post.setRequestEntity(new StringRequestEntity(deleteString, "text/xml", "UTF-8"));
        log.debug("Deleting:\n" + deleteString);
        getHttpClient().executeMethod(post);

        if (!isBatchMode()) {
            commit();
        }
    } catch (final IOException e) {
        throw new IndexingException(e);
    }
}

From source file:com.flexive.chemistry.webdav.TextDocumentResource.java

/**
 * {@inheritDoc}//from w  w  w.j  a  va 2  s  .  co m
 */
public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType)
        throws IOException, NotAuthorizedException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Sending object " + object.getId() + " as XML (range=" + range + ",params=" + params
                + ", contentType=" + contentType + ")");
    }
    final XmlWriter xml = new PrettyPrinterXmlWriter(new SimpleXmlWriter(new PrintWriter(out)));
    xml.writeXmlVersion();

    xml.writeEntity("document");
    xml.writeAttribute("objectId", object.getId());
    xml.writeAttribute("versionSeriesId", emptyIfNull(object.getVersionSeriesId()));
    xml.writeAttribute("typeId", object.getTypeId());

    xml.writeEntity("name").writeCData(object.getName()).endEntity();
    xml.writeEntity("properties");
    for (Map.Entry<String, Property> entry : object.getProperties().entrySet()) {
        xml.writeEntity("property");
        xml.writeAttribute("name", entry.getKey());
        xml.writeAttribute("type", entry.getValue().getDefinition().getType().name());

        xml.writeEntity("value");
        final Serializable value = entry.getValue().getValue();
        if (value != null) {
            if (value instanceof String) {
                xml.writeCData(value.toString());
            } else {
                xml.writeText(emptyIfNull(value));
            }
        }
        xml.endEntity(); // value

        xml.endEntity(); // property
    }
    xml.endEntity(); // properties

    xml.endEntity(); // document
    xml.close();
}

From source file:org.alfresco.repo.forms.processor.node.AssociationFieldProcessor.java

/**
 * Gets the associated value from the {@link ContentModelItemData}.
 * If the value is <code>null</code> the method returns an empty {@link List}.
 * If the value is a single Object (assumed to be a NodeRef) it returns a {@link List} containing a {@link String} representation of that object.
 * If the value is a {@link Collection} of Objects, returns a {@link List} containing {@link String} representations of all the objects.
 * @return An {@link ArrayList} of Strings or <code>null</code>.
 *///from   ww  w.java2 s .com
@Override
protected Object getValue(QName name, ContentModelItemData<?> data) {
    Serializable values = data.getAssociationValue(name);
    if (values == null) {
        return Collections.emptyList();
    }
    if (values instanceof Collection<?>) {
        return getValues((Collection<?>) values);
    }
    return Collections.singletonList(values.toString());
}

From source file:org.nuxeo.ecm.platform.routing.core.impl.GraphVariablesUtil.java

/**
 * @since 7.2/* w  w  w  .  j  a v  a 2  s .com*/
 */
public static Map<String, Serializable> getVariables(DocumentModel doc, String facetProp, boolean mapToJSON) {
    String facet = (String) doc.getPropertyValue(facetProp);
    Map<String, Serializable> map = new LinkedHashMap<String, Serializable>();
    if (StringUtils.isBlank(facet)) {
        return map;
    }
    CompositeType type = getSchemaManager().getFacet(facet);
    if (type == null) {
        return map;
    }
    boolean hasFacet = doc.hasFacet(facet);
    for (Field f : type.getFields()) {
        String name = f.getName().getLocalName();
        Serializable value = hasFacet ? doc.getPropertyValue(name) : null;
        if (value instanceof Calendar) {
            if (mapToJSON) {
                value = DateParser.formatW3CDateTime(((Calendar) value).getTime());
            } else {
                value = ((Calendar) value).getTime();
            }
        } else if (value instanceof Object[] && mapToJSON) {
            try {
                Object[] objects = (Object[]) value;
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                JsonGenerator jg = getFactory().createJsonGenerator(out);
                jg.writeStartArray();
                for (Object object : objects) {
                    jg.writeString(type.encode(object));
                }
                jg.writeEndArray();
                jg.flush();
                jg.close();
                value = out.toString("UTF-8");
            } catch (IOException e) {
                throw new NuxeoException(e);
            }
        }
        if (mapToJSON) {
            map.put(name, value != null ? value.toString() : null);
        } else {
            map.put(name, value);
        }
    }
    return map;
}

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

/**
 * {@inheritDoc}/* w  w w  .  ja va  2 s .  co  m*/
 */
public void addLockTokenToSessionIfNecessary(final Session session,
        final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId) throws RepositoryException {
    Node fileNode = session.getNodeByIdentifier(fileId.toString());
    if (fileNode.isLocked()) {
        LockManager lockManager = session.getWorkspace().getLockManager();
        Lock lock = lockManager.getLock(fileNode.getPath());
        String lockToken = getLockToken(session, pentahoJcrConstants, lock);
        lockManager.addLockToken(lockToken);
    }
}

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

/**
 * {@inheritDoc}//from  w w w.j  av a 2 s  .  c o  m
 */
public void removeLockTokenFromSessionIfNecessary(final Session session,
        final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId) throws RepositoryException {
    Node fileNode = session.getNodeByIdentifier(fileId.toString());
    if (fileNode.isLocked()) {
        LockManager lockManager = session.getWorkspace().getLockManager();
        Lock lock = lockManager.getLock(fileNode.getPath());
        String lockToken = getLockToken(session, pentahoJcrConstants, lock);
        lockManager.removeLockToken(lockToken);
    }
}

From source file:org.bremersee.pagebuilder.PageRequestBuilderImpl.java

protected int getPageNumber(final Serializable pageNumber) {
    int value = 0;
    if (pageNumber != null) {
        if (pageNumber instanceof Number) {
            value = ((Number) pageNumber).intValue();
        } else {//from   w w  w  . j a v a2  s  . c om
            try {
                value = Integer.valueOf(pageNumber.toString());
            } catch (Throwable t) { // NOSONAR
                value = 0;
                log.warn(
                        "Getting page number from value [" + pageNumber + "] failed. Returning " + value + ".");
            }
        }
    }
    return value >= 0 ? value : 0;
}

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

/**
 * {@inheritDoc}//www  . java  2 s. c o m
 */
public void unlockFile(final Session session, final PentahoJcrConstants pentahoJcrConstants,
        final Serializable fileId) throws RepositoryException {
    Node fileNode = session.getNodeByIdentifier(fileId.toString());
    LockManager lockManager = session.getWorkspace().getLockManager();
    Lock lock = lockManager.getLock(fileNode.getPath());
    String lockToken = getLockToken(session, pentahoJcrConstants, lock);
    lockManager.addLockToken(lockToken);
    // get the lock again so that it has a non-null lockToken
    lock = lockManager.getLock(fileNode.getPath());
    // don't need lock token anymore
    removeLockToken(session, pentahoJcrConstants, lock);
    lockManager.unlock(fileNode.getPath());
}

From source file:org.alfresco.repo.action.parameter.NodeParameterProcessor.java

/**
 * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
 *//*from  w w  w .ja v  a2 s. c om*/
@Override
public String process(String value, NodeRef actionedUponNodeRef) {
    // the default position is to return the value un-changed
    String result = value;

    // strip the processor name from the value
    value = stripName(value);
    if (!value.isEmpty()) {
        QName qname = QName.createQName(value, namespaceService);

        PropertyDefinition propertyDefinition = dictionaryService.getProperty(qname);
        if (propertyDefinition == null) {
            throw new AlfrescoRuntimeException(
                    "The property " + value + " does not have a property definition.");
        }

        QName type = propertyDefinition.getDataType().getName();
        if (ArrayUtils.contains(supportedDataTypes, type)) {
            Serializable propertyValue = nodeService.getProperty(actionedUponNodeRef, qname);
            if (propertyValue != null) {
                result = propertyValue.toString();
            } else {
                // set the result to the empty string
                result = "";
            }
        } else {
            throw new AlfrescoRuntimeException("The property " + value + " is of type " + type.toString()
                    + " which is not supported by parameter substitution.");
        }
    }

    return result;
}