Skip to content

Commit

Permalink
Merge pull request #104 from percussion/Performance-Fix-on-Restore-Re…
Browse files Browse the repository at this point in the history
…vision

CMS-7919: Editing Page and Viewing Revision History and then Promotin…
  • Loading branch information
natechadwick committed Apr 21, 2021
2 parents bc5942a + 37d0cc2 commit f0fd444
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 31 deletions.
8 changes: 5 additions & 3 deletions WebUI/war/plugins/PercRevisionDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@
{
$("#revisionsTable").find(".perc-revisions-restore-img").click(function(){
var revId = $(this).attr("revId");
dialog.remove();
$.PercBlockUI($.PercBlockUIMode.CURSORONLY);
$.PercRevisionService.restoreRevision(itemId,revId,afterRestore);
})
.bind("mouseenter", function(){
Expand Down Expand Up @@ -262,14 +264,14 @@
function afterRestore(status,result)
{
var self = this;

$.unblockUI();
if(status == $.PercServiceUtils.STATUS_ERROR)
{
{
var defaultMsg = $.PercServiceUtils.extractDefaultErrorMessage(result.request);
$.perc_utils.alert_dialog({title: I18N.message("perc.ui.publish.title@Error"), content: defaultMsg});
return;
}
dialog.remove();

$.PercNavigationManager.setReopenAllowed(true);
var item = {
"id": $.PercNavigationManager.getId(),
Expand Down
4 changes: 2 additions & 2 deletions WebUI/war/services/PercRevisionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@
ida[0] = revId;
itemId = ida.join("-");
var url = $.perc_paths.ITEM_PROMOTE_REVISION + "/" + itemId;
$.PercServiceUtils.makeJsonRequest(url,$.PercServiceUtils.TYPE_GET,true,callback);
$.PercServiceUtils.makeJsonRequest(url,$.PercServiceUtils.TYPE_GET,false,callback);
}

function getLastComment(itemId, callback){
var url = $.perc_paths.ITEM_LAST_COMMENT + "/" + itemId;
$.PercServiceUtils.makeRequest(url,$.PercServiceUtils.TYPE_GET,true,callback);
$.PercServiceUtils.makeRequest(url,$.PercServiceUtils.TYPE_GET,false,callback);
}
})(jQuery);

Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ public void preProcessRequest(Object[] params, IPSRequestContext request)
}

// get all owner relationships for the current content id
PSRelationshipDbProcessor processor =
new PSRelationshipDbProcessor(request);
PSRelationshipDbProcessor processor = PSRelationshipDbProcessor.getInstance();
PSRelationshipFilter filter = new PSRelationshipFilter();
int itemId = Integer.parseInt(request
.getParameter(IPSHtmlParameters.SYS_CONTENTID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,28 +337,15 @@ public PSNoContent restoreRevision(@PathParam("id") String id) throws PSItemServ
//If item can't be restored this method throws exception with a business message.
validateItemRestorable(id);

PSComponentSummary sum = workflowHelper.getComponentSummary(id);

//Create a list of ids and add the supplied item id first.
List<String> ids = new ArrayList<String>();
ids.add(id);

//get all the local content items related to that revision and add them to the list.
Set<String> lids = waRelService.getLocalAssets(id);
ids.addAll(lids);

try
{
//prepare the item for promotion
prepareForRestore(id);
contentWs.promoteRevisions(idMapper.getGuids(ids));
//Adjust the relationships
sum = workflowHelper.getComponentSummary(id);
String cid = idMapper.getGuid(sum.getHeadLocator()).toString();
if(lids.size()>0)
{
waRelService.adjustLocalContentRelationships(cid);
}
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ private void filterLinkedItems(Set<Integer> foldersToCheck, Map<Integer, Set<Int
{
PSRequest req = (PSRequest) PSRequestInfo.getRequestInfo(PSRequestInfo.KEY_PSREQUEST);
PSFolderSecurityManager.setCheckFolderPermissions(false);
PSRelationshipDbProcessor relProcessor = new PSRelationshipDbProcessor(req);
PSRelationshipDbProcessor relProcessor = PSRelationshipDbProcessor.getInstance();

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,7 @@ public static Map copyRelatedContent(int fromCid, int fromRid,
params.put(IPSHtmlParameters.SYS_CONTENTID, Integer.toString(fromCid));
params.put(IPSHtmlParameters.SYS_REVISION, Integer.toString(fromRid));

PSRelationshipDbProcessor processor =
new PSRelationshipDbProcessor(request);
PSRelationshipDbProcessor processor = PSRelationshipDbProcessor.getInstance();

Map inlineRelationships = new HashMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ public void relate(String relationshipType, PSLocator owner,
relationshipType);
}

PSRelationshipDbProcessor processor = new PSRelationshipDbProcessor(
data.getRequest());
PSRelationshipDbProcessor processor = PSRelationshipDbProcessor.getInstance();
putRelationship(data, config, -1, owner, dependent,
PSApplicationBuilder.REQUEST_TYPE_VALUE_INSERT, false, processor);
}
Expand Down Expand Up @@ -440,8 +439,7 @@ private boolean processRequest(PSExecutionData data)
String command = getParameter(data.getRequest(),
IPSHtmlParameters.SYS_COMMAND);

PSRelationshipDbProcessor processor = new PSRelationshipDbProcessor(
data.getRequest());
PSRelationshipDbProcessor processor = PSRelationshipDbProcessor.getInstance();

if (command.equals(COMMAND_NAME) ||
command.equals(COMMAND_NAME + "/" + COMMAND_CREATE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,26 @@ public PSComponentSummary[] getChildren(
public PSRelationship checkIfRelationshipAlreadyExists(PSRelationship rel){
PSRelationshipProcessor processor = PSRelationshipProcessor.getInstance();
PSRelationshipFilter filter = new PSRelationshipFilter();
filter.setDependentId(rel.getDependent().getId());
filter.setOwnerId(rel.getOwner().getId());

String name = rel.getConfig().getName();
if (name != null && name.trim().length() > 0)
filter.setName(name);

int ownerId = rel.getOwner().getId();
if (ownerId != -1)
{
int rev = rel.getOwner().getRevision();
filter.setOwner(new PSLocator(ownerId, rev));
}

int dependentId = rel.getDependent().getId();
if (dependentId != -1)
filter.setDependent(new PSLocator(dependentId, rel.getDependent().getRevision()));

String slotId = rel.getProperty(IPSHtmlParameters.SYS_SLOTID);
if (slotId != null && !slotId.trim().isEmpty())
filter.setProperty(IPSHtmlParameters.SYS_SLOTID, slotId + "");

try {
PSRelationshipSet relSet = processor.getRelationships(filter);
for (int i = 0; i < relSet.size(); i++)
Expand Down
3 changes: 1 addition & 2 deletions system/src/com/percussion/relationship/effect/PSPromote.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,7 @@ private void repointRelationships(IPSRequestContext request,
PSRelationshipSet relationshipsToModify = new PSRelationshipSet();
PSRelationshipSet relationshipsToDelete = new PSRelationshipSet();

PSRelationshipDbProcessor processor =
new PSRelationshipDbProcessor(request);
PSRelationshipDbProcessor processor = PSRelationshipDbProcessor.getInstance();

//get all outbound relationships (orig item is the owner item)
PSRelationshipFilter filter = new PSRelationshipFilter();
Expand Down

0 comments on commit f0fd444

Please sign in to comment.