List of usage examples for java.io Serializable toString
public String toString()
From source file:org.pentaho.platform.repository2.unified.fs.FileSystemRepositoryFileDao.java
@Override public RepositoryFile getFileById(Serializable fileId, IPentahoLocale locale) { return getFile(fileId.toString()); }
From source file:com.reactive.hzdfs.cluster.HazelcastClusterServiceBean.java
/** * Register a local add/update entry listener on a given {@linkplain IMap} by name. Only a single listener for a given {@linkplain MapListener} instance would be * registered. So subsequent invocation with the same instance would first remove any existing registration for that instance. * @param keyspace map name// w ww . j a v a2 s .c om * @param listener callback * @return * @throws IllegalAccessException */ public String addLocalEntryListener(Serializable keyspace, MapListener listener) { return hzInstance.addLocalEntryListener(keyspace.toString(), listener); }
From source file:com.github.maoo.indexer.webscripts.NodeDetailsWebScript.java
private Map<String, Pair<String, String>> toStringMap(Map<QName, Serializable> propertyMap) { Map<String, Pair<String, String>> ret = new HashMap<String, Pair<String, String>>(1, 1.0f); for (QName propertyName : propertyMap.keySet()) { Serializable propertyValue = propertyMap.get(propertyName); if (propertyValue != null) { String propertyType = propertyValue.getClass().getName(); String stringValue = propertyValue.toString(); if (propertyType.equals("java.util.Date")) { stringValue = sdf.format(propertyValue); }/*www . j ava 2 s .c o m*/ ret.put(propertyName.toPrefixString(namespaceService), new Pair<String, String>(propertyType, stringValue)); } } return ret; }
From source file:org.nuxeo.ecm.platform.semanticentities.sources.StanbolEntityHubSource.java
@SuppressWarnings("unchecked") @Override/*from ww w .j a va 2s .c o m*/ public List<EntitySuggestion> suggestRemoteEntity(String keywords, String type, int maxSuggestions) throws IOException { // build a field query on the entity hub Map<String, Object> query = new LinkedHashMap<String, Object>(); List<Map<String, String>> constraints = new ArrayList<Map<String, String>>(); String namePropertyUri = descriptor.getMappedProperties().get("dc:title"); Map<String, String> nameTextConstraint = new LinkedHashMap<String, String>(); nameTextConstraint.put("type", "text"); nameTextConstraint.put("field", namePropertyUri); nameTextConstraint.put("text", keywords); constraints.add(nameTextConstraint); if (type != null) { String remoteType = descriptor.getMappedTypes().get(type); if (remoteType == null) { return Collections.emptyList(); } Map<String, String> typeReferenceConstraint = new LinkedHashMap<String, String>(); typeReferenceConstraint.put("type", "reference"); typeReferenceConstraint.put("field", RDF_TYPE); typeReferenceConstraint.put("value", remoteType); constraints.add(typeReferenceConstraint); } List<String> selected = Arrays.asList(namePropertyUri, RDF_TYPE); query.put("selected", selected); query.put("limit", maxSuggestions); query.put("constraints", constraints); String queryPayload = mapper.writeValueAsString(query); InputStream responseStream = doHttpPost(URI.create(endpointURL + "query"), "application/json", "application/json", queryPayload); Map<String, Object> response = mapper.readValue(responseStream, Map.class); List<Map<String, Object>> results = (List<Map<String, Object>>) response.get("results"); if (results == null) { throw new DereferencingException("Stanbol EntityHub is missing a 'response' key: " + response); } List<EntitySuggestion> suggestions = new ArrayList<EntitySuggestion>(); for (Map<String, Object> result : results) { Serializable nameLiteral = readDecodedLiteral(result, namePropertyUri, StringType.INSTANCE, "en"); if (nameLiteral == null) { continue; } String name = nameLiteral.toString(); String uri = result.get("id").toString(); if (type == null) { Set<String> admissibleTypes = getAdmissibleTypes(result); if (admissibleTypes.isEmpty()) { continue; } // primary type assignment is currently arbitrary: planned fix // it to use secondary types with "Entity" as primary types // instead type = admissibleTypes.iterator().next(); } suggestions.add(new EntitySuggestion(name, uri, type)); } return suggestions; }
From source file:org.pentaho.platform.repository2.unified.fs.FileSystemRepositoryFileDao.java
@Override public RepositoryFile getFileById(Serializable fileId, boolean loadLocaleMaps, IPentahoLocale locale) { return getFile(fileId.toString()); }
From source file:org.pentaho.platform.repository2.unified.fs.FileSystemRepositoryFileDao.java
public void deleteFile(Serializable fileId, String versionMessage) { try {//w w w. jav a 2s. c o m File f = new File(fileId.toString()); f.delete(); } catch (Exception e) { // CHECKSTYLES IGNORE } }
From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java
public static void deleteFile(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final ILockHelper lockTokenHelper) throws RepositoryException { Node fileNode = session.getNodeByIdentifier(fileId.toString()); // guard against using a file retrieved from a more lenient session inside a more strict session Assert.notNull(fileNode);//from ww w .jav a 2 s. c om // technically, the node can be locked when it is deleted; however, we want to avoid an orphaned lock token; // delete // it first if (fileNode.isLocked()) { Lock lock = session.getWorkspace().getLockManager().getLock(fileNode.getPath()); // don't need lock token anymore lockTokenHelper.removeLockToken(session, pentahoJcrConstants, lock); } fileNode.remove(); }
From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java
public static RepositoryFile getFileAtVersion(final Session session, final PentahoJcrConstants pentahoJcrConstants, final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable fileId, final Serializable versionId) throws RepositoryException { Node fileNode = session.getNodeByIdentifier(fileId.toString()); Version version = session.getWorkspace().getVersionManager().getVersionHistory(fileNode.getPath()) .getVersion(versionId.toString()); return nodeToFile(session, pentahoJcrConstants, pathConversionHelper, lockHelper, getNodeAtVersion(pentahoJcrConstants, version)); }
From source file:org.alfresco.repo.virtual.VirtualizationIntegrationTest.java
protected void assertVirtualNode(NodeRef nodeRef, Map<QName, Serializable> expectedProperties) { assertTrue(Reference.isReference(nodeRef)); assertTrue(nodeService.hasAspect(nodeRef, VirtualContentModel.ASPECT_VIRTUAL)); Set<QName> aspects = nodeService.getAspects(nodeRef); assertTrue("Smart virtual node missing virtual aspect", aspects.contains(VirtualContentModel.ASPECT_VIRTUAL)); //ACE-5303 injected properties title and description require the titled aspect assertTrue("Smaft virtual node missing titled aspect", aspects.contains(ContentModel.ASPECT_TITLED)); Map<QName, Serializable> nodeProperties = nodeService.getProperties(nodeRef); List<QName> mandatoryProperties = Arrays.asList(ContentModel.PROP_STORE_IDENTIFIER, ContentModel.PROP_STORE_PROTOCOL, ContentModel.PROP_LOCALE, ContentModel.PROP_MODIFIED, ContentModel.PROP_MODIFIER, ContentModel.PROP_CREATED, ContentModel.PROP_CREATOR, ContentModel.PROP_NODE_DBID, ContentModel.PROP_DESCRIPTION); Set<QName> missingPropreties = new HashSet<>(mandatoryProperties); missingPropreties.removeAll(nodeProperties.keySet()); assertTrue("Mandatory properties are missing" + missingPropreties, missingPropreties.isEmpty()); assertFalse("ACE-5303 : ContentModel.PROP_TITLE should remain unset", nodeProperties.containsKey(ContentModel.PROP_TITLE)); Set<Entry<QName, Serializable>> epEntries = expectedProperties.entrySet(); StringBuilder unexpectedBuilder = new StringBuilder(); for (Entry<QName, Serializable> entry : epEntries) { Serializable actualValue = nodeProperties.get(entry.getKey()); Serializable expectedValue = expectedProperties.get(entry.getKey()); boolean fail = false; String expectedValueStr = null; if (expectedValue != null) { expectedValueStr = expectedValue.toString(); if (!expectedValue.equals(actualValue)) { fail = true;/*from w ww . j a va2 s . c o m*/ } } else if (actualValue != null) { fail = true; expectedValueStr = "<null>"; } if (fail) { unexpectedBuilder.append("\n"); unexpectedBuilder.append(entry.getKey()); unexpectedBuilder.append(" expected["); unexpectedBuilder.append(expectedValueStr); unexpectedBuilder.append("] != actua["); unexpectedBuilder.append(actualValue); unexpectedBuilder.append("]"); } } String unexpectedStr = unexpectedBuilder.toString(); assertTrue("Unexpected property values : " + unexpectedStr, unexpectedStr.isEmpty()); }
From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java
public static Object getVersionSummaries(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final boolean includeAclOnlyChanges) throws RepositoryException { Node fileNode = session.getNodeByIdentifier(fileId.toString()); VersionHistory versionHistory = session.getWorkspace().getVersionManager() .getVersionHistory(fileNode.getPath()); // get root version but don't include it in version summaries; from JSR-170 specification section 8.2.5: // [root version] is a dummy version that serves as the starting point of the version graph. Like all version // nodes,// w w w.ja va2 s .c o m // it has a subnode called jcr:frozenNode. But, in this case that frozen node does not contain any state // information // about N Version version = versionHistory.getRootVersion(); Version[] successors = version.getSuccessors(); List<VersionSummary> versionSummaries = new ArrayList<VersionSummary>(); while (successors != null && successors.length > 0) { version = successors[0]; // branching not supported VersionSummary sum = toVersionSummary(pentahoJcrConstants, versionHistory, version); if (!sum.isAclOnlyChange() || (includeAclOnlyChanges && sum.isAclOnlyChange())) { versionSummaries.add(sum); } successors = version.getSuccessors(); } return versionSummaries; }