How can I make Plone portal registries find and cook new-style static resources? - resources

All JS I register with an id such as ++theme++mythemename/js/myscript.js gives me the following error on portal_javascripts: (resource not found or not accessible)
I know the id is correct because I can access localhost/mysite/++theme++mythemename/js/myscript.js (even if Diazo is disabled).
If development mode is on the resource gets delivered on the final HTML. However on production mode cooking process fails silently. Or almost. Besides getting a different cachekey than the one showed on portal_javascripts/manage_jsComposition, I see the following error message by accessing the cooked file:
/* XXX ERROR -- access to '++theme++mythemename/js/myscript.js' not authorized */
Any hints on how to deal with those? Or will I really need to leave them uncooked?

Have you tried a browser:resourceDirectory instead of a plone:static ?
<browser:resourceDirectory
name="yourJsFolder"
directory="yourJsFolder"
layer=".interfaces.IThemeSpecific"
/>
and calling your js with :
++resource++yourJsFolder/yourJsFile.js

i added your observatorio.tema package to an existing plone 4.1 buildout and added a random js file to the js registry (positioned after collapsibleformfields.js so it gets properly cooked)
GS export looks like:
<javascript authenticated="False" cacheable="True" compression="safe"
conditionalcomment="" cookable="True" enabled="True" expression=""
id="++theme++observatorio/js/ui.js" inline="False" insert-after="collapsibleformfields.js"/>
no error in portal_jacascripts and the javascript file is included in /jquery-cachekey-e7bee35d43da7a91eb29c6586dcbd396.js
did you add cacheable="False" and cookable="False" for testing purposes?
https://github.com/observatoriogenero/observatorio.tema/blob/master/src/observatorio/tema/profiles/default/jsregistry.xml#L373
since plone:static internally is a resourceDirectory both should and do work with resourceregistries.
maybe there is some other code in your buildout that re-registers another (empty) directory for the same name (observatorio)?

Related

Linux Command Output to Chef Attribute

The issue is I need to assign the value of Linux command to CHef Attribute.But unable to do it.
Im using the below code and not finding the result. Kindly Help what im
missing
ruby_block "something" do
block do
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
node.default['foo'] = shell_out("echo Hello world").stdout
end
action :create
end
log "demo" do
message lazy { node['foo'] }
end
Below is the Run logs:
Starting Chef Client, version 13.9.1
resolving cookbooks for run list: ["sample_repo"]
Synchronizing Cookbooks:
- sample_repo (0.1.4)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: sample_repo::default
* ruby_block[something] action create
- execute the ruby block something
* log[demo] action write
Running handlers:
Running handlers complete
Chef Client finished, 2/2 resources updated in 02 seconds
Thanks in advance
Your code is fine, the log message is not showing because the default level on the log resource is :info and by default chef-client doesn't show info-level log messages when run interactively. That said, this kind of code where you store stuff in node attributes is very brittle and probably shouldn't be used unless specifically needed. Better is to do this:
message lazy { shell_out("echo Hello world").stdout }
Also you don't need any funky mutating include stuff like you there AFAIK, the shell_out helpers are available in most contexts by default. Also you should usually use shell_out!() rather than shell_out(), the ! version automatically raises an exception if the command fails. Unless you specifically want to allow a failed command, use the ! version.

React FacebookAuth Error: FB.login() called before FB.init()

I'm using the admin-on-rest npm package starter project and trying to plug in a simple SSO Facebook login button using the FacebookAuth npm package. Every time I try to click the "Login" button, I get the following error:
FB.login() called before FB.init()
I'm using an .env file with the following variable: REACT_APP_FACEBOOK_APP_ID and setting it to the right value. I even did console.log() within my app and can see it output.
I checked and I'm only loading the FB SDK once, not multiple times (this was a common issue reported on other threads).
Ok, it turned out to be something pretty dumb, but something to point out nonetheless!
In my .env file, I had accidentally placed a semicolon (;) at the end of the declaration, like this:
REACT_APP_FACEBOOK_APP_ID = XXXXXXXXXXXX;
Apparently .env files do NOT like semi-colons. This was just very difficult to figure out from the error above.
So if any of you want to pull your hair out because of this issue, and you're using similar tech, check to make sure you're syntactically kosher EVERYWHERE variables are being declared.
the funny thing was i forgot to replace your-app-id with my app id:
<script>
FB.init({
appId: 'your-app-id',
autoLogAppEvents: true,
xfbml: true,
version: 'v8.0'
});
</script>

How to selectively apply JavaScript block based on profile in JHipster

I try to include HeapAnalytics javascript block in index.html.
HeapAnalytics gives me two version of javascript block, one meant for development and one for production. It looks like this:
// dev
<script>xxxx</script>
// prod
<script>yyyy</script>
I want to know how to include the right one when I use "-Dspring.profiles.active=prod"?
Currently I do it manually, which is error prone.
This information can be obtained in the http header, X-Application-Context, which is returned by the server. For example, the following were returned for prod and dev profiles, respectively:
X-Application-Context:application:prod:8080
or
X-Application-Context:application:dev:8080

GitLab - Getting 404 (Not Found) for /assets/ace/mode-markdown.js

I am getting the following error from GitLab while editing the code online.
GET http://git.server.local/assets/ace/mode-markdown.js 404 (Not Found) application-c8cd2dd87cbf8a023b21baf4d6996ac9.js:26
t.loadScript application-c8cd2dd87cbf8a023b21baf4d6996ac9.js:26
t.loadModule application-c8cd2dd87cbf8a023b21baf4d6996ac9.js:26
setMode application-c8cd2dd87cbf8a023b21baf4d6996ac9.js:27
(anonymous function)
Has anyone encountered such an error? I wonder why an asset without a hash is being requested by the app.
It is an Omnibus install.
I prepared a fix here. This also adds syntax highlighting when creating a new file in the repository or a new snippet.
Until it is properly resolved at some point in time, I have gotten the error resolved by copying the "ace" folder from the ace-rails-ap repository to the GitLab public/assets folder.
https://github.com/codykrieger/ace-rails-ap/tree/master/vendor/assets/javascripts
It seems the asset is requested by the following Javascript that gets inline with the code.
Probably introduced in this commit https://github.com/gitlabhq/gitlabhq/commit/1794f606bd74ae775cd10a3f7da293fb67134c1c
# gitlab-ce.git/app/views/projects/edit_tree/show.html.haml
:javascript
ace.config.set("modePath", gon.relative_url_root + "#{Gitlab::Application.config.assets.prefix}/ace")
var ace_mode = "#{#blob.language.try(:ace_mode)}";
var editor = ace.edit("editor");
editor.setValue("#{escape_javascript(#blob.data)}");
if (ace_mode) {
editor.getSession().setMode('ace/mode/' + ace_mode);
}
Since the inline Javascript does not know anything about Rails asset management, it is assuming that the file would be there in assets folder.

Mule - How to send SOAP Web Service Request?

Hi i am doing simple POC in mule.
I have a web service and i want to make it's Client.
It is SOAP web service and i want to send request to it but i am not getting wayout. Please give me some idea.
Following is code:
MULE:
<cxf:configuration name="CXF_Configuration" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/>
<flow name="prjvm1" doc:name="prjvm1">
<http:inbound-endpoint address="http://localhost:5678/httpHello" contentType="application/x-www-form-urlencoded" doc:name="HTTP">
<http:body-to-parameter-map-transformer />
</http:inbound-endpoint>
<!-- This logger is just set to show the message accepted from the request -->
<logger level="INFO" message="#[payload]" doc:name="Logger"/>
<cxf:jaxws-client doc:name="VimService"
wsdlLocation="file:/C:/Users/gugla/MuleStudio/workspace/prjvm/bin/service/vService.wsdl"
operation="retrieveServiceContent"
clientClass="com.esxclient.VService"
port="VimPort">
<cxf:jaxb-databinding/>
</cxf:jaxws-client>
<outbound-endpoint address="http://localhost:8080/gep-sped/servicos/ServicoDeCadastroEAgendamento"
doc:name="Generic"
exchange-pattern="request-response"/>
<echo-component doc:name="Echo"/>
</flow>
I am getting exception, but operation is there in WSDL
Message : No such operation: retrieveServiceContent. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ManagedObjectReference
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. No such operation: retrieveServiceContent (java.lang.Exception)
org.mule.module.cxf.CxfOutboundMessageProcessor:282 (null)
2. No such operation: retrieveServiceContent. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ManagedObjectReference (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.Exception: No such operation: retrieveServiceContent
at org.mule.module.cxf.CxfOutboundMessageProcessor.getOperation(CxfOutboundMessageProcessor.java:282)
at org.mule.module.cxf.CxfOutboundMessageProcessor.getMethodFromOperation(CxfOutboundMessageProcessor.java:322)
at org.mule.module.cxf.CxfOutboundMessageProcessor.getMethod(CxfOutboundMessageProcessor.java:259)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
Following is WSDL in operation: I am confused and around 4 days on it as i am new to mule.
<operation name="RetrieveServiceContent">
<input message="vim2:RetrieveServiceContentRequestMsg" />
<output message="vim2:RetrieveServiceContentResponseMsg" />
<fault name="RuntimeFault" message="vim2:RuntimeFaultFaultMsg"/>
</operation>
There are a couple of ways to do this. I prefer to NOT us the way MuleStudio wants you to do it since I never really got that to work. Basically, whenever I create a webservice client my mule-config looks something like this:
<custom-transformer class="nl.thorax.someprogram.transformers.SomeRequestTransformer
<https:outbound-endpoint ref="someEndpoint" >
<cxf:jaxws-client
clientClass="nl.thorax.someprogram.someclass"
wsdlLocation="http://somedomain?wsdl
port="somePort"
operation="someOperation"/>
</https:outbound-endpoint>
<custom-transformer class="nl.thorax.someprogram.transformers.SomeResponseTransformer
Where:
SomeRequestTransformer: a transformer to create your request.
someEndpoint: some endpoint defined in your MuleConfig. In my example, this is https but it could also be plain http.
someclass: Important! This is your client class. It can be generated from a WSDL by free tools like Apache's WSDL2Java. Google is your friend on this.
somePort: The port in your webservice to use. It can usually be found in the WSDL itself or in the client class you generated. The port more or less specifies what operations you can use.
someOperation: The operation you want to use. Make sure it is typed EXACTLY the same as it's definition in the client class. Wrong use of cApItAlS will cause errors!
SomeResponseTransformer: a transformer to do something with your response.
Now, the way I configure the call (and parse the response for that matter) is to use POJOs. My first transformer, the SomeRequestTransformer (based on the AbstractMessageTransformer in the Mule library) has a bit of code looking like this:
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException
{
RequestObject request = new RequestObject();
request.setText("Hello!");
message.setPayload(request);
return message;
}
I create the request, set the variables and return it to Mule. The RequestObject is a class generated by WSDL2Java and corresponds to some operation in the WSDL. Parsing the response works pretty much the same way.
Now I know from experience that a lot of webservices do not quite work in the same way. Try to implement my example yourself. If that doesn't work, please provide your Mule-Config and any and all Java classes you may be using.
EDIT:
I've created an example of my method that actually works. The files can be downloaded at our website. Please see the comments in the files. You have to manually create the Mule project, of course.
Points of note for the example:
The XML-representation of the Mule-config can be found in the 'resources' folder in the archive.
The 'nl.example.example' folder contains all the generated JAX-WS files.
The WSDL location in Mule-config has to be changed since it contains an absolute path.
The example creates an endpoint at http://localhost:8088 for you to call. The flow contains a transformer which creates an example call using pre-defined parameters. Then it tries to connect to the webservice. I've used the default address used by SOAPUI when you create a mock service, but this could of course be changed into anything you want. The webservice (supposedly) returns something which is echoed into the user's browser.
In this example, the parameters are actually Strings, since the WSDL-request doesn't contain anything. To figure out what object to pass to the cxf:jaxws-client look at the operation definition which can be found in the Port definition in your generated files.

Resources