import org.alfresco.web.ui.common.Utils;
Utils.generateURL(FacesContext.getCurrentInstance(), node, URLMode.CIFS);
Notez le "FacesContext.getCurrentInstance()" qui suppose que l'on se trouve dans une application Faces telle que le client Web d'Alfresco.String path = getPathForNode( tree, linkRef);
path = path.replace( FileName.DOS_SEPERATOR, '/');
// Build the URL file data
StringBuilder urlStr = new StringBuilder();
urlStr.append("[InternetShortcut]rn");
urlStr.append("URL=file://");
urlStr.append( sess.getServer().getServerName());
urlStr.append("/");
urlStr.append( tree.getSharedDevice().getName());
urlStr.append( path);
urlStr.append("rn");
Sinon, j'ai aussi pensé à regarder du côté du "FileFolderService", mais je ne vois pas de méthode qui me permette de récupérer ce que je veux.org.alfresco.web.bean.repository.Node nodeBean = new org.alfresco.web.bean.repository.Node(nodeRef);Le problème, c'est qu'à l'exécution de cette instruction j'ai une exception "FacesContext must not be null" :
16:41:52,140 DEBUG [test.clientAlfresco.TestRecupUrlCifs] Debut Main…
16:42:02,375 ERROR [transform.magick.AbstractImageMagickContentTransformer] ImageMagickContentTransformer not available: Failed to perform ImageMagick transformation:
Execution result:
os: Windows XP
command: imconvert "C:DOCUME~1ADMINI~1LOCALS~1TempAlfrescoImageMagickContentTransformer_init_source_15461.gif" "C:DOCUME~1ADMINI~1LOCALS~1TempAlfrescoImageMagickContentTransformer_init_target_15462.png"
succeeded: false
exit code: 1
out:
err: Cannot run program "imconvert": CreateProcess error=2, Le fichier spécifié est introuvable
16:42:05,375 WARN [remoting.rmi.RmiRegistryFactoryBean] Could not detect RMI registry - creating new one
16:42:08,343 INFO [domain.schema.SchemaBootstrap] Schema managed by database dialect org.hibernate.dialect.MySQLInnoDBDialect.
16:42:09,406 INFO [domain.schema.SchemaBootstrap] No changes were made to the schema.
16:42:11,546 INFO [repo.admin.ConfigurationChecker] The Alfresco root data directory ('dir.root') is: C:applisalfresco-community-tomcat-2.1.0alf_data
16:42:11,640 INFO [admin.patch.PatchExecuter] Checking for patches to apply …
16:42:11,781 INFO [repo.module.ModuleServiceImpl] Found 0 module(s).
16:42:11,953 INFO [service.descriptor.DescriptorService] Alfresco JVM - v1.6.0_02-b06; maximum heap size 63,563MB
16:42:11,968 WARN [service.descriptor.DescriptorService] Alfresco JVM - WARNING - maximum heap size 63,563MB is less than recommended 512MB
16:42:11,968 INFO [service.descriptor.DescriptorService] Alfresco started (Community Network): Current version 2.1.0 (482) schema 64 - Installed version 2.1.0 (482) schema 64
16:42:11,968 ERROR [alfresco.ftp.protocol] FTP Socket error
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:141)
at org.alfresco.filesys.ftp.FTPNetworkServer.run(FTPNetworkServer.java:407)
at java.lang.Thread.run(Thread.java:619)
16:42:24,812 DEBUG [test.clientAlfresco.TestRecupUrlCifs] jcrNode : cm:Alfresco-Tutorial.pdf - /app:company_home/app:guest_home/cm:Alfresco-Tutorial.pdf
16:42:38,375 DEBUG [test.clientAlfresco.TestRecupUrlCifs] companyHomeNode : app:company_home - /app:company_home
16:42:47,531 ERROR [test.clientAlfresco.TestRecupUrlCifs] Exception FacesContext must not be null
java.lang.IllegalArgumentException: FacesContext must not be null
at org.springframework.util.Assert.notNull(Assert.java:113)
at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:50)
at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
at org.alfresco.web.bean.repository.Repository.getServiceRegistry(Repository.java:429)
at org.alfresco.web.bean.repository.Node.getServiceRegistry(Node.java:500)
at org.alfresco.web.bean.repository.Node.<init>(Node.java:95)
at fr.armort.test.clientAlfresco.TestRecupUrlCifs.main(TestRecupUrlCifs.java:79)
16:42:54,515 DEBUG [test.clientAlfresco.TestRecupUrlCifs] Finally…
A quoi cette exception peut-elle être due ? Est-ce que j'ai mal initialisé quelque chose ? public static void main(String[] args) {
logger.debug("Debut Main…");
Session session = null;
try {
ApplicationContext context = ApplicationContextHelper
.getApplicationContext();
// Acces au JCR Repository Alfresco
javax.jcr.Repository repository = (javax.jcr.Repository) context
.getBean("JCR.Repository");
// Connection au workspace par défaut défini par le bean
// JCR.Repository bean
session = repository.login(new SimpleCredentials("admin", "admin"
.toCharArray()));
logger.debug("Acces au noeud de départ");
Node jcrNode = session
.getNodeByUUID("ec76d682-4fb8-11dc-ab5d-1797b02bcb1f");
NodeRef nodeRef = JCRNodeRef.getNodeRef(jcrNode);
logger.debug("jcrNode : " + jcrNode.getName()
+ " - " + jcrNode.getPath());
// Recherche du noeud racine
Node companyHomeNode = session.getRootNode().getNode(
"app:company_home");
NodeRef companyHomeNodeRef = JCRNodeRef.getNodeRef(companyHomeNode);
logger.debug("companyHomeNode : " + companyHomeNode.getName()
+ " - " + companyHomeNode.getPath());
// Recuperation du NodeService
ServiceRegistry serviceRegistry = (ServiceRegistry) context
.getBean(ServiceRegistry.SERVICE_REGISTRY);
NodeService nodeService = serviceRegistry.getNodeService();
// Recherche du chemin CIFS
CIFSServer cifsServer = (CIFSServer) context.getBean("cifsServer");
org.alfresco.web.bean.repository.Node nodeBean = new org.alfresco.web.bean.repository.Node(
nodeRef);
Path nodePath = nodeBean.getNodePath();
DiskSharedDevice diskShare = cifsServer.getConfiguration()
.getPrimaryFilesystem();
String cifsPath = Repository.getNamePath(nodeService, nodePath,
companyHomeNodeRef, "\", "file:///"
+ getCIFSServerPath(cifsServer, diskShare));
logger.debug(" + cifsPath : " + cifsPath);
} catch (Exception e) {
logger.error("Exception " + e.getMessage());
e.printStackTrace();
} finally {
session.logout();
logger.debug("Finally…");
System.exit(0);
}
}
public static String getCIFSServerPath(CIFSServer cifsServer,
DiskSharedDevice diskShare) {
String cifsServerPath;
StringBuilder buf = new StringBuilder(24);
String serverName = cifsServer.getConfiguration().getServerName();
if (serverName != null && serverName.length() != 0) {
buf.append("\\").append(serverName).append("\");
buf.append(diskShare.getName());
}
cifsServerPath = buf.toString();
return cifsServerPath;
}
Je fais mes tests sous Eclipse, dans une simple classe Java avec une méthode main(), et j'ai en référence, le projet SDK AlfrescoEmbedded. J'arrive à parcourir les noeuds avec l'API JCR sans problème, comme en témoigne la sortie du logger.debug.org.alfresco.web.bean.repository.Node nodeBean = new org.alfresco.web.bean.repository.Node(
nodeRef);
Path nodePath = nodeBean.getNodePath();
par :Path nodePath = nodeService.getPath(nodeRef);
comme vous me l'aviez indiqué.Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.