List of usage examples for java.io Serializable toString
public String toString()
From source file:org.alfresco.repo.audit.PropertyAuditFilter.java
/** * @param rootPath String//w w w. ja v a2s . c o m * @return boolean */ @Override public boolean accept(String rootPath, Map<String, Serializable> auditMap) { String[] root = splitPath(rootPath); String rootProperty = getPropertyName(PROPERY_NAME_PREFIX, getPropertyName(root)); String defaultRootProperty = getDefaultRootProperty(root); if ("true".equalsIgnoreCase(getProperty(rootProperty, defaultRootProperty, ENABLED))) { for (Map.Entry<String, Serializable> entry : auditMap.entrySet()) { Serializable value = entry.getValue(); if (value == null) { value = "null"; } String stringValue = (value instanceof String) ? (String) value : value.toString(); String[] key = splitPath(entry.getKey()); String propertyValue = getProperty(rootProperty, defaultRootProperty, key); if (!acceptValue(stringValue, propertyValue, rootProperty, key)) { if (logger.isDebugEnabled()) { logger.debug("Rejected \n\t " + rootPath + '/' + entry.getKey() + "=" + stringValue + "\n\t" + getPropertyName(rootProperty, getPropertyName(key)) + "=" + propertyValue); } return false; } } } return true; }
From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileAclDao.java
private RepositoryFileAcl toAcl(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$ }/*w ww.j av a 2s . c o m*/ String absPath = node.getPath(); AccessControlManager acMgr = session.getAccessControlManager(); AccessControlList acList = getAccessControlList(acMgr, absPath); RepositoryFileSid owner = null; String ownerString = getOwner(session, absPath, acList); if (ownerString != null) { // for now, just assume all owners are users; only has UI impact owner = new RepositoryFileSid(JcrTenantUtils.getUserNameUtils().getPrincipleName(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) { if (!acEntry.getPrincipal().equals( new SpringSecurityRolePrincipal(JcrTenantUtils.getTenantedRole(tenantAdminAuthorityName)))) { aclBuilder.ace(toAce(session, acEntry)); } } return aclBuilder.build(); }
From source file:org.alfresco.repo.web.scripts.solr.SOLRSerializer.java
public String serializeToJSONString(Serializable value) { if (value != null && typeConverter.INSTANCE.getConverter(value.getClass(), String.class) == null) { // There is no converter return value.toString(); } else {/* w w w . j a va 2 s . c om*/ return typeConverter.INSTANCE.convert(String.class, value); } }
From source file:org.nuxeo.audit.advanced.AdvancedDocumentAuditListener.java
protected String formatPropertyValue(Serializable value) { if (value instanceof Calendar) { Calendar calendar = (Calendar) value; String pattern = "MM/dd/yyyy"; SimpleDateFormat format = new SimpleDateFormat(pattern); return format.format(calendar.getTime()); } else if (value != null) { return value.toString(); } else {//from w w w . ja va2 s . c o m return EMPTY_VALUE; } }
From source file:com.linkedin.pinot.core.query.aggregation.groupby.AggregationGroupByOperatorService.java
private Serializable formatValue(Serializable value) { return (value instanceof Float || value instanceof Double) ? String.format(Locale.US, "%1.5f", value) : value.toString(); }
From source file:no.uka.findmyapp.android.rest.client.RestProcessor.java
private Serializable parseFromJson(String response, Type t1) throws JSONException { Serializable s; if (response.substring(0, 1).equals("[")) { s = parseListFromJson(response, t1); } else {// w ww. j av a 2s . c om Log.v(debug, "executeAndParse: Is not list"); s = (Serializable) mGson.fromJson(response, t1); Log.v(debug, "executeAndParse: Serializable " + s.toString()); } return s; }
From source file:org.pentaho.platform.repository2.unified.fs.FileSystemRepositoryFileDao.java
public RepositoryFile getFileById(Serializable fileId) { return getFile(fileId.toString()); }
From source file:com.bemis.portal.customer.service.impl.CustomerProfileLocalServiceImpl.java
protected String getExpandoValue(Organization org, String attributeName) { String expandoValue = StringPool.BLANK; ExpandoBridge expandoBridge = org.getExpandoBridge(); Serializable serializable = expandoBridge.getAttribute(attributeName, false); if (serializable != null) { expandoValue = serializable.toString(); }/*from w ww. ja va 2 s . c o m*/ return expandoValue; }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.CswMarshallHelper.java
static void writeValue(HierarchicalStreamWriter writer, MarshallingContext context, AttributeDescriptor attributeDescriptor, QName field, Serializable value) { String xmlValue = null;//w w w .j a v a 2 s .c om AttributeType.AttributeFormat attrFormat = null; if (attributeDescriptor != null && attributeDescriptor.getType() != null) { attrFormat = attributeDescriptor.getType().getAttributeFormat(); } if (attrFormat == null) { attrFormat = AttributeType.AttributeFormat.STRING; } String name = null; if (!StringUtils.isBlank(field.getNamespaceURI())) { if (!StringUtils.isBlank(field.getPrefix())) { name = field.getPrefix() + CswConstants.NAMESPACE_DELIMITER + field.getLocalPart(); } else { name = field.getLocalPart(); } } else { name = field.getLocalPart(); } switch (attrFormat) { case BINARY: xmlValue = Base64.getEncoder().encodeToString((byte[]) value); break; case DATE: GregorianCalendar cal = new GregorianCalendar(); cal.setTime((Date) value); xmlValue = XSD_FACTORY.newXMLGregorianCalendar(cal).toXMLFormat(); break; case OBJECT: break; case GEOMETRY: case XML: default: xmlValue = value.toString(); break; } // Write the node if we were able to convert it. if (xmlValue != null) { writer.startNode(name); if (!StringUtils.isBlank(field.getNamespaceURI())) { if (StringUtils.isBlank(field.getPrefix())) { writer.addAttribute(XMLConstants.XMLNS_ATTRIBUTE, field.getNamespaceURI()); } } writer.setValue(xmlValue); writer.endNode(); } }
From source file:com.pentaho.repository.importexport.StreamToJobNodeConverter.java
/** * /*from w ww .j a va2 s . c om*/ * @param fileId * @return */ public InputStream convert(final Serializable fileId) { InputStream is = null; try { if (fileId != null) { Repository repository = connectToRepository(); RepositoryFile file = unifiedRepository.getFileById(fileId); if (file != null) { try { JobMeta jobMeta = repository.loadJob(new StringObjectId(fileId.toString()), null); if (jobMeta != null) { Set<String> privateDatabases = jobMeta.getPrivateDatabases(); if (privateDatabases != null) { // keep only private transformation databases for (Iterator<DatabaseMeta> it = jobMeta.getDatabases().iterator(); it.hasNext();) { String databaseName = it.next().getName(); if (!privateDatabases.contains(databaseName)) { it.remove(); } } } return new ByteArrayInputStream(jobMeta.getXML().getBytes()); } } catch (KettleException e) { logger.error(e); // file is there and may be legacy, attempt simple export SimpleRepositoryFileData fileData = unifiedRepository.getDataForRead(fileId, SimpleRepositoryFileData.class); if (fileData != null) { logger.warn("Reading as legacy CE job " + file.getName() + "."); return fileData.getInputStream(); } } } } } catch (Exception e) { logger.error(e); } return is; }