mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-10659 - CIFS PseudoFiles link hardcoded to Alfresco explorer
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31095 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -386,10 +386,7 @@
|
||||
<property name="renameShufflePattern">
|
||||
<value>${filesystem.renameShufflePattern}</value>
|
||||
</property>
|
||||
<!-- Add a URL file to each folder that links back to the web client -->
|
||||
<property name="URLFileName">
|
||||
<value>__Alfresco.url</value>
|
||||
</property>
|
||||
|
||||
<!-- Mark locked files as offline -->
|
||||
<property name="offlineFiles">
|
||||
<value>true</value>
|
||||
@@ -400,6 +397,27 @@
|
||||
<ref bean="filesystemQuotaManager" />
|
||||
</property>
|
||||
|
||||
<!-- Enables and disables pseudo files - cifs DesktopActions and URL shortcuts. -->
|
||||
<property name="pseudoFilesEnabled">
|
||||
<value>${cifs.pseudoFiles.enabled}</value>
|
||||
</property>
|
||||
|
||||
<!-- Add a pseudo links back to the alfresco explorer -->
|
||||
<property name="alfrescoURLEnabled">
|
||||
<value>${cifs.pseudoFiles.explorerURL.enabled}</value>
|
||||
</property>
|
||||
<property name="URLFileName">
|
||||
<value>${cifs.pseudoFiles.explorerURL.fileName}</value>
|
||||
</property>
|
||||
|
||||
<!-- Add a pseudo links back to the alfresco share -->
|
||||
<property name="shareURLEnabled">
|
||||
<value>${cifs.pseudoFiles.shareURL.enabled}</value>
|
||||
</property>
|
||||
<property name="shareURLFileName">
|
||||
<value>${cifs.pseudoFiles.shareURL.fileName}</value>
|
||||
</property>
|
||||
|
||||
<!-- Desktop actions -->
|
||||
<!-- Uses a client-side application to trigger a server-side action -->
|
||||
<!-- Echo - displays a message echoed from the server -->
|
||||
@@ -468,6 +486,8 @@
|
||||
<property name="defaultAccessLevel"> <value>Write</value> </property> </bean> </property>
|
||||
-->
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- AVM virtualization view of all stores/versions for WCM -->
|
||||
<!-- virtual view stores filter can be any of the following: normal, site, staging, author, preview -->
|
||||
<bean class="org.alfresco.filesys.avm.AVMContext">
|
||||
|
@@ -49,6 +49,17 @@ cifs.WINS.secondary=5.6.7.8
|
||||
# PKTSTATS, THREADPOOL, BENCHMARK
|
||||
cifs.sessionDebug=
|
||||
|
||||
# Big Switch, are the Desktop Actions and URL shortcuts shown for CIFS ?
|
||||
cifs.pseudoFiles.enabled=true
|
||||
|
||||
# CIFS URL for alfresco explorer
|
||||
cifs.pseudoFiles.explorerURL.enabled=true
|
||||
cifs.pseudoFiles.explorerURL.fileName=__Alfresco.url
|
||||
|
||||
# Cifs URL for alfresco share
|
||||
cifs.pseudoFiles.shareURL.enabled=false
|
||||
cifs.pseudoFiles.shareURL.fileName=__Share.url
|
||||
|
||||
### FTP Server Configuration ###
|
||||
ftp.enabled=true
|
||||
ftp.port=21
|
||||
|
@@ -55,6 +55,10 @@ public abstract class AlfrescoContext extends DiskDeviceContext
|
||||
{
|
||||
private SysAdminParams sysAdminParams;
|
||||
|
||||
private boolean pseudoFilesEnabled = false;
|
||||
private boolean isAlfrescoURLEnabled = false;
|
||||
private boolean isShareURLEnabled = false;
|
||||
|
||||
// Debug levels
|
||||
|
||||
public final static int DBG_FILE = 0x00000001; // file/folder create/delete
|
||||
@@ -72,6 +76,7 @@ public abstract class AlfrescoContext extends DiskDeviceContext
|
||||
// URL pseudo file web path prefix (server/port/webapp) and link file name
|
||||
|
||||
private String m_urlFileName;
|
||||
private String m_shareUrlFileName;
|
||||
|
||||
// Pseudo file interface
|
||||
|
||||
@@ -233,20 +238,21 @@ public abstract class AlfrescoContext extends DiskDeviceContext
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the URL pseudo file is enabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean hasURLFile()
|
||||
{
|
||||
if (m_urlFileName != null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Determine if the URL pseudo file is enabled
|
||||
// *
|
||||
// * @return boolean
|
||||
// */
|
||||
// public final boolean hasURLFile()
|
||||
// {
|
||||
// if (m_urlFileName != null)
|
||||
// return true;
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
/**
|
||||
* Return the URL pseudo file path prefix
|
||||
* @deprecated - does not know about share
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@@ -265,6 +271,17 @@ public abstract class AlfrescoContext extends DiskDeviceContext
|
||||
return m_urlFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Share URL pseudo file name
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public final String getShareURLFileName()
|
||||
{
|
||||
return m_shareUrlFileName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the URL pseudo file name
|
||||
*
|
||||
@@ -284,6 +301,25 @@ public abstract class AlfrescoContext extends DiskDeviceContext
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Share URL pseudo file name
|
||||
*
|
||||
* @param urlFileName String
|
||||
*/
|
||||
public final void setShareURLFileName(String urlFileName)
|
||||
{
|
||||
m_shareUrlFileName = urlFileName;
|
||||
|
||||
// URL file name must end with .url
|
||||
if (urlFileName != null)
|
||||
{
|
||||
if (!urlFileName.endsWith(".url"))
|
||||
throw new AlfrescoRuntimeException("URL Share link file must end with .url, " + urlFileName);
|
||||
|
||||
enabledPseudoFileInterface();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the desktop actions
|
||||
*
|
||||
@@ -444,4 +480,34 @@ public abstract class AlfrescoContext extends DiskDeviceContext
|
||||
this.opLockManager = opLockManager;
|
||||
}
|
||||
|
||||
public void setPseudoFilesEnabled(boolean enablePseudoFiles)
|
||||
{
|
||||
this.pseudoFilesEnabled = enablePseudoFiles;
|
||||
}
|
||||
|
||||
public boolean isPseudoFilesEnabled()
|
||||
{
|
||||
return pseudoFilesEnabled;
|
||||
}
|
||||
|
||||
public void setAlfrescoURLEnabled(boolean isAlfrescoURLEnabled)
|
||||
{
|
||||
this.isAlfrescoURLEnabled = isAlfrescoURLEnabled;
|
||||
}
|
||||
|
||||
public boolean isAlfrescoURLEnabled()
|
||||
{
|
||||
return isAlfrescoURLEnabled;
|
||||
}
|
||||
|
||||
public void setShareURLEnabled(boolean isShareURLEnabled)
|
||||
{
|
||||
this.isShareURLEnabled = isShareURLEnabled;
|
||||
}
|
||||
|
||||
public boolean isShareURLEnabled()
|
||||
{
|
||||
return isShareURLEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ public class PseudoFileImpl implements PseudoFileInterface
|
||||
|
||||
// Check if the URL file is enabled
|
||||
|
||||
if ( isPseudo == false && ctx.hasURLFile())
|
||||
if ( isPseudo == false && ctx.isAlfrescoURLEnabled())
|
||||
{
|
||||
// Check if it is the URL file name
|
||||
|
||||
@@ -204,7 +204,7 @@ public class PseudoFileImpl implements PseudoFileInterface
|
||||
|
||||
// Add the URL link pseudo file, if enabled
|
||||
|
||||
if ( isCIFS && ctx.hasURLFile())
|
||||
if ( isCIFS && ctx.isAlfrescoURLEnabled())
|
||||
{
|
||||
// Make sure the state has the associated node details
|
||||
|
||||
|
@@ -26,6 +26,9 @@ import org.alfresco.jlan.server.filesys.pseudo.MemoryPseudoFile;
|
||||
import org.alfresco.jlan.server.filesys.pseudo.PseudoFile;
|
||||
import org.alfresco.jlan.server.filesys.pseudo.PseudoFileList;
|
||||
import org.alfresco.jlan.util.WildCard;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.SysAdminParams;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
@@ -41,6 +44,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* */
|
||||
public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
{
|
||||
private SysAdminParams sysAdminParams;
|
||||
private AlfrescoContext context;
|
||||
private NodeService nodeService;
|
||||
|
||||
@@ -52,6 +56,7 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
{
|
||||
PropertyCheck.mandatory(this, "nodeService", getNodeService());
|
||||
PropertyCheck.mandatory(this, "context", context);
|
||||
PropertyCheck.mandatory(this, "sysAdminParams", sysAdminParams);
|
||||
|
||||
DesktopActionTable actions = context.getDesktopActions();
|
||||
|
||||
@@ -76,9 +81,9 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
}
|
||||
}
|
||||
|
||||
private PseudoFile generateURLShortcut(NodeRef nodeRef)
|
||||
private PseudoFile generateAlfrescoURLShortcut(NodeRef nodeRef)
|
||||
{
|
||||
if ( context.hasURLFile())
|
||||
if ( context.isAlfrescoURLEnabled())
|
||||
{
|
||||
// Make sure the state has the associated node details
|
||||
|
||||
@@ -88,7 +93,7 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
|
||||
urlStr.append("[InternetShortcut]\r\n");
|
||||
urlStr.append("URL=");
|
||||
urlStr.append(context.getURLPrefix());
|
||||
urlStr.append(getAlfrescoURLPrefix());
|
||||
urlStr.append("navigate/browse/workspace/SpacesStore/");
|
||||
urlStr.append( nodeRef.getId());
|
||||
urlStr.append("\r\n");
|
||||
@@ -103,6 +108,109 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the site name if the node ref is in a document library
|
||||
* Return null if the document is not in a site
|
||||
*/
|
||||
// MER URRGH - copied from IMAP service - I don't like it there either!
|
||||
private String getSiteForNode(NodeRef nodeRef)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("get site for node:" + nodeRef);
|
||||
}
|
||||
boolean isInDocLibrary = false;
|
||||
|
||||
NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||
|
||||
while (parent != null && !nodeService.getType(parent).equals(SiteModel.TYPE_SITE))
|
||||
{
|
||||
String parentName = (String) nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
||||
if (parentName.equalsIgnoreCase("documentlibrary"))
|
||||
{
|
||||
isInDocLibrary = true;
|
||||
}
|
||||
|
||||
parent = nodeService.getPrimaryParent(parent).getParentRef();
|
||||
}
|
||||
|
||||
if (parent == null)
|
||||
{
|
||||
logger.debug("folder is not in a site");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isInDocLibrary)
|
||||
{
|
||||
if(nodeService.getType(parent).equals(SiteModel.TYPE_SITE))
|
||||
{
|
||||
String siteName = (String)nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("got a site:" + siteName);
|
||||
}
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
logger.debug("folder is not in doc library");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private PseudoFile generateShareURLShortcut(NodeRef nodeRef)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("generateShareURLShortcut nodeRef" + nodeRef);
|
||||
}
|
||||
if ( context.isShareURLEnabled())
|
||||
{
|
||||
// try
|
||||
// {
|
||||
String site = getSiteForNode(nodeRef);
|
||||
// String site = "wibble";
|
||||
if(site != null)
|
||||
{
|
||||
// Make sure the state has the associated node details
|
||||
// Build the URL file data
|
||||
|
||||
StringBuilder urlStr = new StringBuilder();
|
||||
|
||||
urlStr.append("[InternetShortcut]\r\n");
|
||||
urlStr.append("URL=");
|
||||
urlStr.append(getShareURLPrefix());
|
||||
urlStr.append("page/site/");
|
||||
urlStr.append(site + "/folder-details?nodeRef=");
|
||||
urlStr.append(nodeRef.getStoreRef() + "/");
|
||||
urlStr.append( nodeRef.getId());
|
||||
urlStr.append("\r\n");
|
||||
|
||||
// Create the in memory pseudo file for the URL link
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("generateShareURLShortcut url as string:" + urlStr);
|
||||
}
|
||||
//
|
||||
byte[] urlData = urlStr.toString().getBytes();
|
||||
//
|
||||
MemoryPseudoFile urlFile = new MemoryPseudoFile( context.getShareURLFileName(), urlData);
|
||||
return urlFile;
|
||||
// }
|
||||
}
|
||||
// catch (Throwable t)
|
||||
// {
|
||||
// logger.error("unexpected exception ", t);
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -113,6 +221,22 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
return false;
|
||||
}
|
||||
|
||||
if(context.isAlfrescoURLEnabled())
|
||||
{
|
||||
if(context.getURLFileName().equals(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(context.isShareURLEnabled())
|
||||
{
|
||||
if(context.getShareURLFileName().equals(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(getPseudoFile(parentDir, name) != null)
|
||||
{
|
||||
return true;
|
||||
@@ -136,7 +260,7 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
return null;
|
||||
}
|
||||
|
||||
if(context.hasURLFile())
|
||||
if(context.isAlfrescoURLEnabled())
|
||||
{
|
||||
if(context.getURLFileName().equals(fname))
|
||||
{
|
||||
@@ -144,7 +268,19 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
{
|
||||
logger.debug("returning URL pseudo file");
|
||||
}
|
||||
return generateURLShortcut(parentDir);
|
||||
return generateAlfrescoURLShortcut(parentDir);
|
||||
}
|
||||
}
|
||||
|
||||
if(context.isShareURLEnabled())
|
||||
{
|
||||
if(context.getShareURLFileName().equals(fname))
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("returning Share URL pseudo file");
|
||||
}
|
||||
return generateShareURLShortcut(parentDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,9 +330,19 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
}
|
||||
|
||||
// The URL file is dependent upon the parent dir
|
||||
if(context.hasURLFile())
|
||||
if(context.isAlfrescoURLEnabled())
|
||||
{
|
||||
filterList.addFile(generateURLShortcut(parentDir));
|
||||
filterList.addFile(generateAlfrescoURLShortcut(parentDir));
|
||||
}
|
||||
|
||||
if(context.isShareURLEnabled())
|
||||
{
|
||||
PseudoFile sharePseudoFile = generateShareURLShortcut(parentDir);
|
||||
|
||||
if(sharePseudoFile != null)
|
||||
{
|
||||
filterList.addFile(sharePseudoFile);
|
||||
}
|
||||
}
|
||||
|
||||
return filterList;
|
||||
@@ -219,11 +365,24 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
}
|
||||
|
||||
// The URL file is dependent upon the parent dir
|
||||
if(context.hasURLFile())
|
||||
if(context.isAlfrescoURLEnabled())
|
||||
{
|
||||
if(wildCard.matchesPattern(context.getURLFileName()))
|
||||
{
|
||||
filterList.addFile(generateURLShortcut(parentDir));
|
||||
filterList.addFile(generateAlfrescoURLShortcut(parentDir));
|
||||
}
|
||||
}
|
||||
|
||||
if(context.isShareURLEnabled())
|
||||
{
|
||||
if(wildCard.matchesPattern(context.getShareURLFileName()))
|
||||
{
|
||||
PseudoFile sharePseudoFile = generateShareURLShortcut(parentDir);
|
||||
|
||||
if(sharePseudoFile != null)
|
||||
{
|
||||
filterList.addFile(sharePseudoFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,4 +425,23 @@ public class PseudoFileOverlayImpl implements PseudoFileOverlay
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
private final String getAlfrescoURLPrefix()
|
||||
{
|
||||
return sysAdminParams.getAlfrescoProtocol() + "://" + sysAdminParams.getAlfrescoHost() + ":" + sysAdminParams.getAlfrescoPort() + "/" + sysAdminParams.getAlfrescoContext() + "/";
|
||||
}
|
||||
private final String getShareURLPrefix()
|
||||
{
|
||||
return sysAdminParams.getShareProtocol() + "://" + sysAdminParams.getShareHost() + ":" + sysAdminParams.getSharePort() + "/" + sysAdminParams.getShareContext() + "/";
|
||||
}
|
||||
|
||||
public void setSysAdminParams(SysAdminParams sysAdminParams)
|
||||
{
|
||||
this.sysAdminParams = sysAdminParams;
|
||||
}
|
||||
|
||||
public SysAdminParams getSysAdminParams()
|
||||
{
|
||||
return sysAdminParams;
|
||||
}
|
||||
}
|
||||
|
@@ -601,6 +601,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
PseudoFileOverlayImpl ps = new PseudoFileOverlayImpl();
|
||||
ps.setContext(context);
|
||||
ps.setNodeService(nodeService);
|
||||
ps.setSysAdminParams(context.getSysAdminParams());
|
||||
context.setPseudoFileOverlay(ps);
|
||||
ps.init();
|
||||
}
|
||||
@@ -651,7 +652,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
FileInfo finfo = null;
|
||||
|
||||
// Is the node a pseudo file ?
|
||||
if(session.isPseudoFilesEnabled())
|
||||
if(session.isPseudoFilesEnabled() && ctx.isPseudoFilesEnabled())
|
||||
{
|
||||
String[] paths = FileName.splitPath(path);
|
||||
// lookup parent directory
|
||||
@@ -798,7 +799,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
* Search pseudo files if they are enabled
|
||||
*/
|
||||
PseudoFileList pseudoList = null;
|
||||
if(session.isPseudoFilesEnabled())
|
||||
if(session.isPseudoFilesEnabled() && ctx.isPseudoFilesEnabled())
|
||||
{
|
||||
logger.debug("search pseudo files");
|
||||
pseudoList = ctx.getPseudoFileOverlay().searchPseudoFiles(dirNodeRef, searchFileSpec);
|
||||
@@ -829,11 +830,11 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
}
|
||||
catch (AlfrescoRuntimeException ex)
|
||||
{
|
||||
// Debug
|
||||
// This is an error even though we "handle" it here.
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
if ( logger.isErrorEnabled())
|
||||
{
|
||||
logger.debug("Exception in Start search", ex);
|
||||
logger.error("Exception in Start search", ex);
|
||||
}
|
||||
|
||||
// Convert to a file not found status
|
||||
@@ -862,7 +863,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
int status = FileStatus.Unknown;
|
||||
try
|
||||
{
|
||||
if(session.isPseudoFilesEnabled())
|
||||
if(session.isPseudoFilesEnabled() && ctx.isPseudoFilesEnabled())
|
||||
{
|
||||
String[] paths = FileName.splitPath(name);
|
||||
// lookup parent directory
|
||||
@@ -945,7 +946,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
{
|
||||
String name = params.getPath();
|
||||
|
||||
if(session.isPseudoFilesEnabled())
|
||||
if(session.isPseudoFilesEnabled() && ctx.isPseudoFilesEnabled())
|
||||
{
|
||||
String[] paths = FileName.splitPath(name);
|
||||
// lookup parent directory
|
||||
@@ -1683,7 +1684,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
|
||||
try
|
||||
{
|
||||
if(session.isPseudoFilesEnabled())
|
||||
if(session.isPseudoFilesEnabled() && ctx.isPseudoFilesEnabled())
|
||||
{
|
||||
String[] paths = FileName.splitPath(name);
|
||||
// lookup parent directory
|
||||
@@ -1919,7 +1920,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
try
|
||||
{
|
||||
|
||||
if(sess.isPseudoFilesEnabled())
|
||||
if(sess.isPseudoFilesEnabled() && ctx.isPseudoFilesEnabled())
|
||||
{
|
||||
String[] paths = FileName.splitPath(name);
|
||||
// lookup parent directory
|
||||
|
Reference in New Issue
Block a user