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:ddf.catalog.CatalogFrameworkImpl.java

@SuppressWarnings("javadoc")
public ResourceResponse getResource(ResourceRequest resourceRequest, boolean isEnterprise,
        String resourceSiteName) throws IOException, ResourceNotFoundException, ResourceNotSupportedException {
    String methodName = "getResource";
    logger.entry(methodName);/*from ww w  .  j a v  a2 s.co m*/
    ResourceResponse resourceResponse = null;
    ResourceRequest resourceReq = resourceRequest;
    String resourceSourceName = resourceSiteName;
    if (resourceSourceName == null && !isEnterprise) {
        throw new ResourceNotFoundException("resourceSiteName cannot be null when obtaining resource.");
    }

    validateGetResourceRequest(resourceReq);
    try {

        for (PreResourcePlugin plugin : preResource) {
            try {
                resourceReq = plugin.process(resourceReq);
            } catch (PluginExecutionException e) {
                logger.info("Plugin processing failed. This is allowable. Skipping to next plugin.", e);
            }
        }

        Map<String, Serializable> requestProperties = resourceReq.getProperties();
        logger.debug("Attempting to get resource from siteName: " + resourceSourceName);
        // At this point we pull out the properties and use them.
        Serializable sourceIdProperty = requestProperties.get(ResourceRequest.SOURCE_ID);
        if (sourceIdProperty != null) {
            resourceSourceName = sourceIdProperty.toString();
        }

        Serializable enterpriseProperty = requestProperties.get(ResourceRequest.IS_ENTERPRISE);
        if (enterpriseProperty != null) {
            if (Boolean.parseBoolean(enterpriseProperty.toString())) {
                isEnterprise = true;
            }
        }

        // check if the resourceRequest has an ID only
        // If so, the metacard needs to be found and the Resource URI
        StringBuilder resolvedSourceIdHolder = new StringBuilder();
        URI responseURI = getResourceURI(resourceReq, resourceSourceName, isEnterprise, resolvedSourceIdHolder,
                requestProperties);

        String resolvedSourceId = resolvedSourceIdHolder.toString();

        if (logger.isDebugEnabled()) {
            logger.debug("resolvedSourceId = " + resolvedSourceId);
            logger.debug("ID = " + getId());
        }

        if (isEnterprise) {

            // since resolvedSourceId specifies what source the product
            // metacard resides on, we can just
            // change resourceSiteName to be that value, and then the
            // following if-else statements will
            // handle retrieving the product on the correct source
            resourceSourceName = resolvedSourceId;
        }
        // retrieve product from specified federated site
        if (resourceSourceName != null && !resourceSourceName.equals(getId())) {
            logger.debug("Searching federatedSource " + resourceSourceName + " for resource.");
            logger.debug("metacard for product found on source: " + resolvedSourceId);
            FederatedSource source = null;

            for (FederatedSource fedSource : federatedSources) {
                if (resourceSourceName.equals(fedSource.getId())) {
                    logger.debug("Adding federated site to federated query: " + fedSource.getId());
                    source = fedSource;
                    break;
                }
            }

            if (source != null) {
                resourceResponse = source.retrieveResource(responseURI, requestProperties);
            } else {
                logger.warn("Could not find federatedSource: " + resourceSourceName);
            }
        } else if (resourceSourceName != null) {
            // retrieve product from local source
            logger.debug("Trying to Obtain resource from localSource.");
            resourceResponse = getResourceUsingResourceReader(responseURI, requestProperties);
        }

        resourceResponse = validateFixGetResourceResponse(resourceResponse, resourceReq);

        for (PostResourcePlugin plugin : postResource) {
            try {
                resourceResponse = plugin.process(resourceResponse);
            } catch (PluginExecutionException e) {
                logger.info("Plugin processing failed. This is allowable. Skipping to next plugin.", e);
            }
        }

    } catch (RuntimeException e) {
        throw new ResourceNotFoundException("Unable to find resource");
    } catch (StopProcessingException e) {
        throw new ResourceNotSupportedException(FAILED_BY_GET_RESOURCE_PLUGIN + e.getMessage());
    }

    if (resourceResponse == null) {
        throw new ResourceNotFoundException("Resource could not be found for the given attribute value: "
                + resourceReq.getAttributeValue());
    }

    logger.exit(methodName);
    return resourceResponse;
}

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

/**
 * Provides the value of the node's identifier property.
 * /*  w  w  w .j a v  a 2 s. c  om*/
 * @param nodeRef
 *            an existing node
 * @param identifierQName
 *            the qname of a node property
 * @return
 */
private String resolveIdentifierValue(NodeRef nodeRef, QName identifierQName) { // #1529
    if (identifierQName == null) {
        return "";
    }
    Serializable value = serviceRegistry.getNodeService().getProperty(nodeRef, identifierQName);

    if (value == null) {
        return "";
    }

    return value.toString();
}

From source file:org.craftercms.cstudio.alfresco.dm.service.impl.DmContentServiceImpl.java

protected InputStream _getContent(String site, String path, boolean edit, String user, String fullPath,
        boolean mergePrototype, boolean isDraft) throws ContentNotFoundException {
    ServicesConfig servicesConfig = getService(ServicesConfig.class);
    String repoRootPath = servicesConfig.getRepositoryRootPath(site);
    /* Disable DRAFT repo Dejan 29.03.2012 */
    /*//from   www .ja v a 2s.c om
    if (isDraft) {
       repoRootPath = DmUtils.cleanRepositoryPath(repoRootPath);
    } */
    /***************************************/
    PersistenceManagerService persistenceManagerService = getService(PersistenceManagerService.class);
    NodeRef contentNode = persistenceManagerService.getNodeRef(repoRootPath + "/" + path);

    if (contentNode != null) {
        if (edit) {
            if (persistenceManagerService.getLockStatus(contentNode).equals(LockStatus.LOCKED)) {
                if (logger.isWarnEnabled()) {
                    logger.warn("Content at " + path + " is already locked by another user.");
                }
            } else {
                persistenceManagerService.lock(contentNode, LockType.WRITE_LOCK);
            }
        }
        FileInfo fileInfo = persistenceManagerService.getFileInfo(contentNode);
        Map<QName, Serializable> contentProps = fileInfo.getProperties();
        Serializable contentTypeValue = contentProps.get(CStudioContentModel.PROP_CONTENT_TYPE);
        String contentType = (contentTypeValue != null) ? contentTypeValue.toString() : null;

        if (mergePrototype && !StringUtils.isEmpty(contentType)) {
            ContentTypeConfigTO config = servicesConfig.getContentTypeConfig(site, contentType);
            if (config != null) {
                if (!DmConstants.CONTENT_TYPE_CONFIG_FORM_PATH_SIMPLE.equalsIgnoreCase(config.getFormPath())) {
                    Serializable versionValue = contentProps.get(CStudioContentModel.PROP_TEMPLATE_VERSION);
                    String version = (versionValue != null) ? versionValue.toString() : null;
                    DmContentTypeService dmContentTypeService = getService(DmContentTypeService.class);
                    return dmContentTypeService.mergeLastestTemplate(site, path, contentType, version,
                            persistenceManagerService.getReader(contentNode).getContentInputStream());
                }
            }
        }
        return persistenceManagerService.getReader(contentNode).getContentInputStream();
    } else {
        throw new ContentNotFoundException(path + " is not found in site: " + site);
    }
}

From source file:org.craftercms.cstudio.alfresco.dm.service.impl.DmContentServiceImpl.java

/**
 * load content properties from the content metadata
 *
 * @param path/*w  w w .jav  a  2  s  .c  om*/
 * @param item
 */
@SuppressWarnings("unchecked")
protected void loadContentProperties(String path, DmContentItemTO item) {
    // read common metadata
    Serializable internalNameValue = getPropertyValue(path, CStudioContentModel.PROP_INTERNAL_NAME);
    String internalName = (internalNameValue != null) ? internalNameValue.toString() : null;
    // set internal name
    if (!StringUtils.isEmpty(internalName)) {
        item.setInternalName(internalName);
        Serializable titleValue = getPropertyValue(path, CStudioContentModel.PROP_TITLE);
        String title = (titleValue != null) ? titleValue.toString() : null;
        if (!StringUtils.isEmpty(title))
            item.setTitle(title);
    } else {
        Serializable titleValue = getPropertyValue(path, CStudioContentModel.PROP_TITLE);
        String title = (titleValue != null) ? titleValue.toString() : null;
        if (!StringUtils.isEmpty(title)) {
            item.setInternalName(title);
            item.setTitle(title);
        }
    }
    Serializable metaDescriptionValue = getPropertyValue(path, CStudioContentModel.PROP_META_DESCRIPTION);
    String metaDescription = (metaDescriptionValue != null) ? metaDescriptionValue.toString() : null;
    if (metaDescription != null)
        item.setMetaDescription(metaDescription);

    // set other status flags
    Serializable floatingValue = getPropertyValue(path, CStudioContentModel.PROP_FLOATING);
    Boolean floating = (Boolean) floatingValue;
    if (floating != null) {
        item.setFloating(floating);
    } else {
        item.setFloating(false);
    }
    Serializable disabledValue = getPropertyValue(path, CStudioContentModel.PROP_DISABLED);
    Boolean disabled = (Boolean) disabledValue;
    if (disabled != null) {
        item.setDisabled(disabled);
    } else {
        item.setDisabled(false);
    }
    // set orders
    Serializable ordersValue = getPropertyValue(path, CStudioContentModel.PROP_ORDER_DEFAULT);
    List<String> orders = (List<String>) ordersValue;
    item.setOrders(getItemOrdersFromProperty(orders));
}

From source file:org.craftercms.cstudio.alfresco.dm.service.impl.DmContentServiceImpl.java

/**
 * load common properties from the content
 *
 * @param site//w ww . j a  v  a 2  s  .  c  o  m
 * @param node
 * @param item
 * @param populateDependencies
 * @param populateUpdatedDependecinesOnly
 *
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
protected void loadCommonProperties(String site, AVMNodeDescriptor node, DmContentItemTO item,
        boolean populateDependencies, boolean populateUpdatedDependecinesOnly) throws ServiceException {
    String path = node.getPath();
    if (logger.isDebugEnabled()) {
        logger.debug("loading common properties for " + path);
    }
    // set component flag
    ServicesConfig servicesConfig = getService(ServicesConfig.class);
    item.setComponent(matchesPatterns(item.getUri(), servicesConfig.getComponentPatterns(site)));
    if (item.getName().equals(servicesConfig.getLevelDescriptorName(site))) {
        item.setLevelDescriptor(true);
        // level descriptors are components
        item.setComponent(true);
    }
    // set document flag
    item.setDocument(matchesPatterns(item.getUri(), servicesConfig.getDocumentPatterns(site)));
    // if the content type meta is empty, populate properties from the file
    Document content = null;
    // read common metadata
    Serializable internalNameValue = getPropertyValue(path, CStudioContentModel.PROP_INTERNAL_NAME);
    String internalName = (internalNameValue != null) ? internalNameValue.toString() : null;
    if (!StringUtils.isEmpty(item.getContentType()) && !StringUtils.isEmpty(internalName)) {
        loadContentProperties(path, item);
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("content type is not found from the content metadata. loading properties from XML.");
        }
        content = loadPropertiesFromXml(site, path, item);
    }
    content = loadHideInAuthoringPropertyFromXml(site, path, item);
    if (content == null) {
        content = getDocumentFromDmContent(path);
    }
    // populate dependencies
    if (populateDependencies) {
        DmDependencyService dmDependencyService = getService(DmDependencyService.class);
        dmDependencyService.populateDependencyContentItems(site, item, populateUpdatedDependecinesOnly);
    }
    // TODO: remove this when order extraction is ready
    if (item.getOrders() == null) {
        if (content != null) {
            Element root = content.getRootElement();
            //item.setOrders(getItemOrders(root.selectNodes("//" + DmXmlConstants.ELM_ORDERS + "/"
            //        + DmXmlConstants.ELM_ORDER)));
            item.setOrders(getItemOrders(root.selectNodes("//" + DmXmlConstants.ELM_ORDER_DEFAULT)));
        }
    }
}

From source file:org.craftercms.cstudio.alfresco.dm.service.impl.DmContentServiceImpl.java

/**
 * load common properties from the content
 *
 * @param site//  w  ww  .  ja v  a2 s  . c om
 * @param node
 * @param item
 * @param populateDependencies
 * @param populateUpdatedDependecinesOnly
 *
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
protected void loadCommonProperties(String site, FileInfo node, DmContentItemTO item,
        boolean populateDependencies, boolean populateUpdatedDependecinesOnly) throws ServiceException {
    PersistenceManagerService persistenceManagerService = getService(PersistenceManagerService.class);
    String path = persistenceManagerService.getNodePath(node.getNodeRef());
    if (logger.isDebugEnabled()) {
        logger.debug("loading common properties for " + path);
    }
    // set component flag
    ServicesConfig servicesConfig = getService(ServicesConfig.class);
    item.setComponent(matchesPatterns(item.getUri(), servicesConfig.getComponentPatterns(site)));
    if (item.getName().equals(servicesConfig.getLevelDescriptorName(site))) {
        item.setLevelDescriptor(true);
        // level descriptors are components
        item.setComponent(true);
    }
    // set document flag
    item.setDocument(matchesPatterns(item.getUri(), servicesConfig.getDocumentPatterns(site)));
    // if the content type meta is empty, populate properties from the file
    Document content = null;
    // read common metadata
    Serializable internalNameValue = getPropertyValue(path, CStudioContentModel.PROP_INTERNAL_NAME);
    String internalName = (internalNameValue != null) ? internalNameValue.toString() : null;
    if (!StringUtils.isEmpty(item.getContentType()) && !StringUtils.isEmpty(internalName)) {
        loadContentProperties(path, item);
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("content type is not found from the content metadata. loading properties from XML.");
        }
        content = loadPropertiesFromXml(site, path, item);
    }
    content = loadHideInAuthoringPropertyFromXml(site, path, item);
    if (content == null) {
        content = getDocumentFromDmContent(path);
    }
    // populate dependencies
    if (populateDependencies) {
        DmDependencyService dmDependencyService = getService(DmDependencyService.class);
        dmDependencyService.populateDependencyContentItems(site, item, populateUpdatedDependecinesOnly);
    }
    // TODO: remove this when order extraction is ready
    if (item.getOrders() == null) {
        if (content != null) {
            Element root = content.getRootElement();
            //item.setOrders(getItemOrders(root.selectNodes("//" + DmXmlConstants.ELM_ORDERS + "/"
            //        + DmXmlConstants.ELM_ORDER)));
            item.setOrders(getItemOrders(root.selectNodes("//" + DmXmlConstants.ELM_ORDER_DEFAULT)));
        }
    }
}

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

/**
 * Gets the value of the first non-null textual property in the BlueXML
 * namespace./*from  ww w  . ja  va2s. co  m*/
 * 
 * @param nodeRef
 * @param properties
 * @param names
 * @return The first text property value, or the node id if no textual
 *         property is found.
 */
private String getLabelForNodeFirst(NodeRef nodeRef, Map<QName, Serializable> properties, Set<QName> names) {
    Serializable propValue;
    for (QName propertyName : names) {
        if (propertyName.getNamespaceURI().startsWith(BLUEXML_MODEL_URI)) {
            PropertyDefinition propertyDef = dictionaryService.getProperty(propertyName);
            if (propertyDef != null) { // may happen if propertyName was removed from the
                // current version of the content type
                String propTypeName = propertyDef.getDataType().getJavaClassName();
                if (StringUtils.equalsIgnoreCase(propTypeName, "java.lang.String")) {
                    propValue = makePropertyValue(propertyDef, properties.get(propertyName));
                    if (propValue != null) {
                        String propStr = propValue.toString();
                        if (StringUtils.trimToNull(propStr) != null) {
                            return propStr;
                        }
                    }
                }
            }
        }
    }
    return nodeRef.getId();
}

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

public RepositoryFile internalCreateFolder(final Session session, final Serializable parentFolderId,
        final RepositoryFile folder, final RepositoryFileAcl acl, final String versionMessage)
        throws RepositoryException {
    if (!hasAccess(session, parentFolderId, RepositoryFilePermission.WRITE)) {
        return null;
    }//from www.j a  v  a 2s. co  m
    PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
    JcrRepositoryFileUtils.checkoutNearestVersionableFileIfNecessary(session, pentahoJcrConstants,
            parentFolderId);
    Node folderNode = JcrRepositoryFileUtils.createFolderNode(session, pentahoJcrConstants, parentFolderId,
            folder);
    // create a temporary folder object with correct path for default acl purposes.
    String path = JcrRepositoryFileUtils.getAbsolutePath(session, pentahoJcrConstants, folderNode);
    RepositoryFile tmpFolder = new RepositoryFile.Builder(folder).path(path).build();
    // we must create the acl during checkout
    JcrRepositoryFileAclUtils.createAcl(session, pentahoJcrConstants, folderNode.getIdentifier(),
            acl == null ? defaultAclHandler.createDefaultAcl(tmpFolder) : acl);
    session.save();
    if (folder.isVersioned()) {
        JcrRepositoryFileUtils.checkinNearestVersionableNodeIfNecessary(session, pentahoJcrConstants,
                folderNode, versionMessage);
    }
    JcrRepositoryFileUtils.checkinNearestVersionableFileIfNecessary(session, pentahoJcrConstants,
            parentFolderId,
            Messages.getInstance().getString("JcrRepositoryFileDao.USER_0001_VER_COMMENT_ADD_FOLDER", //$NON-NLS-1$
                    folder.getName(), (parentFolderId == null ? "root" : parentFolderId.toString()))); //$NON-NLS-1$
    return JcrRepositoryFileUtils.nodeToFile(session, pentahoJcrConstants, pathConversionHelper, lockHelper,
            folderNode);
}

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

/**
 * Gets a label built from all non-null text fields found amongst the
 * properties in the BlueXML/* w w w.j a v a2 s  .co m*/
 * namespace. Each value is prefixed with the property's title. e.g.
 * "First Name: John, Last Name: Doe, Hometown: Here-and-There".
 * 
 * @param nodeRef
 * @param properties
 * @param names
 * @return the computed label, or the node id if the label is empty.
 */
private String getLabelForNodeAllText(NodeRef nodeRef, Map<QName, Serializable> properties, Set<QName> names) {
    Serializable propValue;
    String res = "";
    boolean first = true;
    for (QName propertyName : names) {
        if (propertyName.getNamespaceURI().startsWith(BLUEXML_MODEL_URI)) {
            PropertyDefinition propertyDef = dictionaryService.getProperty(propertyName);
            if (propertyDef != null) { // may happen if propertyName was removed from the
                // current version of the content type
                String propTypeName = propertyDef.getDataType().getJavaClassName();
                if (StringUtils.equalsIgnoreCase(propTypeName, "java.lang.String")) {
                    propValue = makePropertyValue(propertyDef, properties.get(propertyName));
                    if (propValue != null) {
                        String propStr = propValue.toString();
                        if (StringUtils.trimToNull(propStr) != null) {
                            if (first == false) {
                                res += ", ";
                            }
                            res += StringUtils.trimToEmpty(getDisplayLabelForProperty(propertyDef)) + ": "
                                    + propStr;
                            first = false;
                        }
                    }
                }
            }
        }
    }
    return StringUtils.trimToNull(res) == null ? nodeRef.getId() : res;
}

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

/**
 * {@inheritDoc}/*ww  w.  j a va 2 s.  c  o  m*/
 */
@Override
public void deleteFileAtVersion(final Serializable fileId, final Serializable versionId) {
    if (isKioskEnabled()) {
        throw new RuntimeException(
                Messages.getInstance().getString("JcrRepositoryFileDao.ERROR_0006_ACCESS_DENIED")); //$NON-NLS-1$
    }

    Assert.notNull(fileId);
    Assert.notNull(versionId);
    jcrTemplate.execute(new JcrCallback() {
        @Override
        public Object doInJcr(final Session session) throws RepositoryException, IOException {
            RepositoryFile fileToBeDeleted = getFileById(fileId);
            // Get repository file info and acl info of parent
            if (fileToBeDeleted != null) {
                RepositoryFileAcl toBeDeletedFileAcl = aclDao.getAcl(fileToBeDeleted.getId());
                // Invoke accessVoterManager to see if we have access to perform this operation
                if (!accessVoterManager.hasAccess(fileToBeDeleted, RepositoryFilePermission.DELETE,
                        toBeDeletedFileAcl, PentahoSessionHolder.getSession())) {
                    return null;
                }
            }
            Node fileToDeleteNode = session.getNodeByIdentifier(fileId.toString());
            session.getWorkspace().getVersionManager().getVersionHistory(fileToDeleteNode.getPath())
                    .removeVersion(versionId.toString());
            session.save();
            return null;
        }
    });
}