Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMS-7919: Editing Page and Viewing Revision History and then Promotin… #104

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -314,28 +314,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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonyDeswal can't we check against cache instead of the db in this method?

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