Cannot edit DAM after Replication Workflow Step called from EventListener (AEM 6.4.1) / S7ConfigResolverImpl - workflow

Cannot edit DAM after Replication Workflow Step called from EventListener (AEM 6.4.1) / S7ConfigResolverImpl
I have an EventListener that calls a Workflow in its onEvent() method. That workflow activate an asset, and after complete correctly (it's replicates the content towards publish instance) i'm not being able to edit the image from http://localhost:4502/damadmin#/content/dam. When double click or right click --> open, nothing happens and I see this in error.log:
GET /content/dam/templates.s7config.json HTTP/1.1] com.day.cq.dam.scene7.impl.S7ConfigResolverImpl Get S7Config null for resource /content/dam/someimage.jpg
Likewise, if I go trough http://localhost:4502/siteadmin#/content/dam and double click the asset, opens a dialog correctly (but not the one that appears on /damadmin#/conten/dam when asset works properly).
Piece of EventListener implementation in activate method:
session = repository.loginService("writeService",null);
session.getWorkspace().getObservationManager().addEventListener(this, Event.NODE_ADDED | Event.NODE_MOVED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED, path, true, null, null, false);
session.refresh(true);
Piece of WorkflowProcess implementation in execute method:
Session session = wfSession.adaptTo(Session.class);
ReplicationOptions options = new ReplicationOptions();
options.setSuppressVersions(true);
options.setSynchronous(true);
options.setSuppressStatusUpdate(false);
replicator.replicate(session, ReplicationActionType.ACTIVATE, path, options);
Any thoughts?

Related

How to send events from the dap to the frontend (frame change, breakpoint changes)?

From the Debug Adapter Protocol Specification it is quite clear how to react on frontend changes. For example: when the user selects a frame so the dap backend is getting an event, the user changes a breakpoint, so a SetBreakpointsRequest() is received.
But how to send "insights" to the frontend, for example when the backend recognizes a breakpoint change or a change of active frame by the debugger?
Note: I've directly tried to add them in the backend with the following code - but as long as that was in the debugging did not start and neither output panes nor debugging pane showed any reason.
import * as vscode from "vscode";
var loc = new vscode.Location(vscode.Uri.file(file), new vscode.Position(line,0));
var bp = new vscode.SourceBreakpoint(loc);
vscode.debug.addBreakpoints([bp]);
A debugger adapter can update breakpoints with an event. See https://microsoft.github.io/debug-adapter-protocol/specification#Events_Breakpoint
The event indicates that some information about a breakpoint has changed.
interface BreakpointEvent extends Event {
event: 'breakpoint';
body: {
/**
* The reason for the event.
* Values: 'changed', 'new', 'removed', etc.
*/
reason: 'changed' | 'new' | 'removed' | string;
/**
* The `id` attribute is used to find the target breakpoint, the other
* attributes are used as the new values.
*/
breakpoint: Breakpoint;
};
}
The Breakpoint object contains an id that you can use to reference an existing breakpoint.
A typical scenario for this would be when you start debugging, the code is loaded in your runtime and a breakpoint is automatically moved from a no-code line to the next line with code. This is how the Debug Adapter would signal to the IDE that it needs to update the breakpoint location.
Generally the specification section "Requests" is something that gets initiated by the IDE (usually the user) and the section "Events" is something that gets initiated by the Debug Adapter or the Debugger Engine Backend...
Note, all this is only possible when a debug session is active. If you have some other requirements, that your extension should modify breakpoints and such while there is no active session, or perhaps do something that is not covered by the DAP specification, you will need to implement some extension code and use the vscode.debug API https://code.visualstudio.com/api/references/vscode-api#debug

Roblox Studio - how do I run a script right before game starts?

I'm attempting to create a plugin that fetches additional code from a server before the user plays the game on roblox studio.
Basically, the user will use something like blockly to create luau code on a website and I want to sent that code to roblox studio. I've seen some plugins that fetch new data from a server from time to time and I've been able to do that, but I'd like to see if there's a way to only fetch the new code when the user clicks the play button because it could be expensive to request new data every 5 seconds or so.
Below is a simple plugin that attempts to send a request to the server when the game loads, but the script never goes beyond game.Loaded:Wait()
Main file:
local Request = require(script.Parent.Request)
local URL = "http://localhost:3333"
local toolbar = plugin:CreateToolbar("Test")
local button = toolbar:CreateButton("Test", "Test", "rbxassetid://4458901886")
local isListening = false
local request = Request.new()
local ok
local json
local function onClick ()
isListening = not isListening
if (isListening == false) then
return print("Not listening")
end
print("Listening")
if not game:IsLoaded() then
print(game.Loaded)
game.Loaded:Wait()
print("Game has started")
ok, json = request:Get(URL)
print(ok, json)
end
end
button.Click:Connect(onClick)
Request file:
local Request = {}
Request.__index = Request
function Request.new()
return setmetatable({}, Request)
end
function Request:Get(URL)
local ok, result = pcall(game.HttpService.GetAsync, game.HttpService, URL)
local json = game.HttpService:JSONDecode(result)
return ok, json
end
return Request
There isn't an explicit signal to detect when a game is about to start.
But, whenever you hit the Play button, the Edit session ends and the Play session begins. When a session ends, all of the plugins are unloaded. So you could use the plugin.Unloading signal to detect when the Edit session is ending, but it will also fire when the user closes the place, when you stop play testing, or when the plugin is disabled or uninstalled.
You could combine that signal with the RunService:IsEdit() function so that the behavior only triggers when exiting Edit mode, but this is still a really hazy signal.
So in a Script in your plugin, you could do something like this :
local RunService = game:GetService("RunService")
local Request = require(script.Parent.Request)
local URL = "<YOUR URL>"
-- listen for when sessions end
plugin.Unloading:Connect(function()
-- disregard sessions that aren't Edit Mode
if not RunService:IsEdit() end
return
end
print("Game about to start... maybe. The game might also be closing, or the plugin might be disabled from the PluginManager.")
local ok, json = request:Get(URL)
print(ok, json)
end)
Debugging this may be difficult as the Output console is cleared any time you start a Play session, so you won't see any of your print statements. But if you close the place, your logs will be preserved on the Welcome Screen. Just go View > Output to open the Output window.

Powershell Selenium: Unable to Locate Element on Amazon

I'm trying to create a Selenium script in Powershell that automatically buys something that I tell it to. I've gotten it past finding the item, and clicking the Buy Now button, but then this window pops up and I've tried what seems like 3000 different ways of failing to click the Place your order button. Web code to the right. Appears to be the "turbo-checkout-pyo-button", but finding it by ID, XPath, CSSselector, etc have all failed for me. It's not a wait issue. I've even thrown in an explicit (and overly long) 5 second delay to be sure this field is present and "should" be clickable. Any ideas?
I've tried all of these. They're all followed by $placeYourOrderBtn.click() (and have all failed):
$placeYourOrderBtn = $ChromeDriver.FindElementByXpath("//*[#id='turbo-checkout-pyo-button']")
$placeYourOrderBtn = $ChromeDriver.FindElementByXPath("//*[#id='turbo-checkout-place-order-button']")
$placeYourOrderBtn = $ChromeDriver.FindElementByXPath("//span[text() = Place your order]")
$placeYourOrderBtn = $ChromeDriver.FindElementById("turbo-checkout-place-order-button-announce")
$placeYourOrderBtn = $ChromeDriver.FindElementById("turbo-checkout-pyo-button")
$placeYourOrderBtn = $ChromeDriver.FindElementByCssSelector("#turbo-checkout-pyo-button")
I did this for a windows that sends email. You have to click the button to open the new window, then use "SwitchTo()" to change to the new window.
[void]$Webdriver.SwitchTo().Window($WebDriver.WindowHandles[1])
You may have to read the window handles attribute and query each one to determine which one you need to open.

Wait until a symbol provider is available

I am writing a Go adapter extension for the Test Explorer extension for Visual Studio Code. My extension uses language services from Microsoft's Go extension:
const symbols = await vscode.commands.executeCommand('vscode.executeDocumentSymbolProvider', uri)
However, I have an issue. When I specify extensionDependencies and activationEvents correctly (in package.json), symbols don't initially load (the command returns undefined). If I set activationEvents to * or if I delay for long enough in my activate handler, symbols load. I thought about retrying until the command returns something, but "this file has no symbols" and "there is no symbol provider for this type of document" both return undefined.
Is there a way to delay until a symbol provider has been defined for a specific file extension/language? Waiting for the Go extension to be activated is not enough. I would use GoDocumentSymbolProvider directly, but the extension doesn't export anything.
It looks like it will be possible to add a delay time before your extension is activated. See https://github.com/microsoft/vscode/issues/98083 (Add support to eventually activate an extension on startup). And https://github.com/microsoft/vscode/issues/98990 (Delayed startup activation events).
Will be in v1.46. From v1.46 release notes onStartupFinished activation event:
We now have a new activation event, similar to the already existing *
activation event. The new onStartupFinished activation event should
be used when an extension wishes to be activated sometime soon after
VS Code startup, but not as part of the startup.
However, it is just a hard-coded delay, not based on other events but may still help your situation.
There is a new activation event which looks like e.g. onStartup:1000
or onStartup:5000. This means that the extension wants to be
activated 1000ms or 5000ms after startup. This is very similar to *
activation, but the extension indicates that it can wait a bit.

How to wait for element not to be present anymore

I have a protractor test that navigates to another url, which cannot be found/resolved in my test environment, so I check if the title is not the previous title.
The test is as follows:
it('should navigate to another site in case of click on cancel link', function () {
page.navigate();
page.submit();
protractor.getInstance().ignoreSynchronization = true;
browser.wait(function(){
return element(by.id('submit')).isPresent();
});
page.closePage();
// the title of a 404, dns issue etc is at least different from the previous site:
expect(browser.getTitle()).not.toEqual('MyDummyTitle')
protractor.getInstance().ignoreSynchronization = false;
});
This works in most browsers, but in Internet Explorer I find that it often is not ready navigating to the non-existing page when the expect is fired.
Can I somehow wait for the 'submit' element to be gone, similar to what I do before firing the closePage?
What I do in this cases is an active wait of an element to disappear:
Using a custom waitAbsent() helper function that actively waits for an element to disappear either by becoming invisible or by not being present.
That helper waits up to specTimeoutMs ignoring useless webdriver errors like StaleElementError.
Usage: add require('./waitAbsent.js'); in your onPrepare block or file.
Example to wait for #submit to be gone:
expect(element(by.id('submit')).waitAbsent()).toBeTruthy();