I want to create a user in apex from db(in oracle).
this is my code:
declare
l_workspace_id number;
l_group_id number;
begin
l_workspace_id := apex_util.find_security_group_id('MS');
apex_util.set_security_group_id(l_workspace_id);
l_group_id := apex_util.get_group_id('Developer');
apex_util.create_user(p_user_name => 'MS',
p_first_name => 'Mona',
p_last_name => 'Sh',
p_email_address => 'ms#...',
p_group_ids => l_group_id,
p_web_password => 'MS',
p_default_schema => 'MS',
p_change_password_on_first_use => 'N');
end;
It runs successfully, but I cant see the user in apex application in web.(workspace name, schema name and username are MS)
what is problem?
Related
By default all successfull request on ORDS respond with status code 200 Ok. it is well.
But on occassion I need respond with on customizable error code, ie. 201 , 202 etc.
Are there any mode to respond a customizable error code on ORDS on PUT request?
regards
Pedro
Yes, absolutely.
Simply add a parameter called X-ORDS-STATUS-CODE, and assign it to a :bind, that you have as an OUT RESPONSE HEADER, of type INTEGER.
Then in your POST or PUT handler code, assign the status code you want.
:status := 201;
So...
Here's the full module export -
-- Generated by Oracle SQL Developer REST Data Services 20.2.0.147.0319
-- Exported REST Definitions from ORDS Schema Version 20.2.0.r1611903
-- Schema: HR Date: Mon Jun 22 16:41:15 EDT 2020
--
BEGIN
ORDS.DEFINE_MODULE(
p_module_name => 'status',
p_base_path => '/status/',
p_items_per_page => 25,
p_status => 'PUBLISHED',
p_comments => NULL);
ORDS.DEFINE_TEMPLATE(
p_module_name => 'status',
p_pattern => '201',
p_priority => 0,
p_etag_type => 'HASH',
p_etag_query => NULL,
p_comments => NULL);
ORDS.DEFINE_HANDLER(
p_module_name => 'status',
p_pattern => '201',
p_method => 'POST',
p_source_type => 'plsql/block',
p_items_per_page => 0,
p_mimes_allowed => '',
p_comments => NULL,
p_source =>
'declare
new_record integer;
begin
insert into demo201 (column2) values (:words) returning column1 into new_record;
commit;
:status := 201;
end;'
);
ORDS.DEFINE_PARAMETER(
p_module_name => 'status',
p_pattern => '201',
p_method => 'POST',
p_name => 'X-ORDS-STATUS-CODE',
p_bind_variable_name => 'status',
p_source_type => 'HEADER',
p_param_type => 'INT',
p_access_method => 'OUT',
p_comments => NULL);
COMMIT;
END;
Here's a somewhat better example where I've caught my exception and set the HTTP Response Status code to '400'
Construction like:
menu.add :label => current_admin_user.full_name do |submenu|
menus.each do |m|
submenu.add :label => m['name'],
:url => "/admin/change/#{m['id']}",
:html_options => {:style => 'float:left;'},
:if => proc { current_admin_user.role?('super_admin') }
end
end
Doesn't work in 1.0pre+ anymore. There is no current_admin_user in the scope. But in the logs i see the request that fetches admin user before a menu getting added.
SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 6 ORDER BY `admin_users`.`id` ASC LIMIT 1
Any chance to deal with it?
It is still possible to use, i only needed to pass id of a menu
menu.add id: 'user_name' label: -> { current_admin_user.full_name } do |submenu|
I know it is possible to send mail through oracle apex using apex mail with an attachment with the following code -
DECLARE
l_id NUMBER;
BEGIN
l_id := APEX_MAIL.SEND(
p_to => 'fred#flintstone.com',
p_from => 'barney#rubble.com',
p_subj => 'APEX_MAIL with attachment',
p_body => 'Please review the attachment.',
p_body_html => '<b>Please</b> review the attachment');
FOR c1 IN (SELECT filename, blob_content, mime_type
FROM APEX_APPLICATION_FILES
WHERE ID IN (123,456)) LOOP
APEX_MAIL.ADD_ATTACHMENT(
p_mail_id => l_id,
p_attachment => c1.blob_content,
p_filename => c1.filename,
p_mime_type => c1.mime_type);
END LOOP;
COMMIT;
END;
/
but ,I want to attach a file on the disk(OS) to a mail sent through oracle apex instead of blob content
p_attachment => c1.blob_content,
i.e., i want to attach a file for example D:\sample.pdf as attachment in the mail.
I want to know if it is possible and if possible then how?
I got the answer from my post here
I sent the mail using the below method
DECLARE
l_id NUMBER;
l_bfile BFILE;
l_blob BLOB;
BEGIN
DBMS_LOB.createtemporary(l_blob, TRUE); -- Initialize the BLOB.
l_bfile := BFILENAME('TEST', 'test.pdf');
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
l_id := APEX_MAIL.SEND(
p_to => 'account#host.com',
p_from => 'account#host.com',
p_subj => 'APEX_MAIL with attachment',
p_body => 'Please review the attachment.',
p_body_html => '<b>Please</b> review the attachment');
APEX_MAIL.ADD_ATTACHMENT(
p_mail_id => l_id,
p_attachment => l_blob,
p_filename => 'test.pdf',
p_mime_type => 'application/pdf');
DBMS_LOB.fileclose(l_bfile);
DBMS_LOB.freetemporary(l_blob);
COMMIT;
END;
I'm trying to consume the OTRS generic interface. The rest service is created by the import functionallity. I found the files needed for import here Consuming OTRS TicketConnector from .NET apps
My problem is when I try to consume the interface for example with a curl command
curl http://<user>:<password>#<server-ip>:<port>/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<Ticket-id> -X GET
The result of the command is
{"Error":{"ErrorCode":"TicketGet.AuthFail","ErrorMessage":"TicketGet: Authorization failing!"}}
I tried every user/password combination that makes sense to me. I tried the otrs admin account, agent account, customer account, root account of the server, EVERYTHING! I can't find a information in the docs that states wich account type is needed.
Here are some information that are printed out by the webservice debugger
Communication sequence started
$VAR1 = {
'DOCUMENT_ROOT' => '/srv/www/htdocs',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'HTTP_ACCEPT' => '*/*',
'HTTP_HOST' => '<server-name>',
'HTTP_USER_AGENT' => 'curl/7.39.0',
'MOD_PERL' => 'mod_perl/2.0.4',
'MOD_PERL_API_VERSION' => '2',
'PATH' => '/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin',
'PATH_INFO' => '/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'PATH_TRANSLATED' => '/srv/www/htdocs/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'QUERY_STRING' => '',
'REMOTE_ADDR' => '<server-ip>',
'REMOTE_PORT' => '56065',
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'SCRIPT_FILENAME' => '/opt/otrs/bin/cgi-bin/nph-genericinterface.pl',
'SCRIPT_NAME' => '/otrs/nph-genericinterface.pl',
'SERVER_ADDR' => '<server-ip>',
'SERVER_ADMIN' => '<admin-account>',
'SERVER_NAME' => '<server-name>',
'SERVER_PORT' => '80',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'SERVER_SIGNATURE' => '<address>Apache/2.2.12 (Linux/SUSE) Server at <server-name> Port 80</address>
',
'SERVER_SOFTWARE' => 'Apache/2.2.12 (Linux/SUSE)'
};
Deteced operation TicketGet
No data provided
Incoming data before mapping
$VAR1 = {
'RequestMethod' => 'GET',
'TicketID' => '<ticket-id>'
};
TicketGet.AuthFail
TicketGet: Authorization failing!
Outgoing data before mapping
$VAR1 = {
'Error' => {
'ErrorCode' => 'TicketGet.AuthFail',
'ErrorMessage' => 'TicketGet: Authorization failing!'
}
};
Long story short: what type of authentication or user type otrs expects to access the generic interface?
In found my mistake. The way I passed the login credentials to the service was wrong.
In my case the user is a agent user.
Here is a working curl command for my service:
curl http://<server-ip>:<port>/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>?UserLogin=<username>\&Password=<password> -X GET
I'm using Active Admin with i18n. Everything works but if i want to change language I need to do that by hand - changing site address :-(... How to add buttons in navigate bar with models names? It could be another place but good for that - accessible.
You can set a default locale in a before filter by adding the following lines to application_controller.rb:
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
{ :locale => I18n.locale }
end
Add a menu for selecting languages in active_admin.rb:
config.namespace :admin do |admin|
admin.build_menu :utility_navigation do |menu|
menu.add :label => "Languages" do |lang|
lang.add :label => "English",:url => proc { url_for(:locale => 'en') }, id: 'i18n-en', :priority => 1
lang.add :label => "Mexican",:url => proc { url_for(:locale => 'es') }, id: 'i18n-es', :priority => 2
end
menu.add :label => proc { display_name current_active_admin_user },
:url => '#',
:id => 'current_user',
:if => proc { current_active_admin_user? }
admin.add_logout_button_to_menu menu
end
end
You can set the default locale in application.rb:
config.before_configuration do
I18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
I18n.default_locale = :en
I18n.reload!
end