I am trying to render richtext content from WCM using wcm API. I have jsp to do so. It renders properly for all user group except anonymous. When I view rendered content I see broken image inside richtext. When I log in and view the rendered content, image is displayed.
here is my code:
Workspace ws = WCM_API.getRepository().getSystemWorkspace();
ws.login();
DocumentLibrary lib = ws.getDocumentLibrary("Portal Site");
String s1 = "";
String s2 = "";
if (lib!=null) {
DocumentIdIterator<Document> it = ws.findByName(DocumentTypes.Content,"kino");
if (it.hasNext()) {
DocumentId<Document> docid = it.next();
Content doc = (Content) ws.getById(docid);
s1 = "Title: " + doc.getTitle() + "\n";
RichTextComponent c = (RichTextComponent) doc.getComponent("Body");
s2 = "Text: " + c.getRichText();
}
}
out.println(s1);
out.println(s2);
s2 is outputs richtext with image for authorized users.
When I logout and view s2 output: text is displayed but image is broken
Please make sure that you have anonymous access granted to all your RichText component and parent site areas at user level.
And add this call on workspace object
workspace.useUserAccess(true);
Solution has nothing to do with access level in my case!
I checked url of the content and in both cases it consisted /myconnect word (example: http:ip_address:port/wps/wcm/myconnect/...)
I found out that myconnect is for authorized user
and connect is for anon users. (example: http:ip_address:port/wps/wcm/connect/...)
Just by replacing myconnect with connect in the url to the wcm content I managed to solve the problem:
Related
I am opening a webpage in the cefsharp browser and trying to send a set of JSON data to my website's .aspx page along with query string. While the query string is not an issue but sending the JSON data to the same URL is what I am trying to fix. Earlier I was using Window's native WebBrowser control's Navigate method where I was passing the URL along with query string as well as a byte array. But, I don't find any such method to post the data. Various discussion and posts regarding the same don't have a clear example. Can you provide a sample code/example to show how to achieve that? Here is the code I've been using:
ChromiumWebBrowser browser = new ChromiumWebBrowser();
browser.Address = "https://webhook.site";
browser.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
browser.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
browser.RequestHandler = this;
browser.IsBrowserInitializedChanged += (sender, args) =>
{
if (browser.IsBrowserInitialized)
{
browser.LoadUrlWithPostData("https://webhook.site/#/cba9d04b-01ff-40ef-b223-0917d127ecbe/6ce82e34-28df-4900-88ef-c932a446c6b0/1", Encoding.UTF8.GetBytes("test=123&data=456"));
}
};
I've been trying to upload a user profile picture during the user registration using Service 3 and so far I haven't had any luck. I tested passing a hard coded fid in the field "picture" and also tried to pass the fields "filemime", "filename", etc. and it didn't work neither.
Any idea about what fields I need to populate?
I guess it must be related to this post Using Drupal Services and DIOS SDK for setting user picture in iOS app
but it doesn't have and answer neither.
I use following code -
//Picture is first uploaded from ios using file service and fid is passed in $data object
$file_contents_object = file_load($data->picture_fid);
$file_contents_array['fid'] = $file_contents_object->fid;
$file_contents_array['uid'] = $file_contents_object->uid;
$file_contents_array['filename'] = $file_contents_object->filename;
$file_contents_array['uri'] = $file_contents_object->uri;
$file_contents_array['filemime'] = $file_contents_object->filemime;
$file_contents_array['filesize'] = $file_contents_object->filesize;
$file_contents_array['status'] = $file_contents_object->status;
$file_contents_array['timestamp'] = $file_contents_object->timestamp;
$file_contents_array['rdf_mapping'] = $file_contents_object->rdf_mapping;
//use your cck field here
$user_obj->field_user_profile_picture['und'][0] = $file_contents_array;
Hope this will help.
I recently show up all products on a "Lookup" Field on a Inline Silverlight App on the CRM2011 Quote form.
I do this with directly calling the link of the Lookup:
var uri = (ScriptObject)crmUri.Invoke("create", string.Format("/_controls/lookup/lookupinfo.aspx?LookupStyle=single&objecttypes={0}", objectType));
var dArgs = (ScriptObject)HtmlPage.Window.CreateInstance("Object");
dArgs.SetProperty("items", new string[] { "" });
dynamic dlgResult = HtmlPage.Window.Invoke("showModalDialog", uri, dArgs, "dialogWidth:500px;dialogHeight:700px");
Our Customer wants to filter the lookup view on a value of a specific field on the product form.
This field is a optionset and can be 1 or 2.
I tried to add "&$filter=" + "producttypecode/Value" + " eq 1" or "&$filter=" + "producttypecode" + " eq 1" in the link, but this always Returns a error message.
Are there any suggestions?
This is a valid request that I just tested.
ProductSet?$filter=ProductTypeCode/Value eq 1
If that doesn't work I'd recommend the following troubleshooting steps.
Test your full URL in a browser first.
If it works in a browser then fire up fiddler and see what the difference is between the silverlight request and your manual request using a browser.
If you are having difficulty determining the correct full url I'd recommend downloading and becoming familiar with the CRM OData Query Designer. It will allow you to use a GUI to generate your request strings, and test them out. It can be found here.
http://crm2011odatatool.codeplex.com/
We solved this issue by adding a new System View and call it from its URL.
I have a GAE website. The home page displays a list of project objects and a form for adding more projects. When the submit button is pressed, an ajax request is made which runs the 'create_userstoryproject()' method. This method adds the new project and returns a list of all projects, including the one that was just added. For some reason, the query in the 'create_userstoryproject()' method does not return the project just added. However, if I refresh the page, causing the 'get()' method to run, the newly added project shows up just fine. I haven't simplified this code--it's cut and pasted. Anyone have any idea why the newly created project doesn't show up until I refresh the page?
class Home(BaseApp): #BaseApp is derived from webapp2.RequestHandler
def get(self):
self.context['userstoryprojects'] = UserStoryProject.query().order(UserStoryProject.Order)
self.context['userstorystatuses'] = UserStoryStatus.query().order(UserStoryStatus.Order)
self.render('/userstories')
def create_userstoryproject(self):
description = self.request.get('userstoryproject[description]', default_value=None)
if description:
userstoryproject = UserStoryProject()
userstoryproject.Description = description
userstoryproject.put()
self.context['userstoryprojects'] = UserStoryProject.query().order(UserStoryProject.Order)
self.render('/userstoryprojects')
else:
self.write("fail.")
This is because of eventual consistency.
Overview
I am working on building a Kynetx ruleset that will find a bunch of Facebook ids that are on the page and then use the Kynetx Facebook module to get the Facebook avatar associated with that Facebook id. I have the JS that creates an array of Facebook ids on the page and I can process an array in KRL to retrieve Facebook avatars. What I don't have is how to get an array from the client side to the server side in KRL.
How can I get the array from the client side to the server side of KRL?
You can take a JavaScript array and convert it into a string and it will work if you decode it on the server side of KRL.
Example app code => https://gist.github.com/722536
Example app bookmarklet => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/send-array-to-kns-dev-bookmarklet.html
ruleset a60x442 {
meta {
name "array-passing-test"
description <<
array-passing-test
>>
author "Mike Grace"
logging on
}
rule start_your_engines {
select when pageview ".*"
{
notify("Running","...sending array to KNS") with sticky = true;
emit <|
app = KOBJ.get_application("a60x442");
var numbers = [1,2,3,4,5];
nums = JSON.stringify(numbers);
app.raise_event("process_array", {"numbers":nums});
$K("div.KOBJ_message").append("<br/>"+nums);
|>;
}
}
rule process_array {
select when web process_array
foreach event:param("numbers").decode() setting (number)
{
notify("number",number) with sticky = true;
}
}
}
Results of running app from bookmarklet on http://example.com/
Answer
Unfortunately, the KRL JS runtime doesn't yet support sending arrays to the server side. There is a way to accomplish what you are wanting to do though.
Example
I built an example app that runs on this page with a bookmarklet that gets the tags that the question is tagged with and sends them to the server to be processed and then they come back.
Example app code => https://gist.github.com/707561
Example app bookmarklet => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/client-side-array-to-server-bookmarklet.html
Step by step explination of code example
collect text in JS array
convert array into csv string and append comma to make regex splitting easier
raise event to KNS with csv string
process rule pulls first value off
rest of the values are saved to a new variable
first value goes into a notify
postlude sends remaining values to itself
loops until done and returns directives back to the browser
Results of running app from bookmarklet:
You can also do arrays of hashes if you JSON.stringify the array of hashes.
Example app:
ruleset a60x449 {
meta {
name "pass-hash-in-web-event-test"
description <<
pass-hash-in-web-event-test
>>
author "Mike Grace"
logging on
}
rule start_this_party {
select when pageview ".*"
{
notify("Now running","Building arrays to send to KNS") with sticky = true;
emit <|
var data = {};
data.userData = JSON.stringify(
[
{"name":"MikeGrace","id":234232344},
{"name":"TelegramSam","id":234089790234},
{"name":"Alex","id":2300234234234}
]
);
app = KOBJ.get_application("a60x449");
app.raise_event("process_me_data", data);
|>;
}
}
rule process_arrays_of_data {
select when web process_me_data
foreach event:param("userData").decode() setting (user)
pre {
userName = user.pick("$.name");
userId = user.pick("$.id");
output =<<
<p>
userName: #{userName}<br/>
userId: #{userId}<br/>
</p>
>>;
}
{
append("body", output);
}
}
}
Results of running on example.com