mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
Merged V2.0 to HEAD
5456: (From WCM_DEPLOY) There were many pure conflicts on license headers, one conflict due to CR-LF and some other smaller issues to resolve: ----------------------------------------- Resolved (line endings not cr-lf): root\projects\repository\config\alfresco\public-services-context.xml Reverted: root\projects\web-client\source\web\images\icons\ajax_anim.gif Reverted or Resolved (License text conflicts): svn revert root\projects\jndi-client\source\java\org\alfresco\jndi\JndiTest.java svn resolved root\projects\jndi-client\source\java\org\alfresco\jndi\AVMFileDirContext.java svn revert root\projects\jndi-client\source\java\org\alfresco\jndi\AVMBulkLoader.java svn revert root\projects\jndi-client\source\java\org\alfresco\filter\CacheControlFilter.java svn revert root\projects\jndi-client\source\java\org\alfresco\filter\CacheControlFilterInfoBean.java svn revert -R root\projects\catalina-virtual\source\java\org\alfresco\mbeans svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\context\AVMStandardContext.java svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\loader\AVMWebappClassLoader.java svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\loader\AVMWebappLoader.java svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMResourceBinding.java svn resolved root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMHostConfig.java - why the change in method naming convention? svn resolved root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMHost.java svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\DefaultAVMResourceBinding.java svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\valve\AVMUrlValveTest.java svn resolved root\projects\catalina-virtual\source\java\org\alfresco\catalina\valve\AVMUrlValve.java svn revert root\projects\catalina-virtual\source\java\org\alfresco\catalina\host\AVMHostMatch.java Modified: root\projects\web-client\source\java\org\alfresco\web\ui\wcm\component\UIDeployWebsite.java (Kevin to check line 330) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5484 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -215,4 +215,16 @@ public interface AVMNode
|
||||
* @param other The other node.
|
||||
*/
|
||||
public void copyMetaDataFrom(AVMNode other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the GUID associated with this version.
|
||||
* @return The GUID.
|
||||
*/
|
||||
public String getGuid();
|
||||
|
||||
/**
|
||||
* Set the GUID associated with this version.
|
||||
* @param guid
|
||||
*/
|
||||
public void setGuid(String guid);
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.cmr.avm.AVMReadOnlyException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
/**
|
||||
* Base class for all repository file system like objects.
|
||||
@@ -77,6 +78,11 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
*/
|
||||
private AVMStore fStoreNew;
|
||||
|
||||
/**
|
||||
* The GUID for this version.
|
||||
*/
|
||||
private String fGUID;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
@@ -109,6 +115,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
time,
|
||||
time);
|
||||
fStoreNew = store;
|
||||
fGUID = GUID.generate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,4 +522,20 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
throw new AVMReadOnlyException("Write Operation on R/O Node.");
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMNode#getGuid()
|
||||
*/
|
||||
public String getGuid()
|
||||
{
|
||||
return fGUID;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMNode#setGuid(java.lang.String)
|
||||
*/
|
||||
public void setGuid(String guid)
|
||||
{
|
||||
fGUID = guid;
|
||||
}
|
||||
}
|
||||
|
@@ -193,7 +193,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidStoreRefException("Not Found.", storeRef);
|
||||
throw new InvalidStoreRefException(storeName +":/" + " not found.", storeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", parentRef);
|
||||
throw new InvalidNodeRefException(avmPath + " not found.", parentRef);
|
||||
}
|
||||
catch (AVMExistsException e)
|
||||
{
|
||||
@@ -480,7 +480,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
avmVersionPath.getSecond());
|
||||
if (desc == null)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef);
|
||||
}
|
||||
if (desc.isPlainDirectory())
|
||||
{
|
||||
@@ -794,7 +794,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() +" not found.", nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,7 +821,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
childVersionPath.getSecond());
|
||||
if (child == null)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", childRef);
|
||||
throw new InvalidNodeRefException(childVersionPath.getSecond() + " not found.", childRef);
|
||||
}
|
||||
Pair<Integer, String> parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
|
||||
if (parentVersionPath.getFirst() >= 0)
|
||||
@@ -870,7 +870,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
String [] childPathBase = AVMNodeConverter.SplitBase(childPath);
|
||||
if (childPathBase[0] == null || !childPathBase[0].equals(parentPath))
|
||||
{
|
||||
throw new InvalidNodeRefException("Not a child.", childRef);
|
||||
throw new InvalidNodeRefException(childPath + " not a child of " + parentPath, childRef);
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -887,7 +887,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not found.", childRef);
|
||||
throw new InvalidNodeRefException(childPathBase[1] + " not found in " + childPathBase[0],
|
||||
childRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,7 +945,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef);
|
||||
}
|
||||
Map<QName, Serializable> result = new HashMap<QName, Serializable>();
|
||||
for (QName qName : props.keySet())
|
||||
@@ -1017,7 +1018,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1052,7 +1053,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
avmVersionPath.getSecond());
|
||||
if (desc == null)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef);
|
||||
}
|
||||
if (qName.equals(ContentModel.PROP_CREATED))
|
||||
{
|
||||
@@ -1153,7 +1154,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
AVMNodeDescriptor desc = fAVMService.lookup(-1, avmVersionPath.getSecond());
|
||||
if (desc == null)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef);
|
||||
}
|
||||
if (desc.isPlainFile())
|
||||
{
|
||||
@@ -1171,7 +1172,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1256,7 +1257,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
||||
throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -496,4 +496,12 @@ public class AVMRemoteLocal implements AVMRemote
|
||||
{
|
||||
return fService.getAPath(desc);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.remote.AVMRemote#setGuid(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setGuid(String path, String guid)
|
||||
{
|
||||
fService.setGuid(path, guid);
|
||||
}
|
||||
}
|
||||
|
@@ -1018,4 +1018,13 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable
|
||||
fAuthService.validate(ticket);
|
||||
return fAVMService.getAPath(desc);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.remote.AVMRemoteTransport#setGuid(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setGuid(String ticket, String path, String guid)
|
||||
{
|
||||
fAuthService.validate(ticket);
|
||||
fAVMService.setGuid(path, guid);
|
||||
}
|
||||
}
|
||||
|
@@ -51,6 +51,7 @@ import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@@ -2442,4 +2443,29 @@ public class AVMRepository
|
||||
fLookupCount.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the GUID on a node.
|
||||
* @param path
|
||||
* @param guid
|
||||
*/
|
||||
public void setGuid(String path, String guid)
|
||||
{
|
||||
fLookupCount.set(1);
|
||||
try
|
||||
{
|
||||
String [] pathParts = SplitPath(path);
|
||||
AVMStore store = getAVMStoreByName(pathParts[0]);
|
||||
if (store == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Store not found:" + pathParts[0]);
|
||||
}
|
||||
fLookupCache.onWrite(pathParts[0]);
|
||||
store.setGuid(pathParts[1], guid);
|
||||
}
|
||||
finally
|
||||
{
|
||||
fLookupCount.set(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1458,4 +1458,17 @@ public class AVMServiceImpl implements AVMService
|
||||
AlfrescoTransactionSupport.bindListener(fTransactionListener);
|
||||
fAVMRepository.revert(baseName[0], baseName[1], toRevertTo);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#setGuid(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setGuid(String path, String guid)
|
||||
{
|
||||
if (path == null || guid == null)
|
||||
{
|
||||
throw new AVMBadArgumentException("Illegal Null Argument.");
|
||||
}
|
||||
AlfrescoTransactionSupport.bindListener(fTransactionListener);
|
||||
fAVMRepository.setGuid(path, guid);
|
||||
}
|
||||
}
|
||||
|
@@ -60,6 +60,8 @@ import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.avm.LayeringDescriptor;
|
||||
import org.alfresco.service.cmr.avm.VersionDescriptor;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
@@ -82,6 +84,73 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Test Deployment.
|
||||
*/
|
||||
public void testDeployment()
|
||||
{
|
||||
try
|
||||
{
|
||||
DeploymentService depService = (DeploymentService)fContext.getBean("DeploymentService");
|
||||
setupBasicTree();
|
||||
TestDeploymentCallback callback = new TestDeploymentCallback();
|
||||
fService.createStore("target");
|
||||
DeploymentReport report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
|
||||
System.out.println(report);
|
||||
assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getGuid(),
|
||||
fService.lookup(-1, "target:/a/b/c/foo").getGuid());
|
||||
assertEquals(fService.lookup(-1, "main:/a/b/c/bar").getGuid(),
|
||||
fService.lookup(-1, "target:/a/b/c/bar").getGuid());
|
||||
fService.createFile("main:/a/b", "biz").close();
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, true, callback);
|
||||
System.out.println(report);
|
||||
System.out.println(recursiveList("target", -1, true));
|
||||
assertNull(fService.lookup(-1, "target:/a/b/biz"));
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
|
||||
System.out.println(report);
|
||||
assertEquals(fService.lookup(-1, "main:/a/b/biz").getGuid(),
|
||||
fService.lookup(-1, "target:/a/b/biz").getGuid());
|
||||
fService.removeNode("main:/a/b/c/foo");
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, true, false, callback);
|
||||
System.out.println(report);
|
||||
assertNotNull(fService.lookup(-1, "target:/a/b/c/foo"));
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
|
||||
System.out.println(report);
|
||||
assertNull(fService.lookup(-1, "target:/a/b/c/foo"));
|
||||
fService.removeNode("main:/a/b/c/bar");
|
||||
fService.createDirectory("main:/a/b/c", "bar");
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
|
||||
System.out.println(report);
|
||||
depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target2:/wiggly/diggly", true, false, false, callback);
|
||||
System.out.println(report);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of GUIDs on AVM Nodes.
|
||||
*/
|
||||
public void testGuids()
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
System.out.println(fService.lookup(-1, "main:/a/b/c/foo").getGuid());
|
||||
String guid = GUID.generate();
|
||||
fService.setGuid("main:/a/b/c/foo", guid);
|
||||
assertEquals(guid, fService.lookup(-1, "main:/a/b/c/foo").getGuid());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the revert to version action.
|
||||
*/
|
||||
|
@@ -470,4 +470,11 @@ public interface AVMStore
|
||||
* @param toRevertTo The descriptor of the version to revert to.
|
||||
*/
|
||||
public void revert(String path, String name, AVMNodeDescriptor toRevertTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the GUID on a node.
|
||||
* @param path
|
||||
* @param guid
|
||||
*/
|
||||
public void setGuid(String path, String guid);
|
||||
}
|
||||
|
@@ -58,6 +58,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
/**
|
||||
* A Repository contains a current root directory and a list of
|
||||
@@ -948,6 +949,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.setProperty(name, value);
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -964,6 +966,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.setProperties(properties);
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1014,6 +1017,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.setGuid(GUID.generate());
|
||||
node.deleteProperty(name);
|
||||
}
|
||||
|
||||
@@ -1029,6 +1033,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.setGuid(GUID.generate());
|
||||
node.deleteProperties();
|
||||
}
|
||||
|
||||
@@ -1137,6 +1142,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMWrongTypeException("File Expected.");
|
||||
}
|
||||
node.updateModTime();
|
||||
node.setGuid(GUID.generate());
|
||||
return ((FileNode)node).getContentData(lPath);
|
||||
}
|
||||
|
||||
@@ -1174,6 +1180,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.copyMetaDataFrom(from);
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1197,6 +1204,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
new AVMAspectNameImpl();
|
||||
newName.setNode(node);
|
||||
newName.setName(aspectName);
|
||||
node.setGuid(GUID.generate());
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.save(newName);
|
||||
}
|
||||
|
||||
@@ -1245,6 +1253,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
AVMDAOs.Instance().fAVMNodePropertyDAO.delete(node, name);
|
||||
}
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1279,6 +1288,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.setAcl(acl);
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1355,4 +1365,18 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
PropertyValue value = new PropertyValue(null, toRevertTo.getId());
|
||||
toLink.setProperty(WCMModel.PROP_REVERTED_ID, value);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMStore#setGuid(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setGuid(String path, String guid)
|
||||
{
|
||||
Lookup lPath = lookup(-1, path, true, true);
|
||||
if (lPath == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Path not found: " + path);
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.setGuid(guid);
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.remote.ClientTicketHolder;
|
||||
import org.alfresco.repo.remote.ClientTicketHolderGlobal;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
@@ -72,7 +73,7 @@ public class AVMTestRemote extends TestCase
|
||||
fAuthService = (AuthenticationService)fContext.getBean("authenticationService");
|
||||
fAuthService.authenticate("admin", "admin".toCharArray());
|
||||
String ticket = fAuthService.getCurrentTicket();
|
||||
ClientTicketHolder.SetTicket(ticket);
|
||||
((ClientTicketHolder)fContext.getBean("clientTicketHolder")).setTicket(ticket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -121,6 +121,7 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
@@ -149,6 +150,7 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
@@ -179,6 +181,7 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
|
@@ -719,6 +719,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
indirect,
|
||||
fPrimaryIndirection,
|
||||
@@ -748,6 +749,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
getUnderlying(lPath),
|
||||
fPrimaryIndirection,
|
||||
@@ -788,6 +790,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
indirection,
|
||||
fPrimaryIndirection,
|
||||
|
@@ -165,6 +165,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
getUnderlying(lPath),
|
||||
false,
|
||||
@@ -193,6 +194,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
getUnderlying(lPath),
|
||||
false,
|
||||
@@ -223,6 +225,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
fIndirection,
|
||||
false,
|
||||
|
@@ -375,6 +375,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
@@ -403,6 +404,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
@@ -433,6 +435,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
|
@@ -200,6 +200,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
@@ -228,6 +229,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
@@ -258,6 +260,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
attrs.getModDate(),
|
||||
attrs.getAccessDate(),
|
||||
getId(),
|
||||
getGuid(),
|
||||
getVersionID(),
|
||||
null,
|
||||
false,
|
||||
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentCallback;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
|
||||
|
||||
/**
|
||||
* Trivial deployment callback for testing.
|
||||
* @author britt
|
||||
*/
|
||||
public class TestDeploymentCallback implements DeploymentCallback
|
||||
{
|
||||
public void eventOccurred(DeploymentEvent event)
|
||||
{
|
||||
System.out.println(event);
|
||||
}
|
||||
}
|
@@ -0,0 +1,327 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.avm.actions;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentCallback;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Deploys a website snapshot to a remote server.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class AVMDeploySnapshotAction extends ActionExecuterAbstractBase
|
||||
{
|
||||
public static final String NAME = "avm-deploy-snapshot";
|
||||
|
||||
public static final String PARAM_WEBSITE = "website";
|
||||
public static final String PARAM_TARGET_SERVER = "target-server";
|
||||
public static final String PARAM_DEFAULT_RMI_PORT = "default-rmi-port";
|
||||
public static final String PARAM_REMOTE_USERNAME = "remote-username";
|
||||
public static final String PARAM_REMOTE_PASSWORD = "remote-password";
|
||||
public static final String PARAM_CALLBACK = "deploy-callback";
|
||||
public static final String PARAM_DELAY = "delay";
|
||||
|
||||
private DeploymentService deployService;
|
||||
private ContentService contentService;
|
||||
private NodeService nodeService;
|
||||
|
||||
private static Log logger = LogFactory.getLog(AVMDeploySnapshotAction.class);
|
||||
private static Log delayDeploymentLogger = LogFactory.getLog("alfresco.deployment.delay");
|
||||
|
||||
/**
|
||||
* @param service The NodeService instance
|
||||
*/
|
||||
public void setNodeService(NodeService service)
|
||||
{
|
||||
this.nodeService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentService The ContentService instance
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param service The AVM Deployment Service instance
|
||||
*/
|
||||
public void setDeploymentService(DeploymentService service)
|
||||
{
|
||||
deployService = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_WEBSITE, DataTypeDefinition.NODE_REF, true,
|
||||
getParamDisplayLabel(PARAM_WEBSITE)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_TARGET_SERVER, DataTypeDefinition.TEXT, true,
|
||||
getParamDisplayLabel(PARAM_TARGET_SERVER)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_DEFAULT_RMI_PORT, DataTypeDefinition.INT, true,
|
||||
getParamDisplayLabel(PARAM_DEFAULT_RMI_PORT)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_REMOTE_USERNAME, DataTypeDefinition.TEXT, true,
|
||||
getParamDisplayLabel(PARAM_REMOTE_USERNAME)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_REMOTE_PASSWORD, DataTypeDefinition.TEXT, true,
|
||||
getParamDisplayLabel(PARAM_REMOTE_PASSWORD)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_CALLBACK, DataTypeDefinition.ANY, false,
|
||||
getParamDisplayLabel(PARAM_CALLBACK)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_DELAY, DataTypeDefinition.INT, false,
|
||||
getParamDisplayLabel(PARAM_DELAY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// the actionedUponNodeRef is the path of the sandbox to deploy
|
||||
Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
|
||||
int version = avmVersionPath.getFirst();
|
||||
String path = avmVersionPath.getSecond();
|
||||
|
||||
// get store name and path parts.
|
||||
String [] storePath = path.split(":");
|
||||
if (storePath.length != 2)
|
||||
{
|
||||
throw new AVMSyncException("Malformed source path: " + path);
|
||||
}
|
||||
|
||||
// get the NodeRef representing the website being deployed
|
||||
NodeRef websiteRef = (NodeRef)action.getParameterValue(PARAM_WEBSITE);
|
||||
if (this.nodeService.exists(websiteRef) == false)
|
||||
{
|
||||
throw new IllegalStateException("The website NodeRef (" + websiteRef +
|
||||
") provided does not exist!");
|
||||
}
|
||||
|
||||
// get the callback object
|
||||
DeploymentCallback callback = (DeploymentCallback)action.getParameterValue(PARAM_CALLBACK);
|
||||
|
||||
// get the remote machine
|
||||
String targetServer = (String)action.getParameterValue(PARAM_TARGET_SERVER);
|
||||
String remoteUsername = (String)action.getParameterValue(PARAM_REMOTE_USERNAME);
|
||||
String remotePassword = (String)action.getParameterValue(PARAM_REMOTE_PASSWORD);
|
||||
int defaultRmiPort = (Integer)action.getParameterValue(PARAM_DEFAULT_RMI_PORT);
|
||||
int delay = -1;
|
||||
if (action.getParameterValue(PARAM_DELAY) != null)
|
||||
{
|
||||
delay = (Integer)action.getParameterValue(PARAM_DELAY);
|
||||
}
|
||||
|
||||
// if "localhost" is passed as the target server add "live" to the end of the
|
||||
// store name, this store will then get created automatically.
|
||||
String targetPath = null;
|
||||
if (targetServer.equalsIgnoreCase("localhost") || targetServer.equalsIgnoreCase("127.0.0.1"))
|
||||
{
|
||||
targetPath = storePath[0] + "live:" + storePath[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Check that the actual host name of the machine hasn't been passed
|
||||
|
||||
targetPath = path;
|
||||
}
|
||||
|
||||
// take a note of the current date/time
|
||||
Date startDate = new Date();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Starting deployment of " + actionedUponNodeRef.toString() +
|
||||
" to " + targetServer + " at " + startDate);
|
||||
|
||||
if (delayDeploymentLogger.isDebugEnabled() && delay > 0)
|
||||
{
|
||||
delayDeploymentLogger.debug("Delaying deployment by " + delay + "s...");
|
||||
|
||||
// add a delay for testing purposes if the delay logger level is debug
|
||||
try { Thread.sleep(1000*delay); } catch (Throwable e) {}
|
||||
}
|
||||
|
||||
// make the deploy call passing in the DeploymentCallback, if present
|
||||
Throwable deployError = null;
|
||||
DeploymentReport report = null;
|
||||
try
|
||||
{
|
||||
int port = defaultRmiPort;
|
||||
|
||||
// check whether there is a port number present, if so, use it
|
||||
int idx = targetServer.indexOf(":");
|
||||
if (idx != -1)
|
||||
{
|
||||
String strPort = targetServer.substring(idx+1);
|
||||
port = Integer.parseInt(strPort);
|
||||
}
|
||||
|
||||
// TODO: we need to capture username/password for the remote server at some
|
||||
// point, for now we use the admin/admin account, need to externalise this too!
|
||||
report = this.deployService.deployDifference(version, path, targetServer, port,
|
||||
remoteUsername, remotePassword, targetPath, true, false, false, callback);
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
deployError = err;
|
||||
logger.error(deployError);
|
||||
|
||||
// report the error to the callback object
|
||||
// TODO: See if this can be incorporated into the DeploymentCallback I/F
|
||||
if (callback != null)
|
||||
{
|
||||
// to avoid a circular dependency use reflection to call the method
|
||||
try
|
||||
{
|
||||
Method method = callback.getClass().getMethod("errorOccurred", new Class[] {Throwable.class});
|
||||
if (method != null)
|
||||
{
|
||||
method.invoke(callback, new Object[] {err});
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
logger.warn("Failed to inform deployment monitor of deployment failure", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (report != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Differences successfully applied to " + targetServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Failed to apply differences to " + targetServer);
|
||||
}
|
||||
|
||||
// create the deployment report node
|
||||
createDeploymentReportNode(report, (String)action.getParameterValue(PARAM_TARGET_SERVER),
|
||||
version, websiteRef, startDate, deployError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a deployment report node as a child of the given website.
|
||||
*
|
||||
* @param report The DeploymentReport result from the deploy,
|
||||
* will be null if the deploy failed
|
||||
* @param targetServer The server the deploy was going to
|
||||
* @param version The version of the site bebing deployed (the snapshot)
|
||||
* @param websiteRef The NodeRef of the folder representing the website
|
||||
* @param startDate The date/time the deployment started
|
||||
* @param error The error that caused the deployment to fail, null if the
|
||||
* deployment was successful
|
||||
* @return The created deployment report NodeRef
|
||||
*/
|
||||
private NodeRef createDeploymentReportNode(DeploymentReport report, String targetServer,
|
||||
int version, NodeRef websiteRef, Date startDate, Throwable error)
|
||||
{
|
||||
NodeRef reportRef = null;
|
||||
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4, 1.0f);
|
||||
props.put(ContentModel.PROP_NAME, targetServer.replace(':', '_') + " deployment report.txt");
|
||||
props.put(WCMAppModel.PROP_DEPLOYSERVER, targetServer);
|
||||
props.put(WCMAppModel.PROP_DEPLOYVERSION, version);
|
||||
props.put(WCMAppModel.PROP_DEPLOYSTARTTIME, startDate);
|
||||
props.put(WCMAppModel.PROP_DEPLOYENDTIME, new Date());
|
||||
props.put(WCMAppModel.PROP_DEPLOYSUCCESSFUL, (report != null));
|
||||
if (report == null && error != null)
|
||||
{
|
||||
// add error message as fail reason if appropriate
|
||||
props.put(WCMAppModel.PROP_DEPLOYFAILEDREASON, error.getMessage());
|
||||
}
|
||||
reportRef = this.nodeService.createNode(websiteRef,
|
||||
WCMAppModel.ASSOC_DEPLOYMENTREPORT, WCMAppModel.ASSOC_DEPLOYMENTREPORT,
|
||||
WCMAppModel.TYPE_DEPLOYMENTREPORT, props).getChildRef();
|
||||
ContentWriter writer = contentService.getWriter(reportRef, ContentModel.PROP_CONTENT, true);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.setEncoding("UTF-8");
|
||||
|
||||
if (report == null)
|
||||
{
|
||||
if (error == null)
|
||||
{
|
||||
writer.putContent("");
|
||||
}
|
||||
else
|
||||
{
|
||||
// add the full stack trace of the error as the content
|
||||
StringWriter stack = new StringWriter();
|
||||
PrintWriter stackPrint = new PrintWriter(stack);
|
||||
error.printStackTrace(stackPrint);
|
||||
writer.putContent(stack.toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: revisit this, is it better to stream to a temp file?
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (DeploymentEvent event : report)
|
||||
{
|
||||
builder.append(event.getType());
|
||||
builder.append(" ");
|
||||
builder.append(event.getDestination());
|
||||
builder.append("\r\n");
|
||||
}
|
||||
|
||||
writer.putContent(builder.toString());
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created deplyoment report node (" + reportRef + ") for targetServer " +
|
||||
targetServer);
|
||||
|
||||
return reportRef;
|
||||
}
|
||||
}
|
@@ -32,6 +32,7 @@
|
||||
won't cause violations in the db during saves. -->
|
||||
<property name="versionID" type="int" column="version_id"
|
||||
not-null="true"/>
|
||||
<property name="guid" type="string" length="36" column="guid" not-null="true"/>
|
||||
<component name="basicAttributes" class="BasicAttributesImpl">
|
||||
<property name="creator" type="string" not-null="true"/>
|
||||
<property name="owner" type="string" not-null="true"/>
|
||||
|
Reference in New Issue
Block a user