Java Code Examples for org.alfresco.service.cmr.repository.StoreRef#toString()
The following examples show how to use
org.alfresco.service.cmr.repository.StoreRef#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectIdLuceneBuilder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
private <Q, S, E extends Throwable> String getValueAsString(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value) { String nodeRefStr = null; if(!NodeRef.isNodeRef((String)value)) { // assume the object id is the node guid StoreRef storeRef = getStore(lqpa); nodeRefStr = storeRef.toString() + "/" + (String)value; } else { nodeRefStr = (String)value; } Object converted = DefaultTypeConverter.INSTANCE.convert(dictionaryService.getDataType(DataTypeDefinition.NODE_REF), nodeRefStr); String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); return asString; }
Example 2
Source File: ParentLuceneBuilder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
private <Q, S, E extends Throwable> String getValueAsString(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value) { String nodeRefStr = (String)value; if(!NodeRef.isNodeRef((String)value)) { // assume the value (object id) is the node guid StoreRef storeRef = getStore(lqpa); nodeRefStr = storeRef.toString() + "/" + (String)value; } Object converted = DefaultTypeConverter.INSTANCE.convert(dictionaryService.getDataType(DataTypeDefinition.NODE_REF), nodeRefStr); String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); return asString; }
Example 3
Source File: RepoAdminServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private void deployMessageResourceFile(String bundleBasePath, String name, InputStream resourceStream, boolean registerResourceBundle) { // Check that all the passed values are not null ParameterCheck.mandatory("BundleBasePath", bundleBasePath); ParameterCheck.mandatory("Name", name); ParameterCheck.mandatory("ResourceStream", resourceStream); try { Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); contentProps.put(ContentModel.PROP_NAME, name); StoreRef storeRef = repoMessagesLocation.getStoreRef(); NodeRef rootNode = nodeService.getRootNode(storeRef); List<NodeRef> nodeRefs = searchService.selectNodes(rootNode, repoMessagesLocation.getPath(), null, namespaceService, false); if (nodeRefs.size() == 0) { throw new AlfrescoRuntimeException(MESSAGES_LOCATION_NOT_FOUND, new Object[] { repoMessagesLocation.getPath() }); } else if (nodeRefs.size() > 1) { // unexpected: should not find multiple nodes with same name throw new AlfrescoRuntimeException(MESSAGES_LOCATION_MULTIPLE_FOUND, new Object[] { repoMessagesLocation.getPath() }); } NodeRef customLabelsNodeRef = nodeRefs.get(0); ChildAssociationRef association = nodeService.createNode(customLabelsNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps); NodeRef content = association.getChildRef(); // add titled aspect (for Web Client display) Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(); titledProps.put(ContentModel.PROP_TITLE, name); titledProps.put(ContentModel.PROP_DESCRIPTION, name); nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProps); // add inline-editable aspect Map<QName, Serializable> editProps = new HashMap<QName, Serializable>(1, 1.0f); editProps.put(ApplicationModel.PROP_EDITINLINE, true); nodeService.addAspect(content, ApplicationModel.ASPECT_INLINEEDITABLE, editProps); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding("UTF-8"); writer.putContent(resourceStream); resourceStream.close(); if (registerResourceBundle == true) { String bundleBaseName = null; int idx = bundleBasePath.lastIndexOf("/"); if ((idx != -1) && (idx != bundleBasePath.length() - 1)) { bundleBaseName = bundleBasePath.substring(idx+1); } else { bundleBaseName = bundleBasePath; } String repoBundlePath = storeRef.toString() + repoMessagesLocation.getPath() + "/cm:" + bundleBaseName; messageService.registerResourceBundle(repoBundlePath); } logger.info("Message resource deployed: " + name); } catch (Throwable e) { throw new AlfrescoRuntimeException("Message resource deployment failed", e); } }
Example 4
Source File: RepoAdminServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void undeployMessageBundle(String bundleBaseName) { checkBundleBaseName(bundleBaseName); try { StoreRef storeRef = repoMessagesLocation.getStoreRef(); // unregister bundle String repoBundlePath = storeRef.toString() + repoMessagesLocation.getPath() + "/cm:" + bundleBaseName; messageService.unregisterResourceBundle(repoBundlePath); NodeRef rootNode = nodeService.getRootNode(storeRef); List<NodeRef> nodeRefs = searchService.selectNodes(rootNode, repoMessagesLocation.getPath()+CRITERIA_ALL, null, namespaceService, false); boolean found = false; for (NodeRef nodeRef : nodeRefs) { String resourceName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); if (bundleBaseName.equals(messageService.getBaseBundleName(resourceName))) { // remove message resource file from the repository nodeService.deleteNode(nodeRef); found = true; // continue to undeploy any others } } if (found) { logger.info("Message resources undeployed: " + bundleBaseName); } else { throw new AlfrescoRuntimeException(MSG_RESOURCES_NOT_FOUND, new Object[] { repoBundlePath }); } } catch (Throwable t) { throw new AlfrescoRuntimeException(MSG_RESOURCES_UNDEPLOYMENT_FAILED, t); } }
Example 5
Source File: RepoAdminServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void reloadMessageBundle(String bundleBaseName) { checkBundleBaseName(bundleBaseName); try { StoreRef storeRef = repoMessagesLocation.getStoreRef(); // re-register bundle String repoBundlePath = storeRef.toString() + repoMessagesLocation.getPath() + "/cm:" + bundleBaseName; NodeRef rootNode = nodeService.getRootNode(storeRef); List<NodeRef> nodeRefs = searchService.selectNodes(rootNode, repoMessagesLocation.getPath()+CRITERIA_ALL, null, namespaceService, false); boolean found = false; for (NodeRef nodeRef : nodeRefs) { String resourceName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); if (bundleBaseName.equals(messageService.getBaseBundleName(resourceName))) { found = true; break; } } if (found) { messageService.unregisterResourceBundle(repoBundlePath); messageService.registerResourceBundle(repoBundlePath); logger.info("Message resources re-loaded: " + bundleBaseName); } else { throw new AlfrescoRuntimeException(MSG_RESOURCES_NOT_FOUND, new Object[] { repoBundlePath }); } } catch (Throwable e) { throw new AlfrescoRuntimeException(MSG_RESOURCES_RELOAD_FAILED, e); } }