I'm trying to learn how to develop modules and I'm having controller path problems
InvalidArgumentException: Class "\Drupal\new_module\Controller\NewModuleController" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of core\lib\Drupal\Core\DependencyInjection\ClassResolver.php).
web\modules\custom\new_module\new_module.info.yml:
name: New Module
description: My first module custom
package: New Modules
type: module
core: 8.x
core_version_requirement: ^8 || ^9
web\modules\custom\new_module\new_module.routing.yml:
new_module.content:
path: '/admin/config/new-mogule-first'
defaults:
_title: 'New Module'
_controller: '\Drupal\new_module\Controller\NewModuleController::content'
requirements:
_permission: 'access content'
web\modules\custom\new_module\src\Controller\NewModuleController.php:
<?php
namespace Drupal\new_module\Controller;
use Drupal\Core\Controller\ControllerBase;
class NewModuleController extends ControllerBase {
public function content(){
return array(
'#type'=> 'markup',
'#markup' => $this->t('Hola, prueba'),
);
}
}
?>
drush status:
Drupal version : 9.5.2
Site URI : http://default
DB driver : mysql
DB hostname : localhost
DB port : 3306
DB username : root
DB name : drupasl_new_module
Database : Connected
Drupal bootstrap : Successful
Default theme : olivero
Admin theme : claro
PHP binary : C:/xampp/php/php.exe
PHP config : C:/xampp/php/php.ini
PHP OS : WINNT
PHP version : 8.1.12
Drush script : C:/xampp/htdocs/drupal/new_module/vendor/bin/drush
Drush version : 11.4.0
Drush temp : C:/Users/54113/AppData/Local/Temp
Drush configs : C:/xampp/htdocs/drupal/new_module/vendor/drush/drush/drus
h.yml
Install profile : standard
Drupal root : C:\xampp\htdocs\drupal\new_module/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : C:\xampp\tmp
I also generated a test module with the drush, it gives the same error
Related
Problem
The issue concerns swagger codegen and using multiple files to define specs.
I have two REST APIs with two different files specs1.yml and specs2.yml.
These specs have some models/schemas/definitions (I use swagger 2.0) in common.
I'd like to factorize these definitions in a core.yml file.
I can then reference these in specs1 and specs2.
The issue is that swagger codegen generates these models as part of specs1 and specs2. What I'd like is processing the core.yml file, generating classes in a core package, and then having the specs1/2 generated classes referencing the classes in the core package when it's a common one.
Technical Stack
Maven / Java / JAXRS-CXF REST API
Maven 3.6.0
Java 1.8.0_201
swagger-jaxrs 1.5.16
CXF 3.1.14
swagger-codegen-maven-plugin 2.4.7
Code Example
Swagger Specs YML
I have a tag named e.g. "Super Tag" in my swagger specs definition.
Multiple endpoints are regrouped under that tag. For the sake of a minimal PoC of my issue, let's go with one endpoint:
specs1.yml
swagger: "2.0"
tags:
- name: "Super Tag"
x-core-imports: [ErrorResponse] # Trying this at tag level
x-imports: [ABody] # Trying this at tag level
paths:
/someEndpointPath:
post:
x-core-imports: [ErrorResponse] # --> import bla.core.api.models.ErrorResponse
x-imports: [ABody] # --> import bla.project.api.models.ABody
tags:
- "Super Tag"
operationId: postToSomeEndpoint
consumes:
- application/json
produces:
- application/json
parameters:
- name: body
in: body
required: true
schema:
$ref: '#/definitions/ABody' # This model is defined in this file
responses:
204:
description: "Successful response"
400:
description: "Bad request error"
schema:
$ref: '../CORE.yml#/definitions/_ErrorResponse'
# I'm importing this model definition from another file
definitions:
ABody:
type: object
field:
type: string
Swagger Codegen Debugging
I tried seeing where the vendor extensions would be added with regards to imports: [{ "import": ... }] (which is what's read from the api.mustache template, see below)
> java -DdebugSupportingFiles -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i specs.yml -l java > result.json
I can see
result.json
"apiInfo" : {
"apis" : { [
"parent" : [ ],
"generatorClass" : "io.swagger.codegen.languages.JavaClientCodegen",
"supportJava6" : false,
"sortParamsByRequiredFlag" : true,
"groupId" : "io.swagger",
"invokerPackage" : "io.swagger.client",
"classVarName" : "superTag",
"developerEmail" : "apiteam#swagger.io",
"generateModelDocs" : true,
"hasImport" : true,
"generateModelTests" : true,
"generateApiTests" : true,
"classFilename" : "SuperTagApi",
"usePlayWS" : false,
"generateModels" : true,
"serializableModel" : false,
"playVersion" : "play25",
"inputSpec" : "specs.yml",
"artifactUrl" : "https://github.com/swagger-api/swagger-codegen",
"developerOrganization" : "Swagger",
"baseName" : "SuperTag",
"package" : "io.swagger.client.api",
"imports" : [ {
"import" : "io.swagger.client.model.ABody"
}, {
"import" : "io.swagger.client.model.ErrorResponse"
} ]
...
] }
}
Swagger Templates
We can see in the api.mustache template
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
I'm using the maven swagger codegen plugin with the following options:
<modelPackage>com.mysite.myproject.api.models</modelPackage>
<apiPackage>com.mysite.myproject.api</apiPackage>
So in my generated java class I will get:
SuperTagApi.class
package com.mysite.myproject.api;
import com.mysite.myproject.api.models.ErrorResponse;
import com.mysite.myproject.api.models.ABody;
What I'd like to do is have a means to tell swaggercodegen that I want one class imported as it is now, but the second imported from another package.
To do that, my idea was using vendor extensions (as you can see above) and manually list the classes that I want imported from a given package (that will actually be generated from the CORE.yml file) and the ones that are defined in my specs.yml where I want the original generated package name.
I tried adding x-core-imports vendor-extension to multiple different places trying to get access to them. None put them at the same level as the imports: [{ "import": ... }] section of the result.json... This is because different endpoints/methods are regrouped under the same file when their tag is identical.
I modified my api.mustache like so:
{{^vendorExtensions.x-imports}}
{{#imports}}import {{import}};
{{/imports}}
{{/vendorExtensions.x-imports}}
{{#vendorExtensions.x-imports}}
{{#vendorExtensions.x-core-imports}}
import com.mysite.core.api.models.{{.}};
{{/vendorExtensions.x-core-imports}}
import com.mysite.myproject.api.models.{{.}};
{{/vendorExtensions.x-imports}}
Do you know at which level in the yml file I have to put my vendor extensions to be able to access them from api.mustache? (Without modifying swagger codegen, just modifying templates and yml specs files)
I've the following script with a custom database specified but I don't see the database user getting created within the GUI (compass). I only see 3 default databases (admin, config, local).
I've looked into this linked answer but I need a specific answer for my question, please.
mongo:
image: mongo:4.0.10
container_name: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: mypass
MONGO_INITDB_DATABASE: mydb
ports:
- 27017:27017
- 27018:27018
- 27019:27019
The expectation for a user database to be created.
Database prefilled with some records.
Edit - made some progress, 2 Problems
Added volumes
mongo:
image: mongo:4.0.1r0
container_name: mongo
restart: always
volumes:
- ./assets:/docker-entrypoint-initdb.d/
1. Ignore
Within assets folder, I've 3 files and I see this in the logs, my files are getting ignored.
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/file1.json
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/file2.json
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/file3.json
all my JSON files look like following. (no root array object? no [] at the root?)
{ "_id" : { "$oid" : "5d3a9d423b881e4ca04ae8f0" }, "name" : "Human Resource" }
{ "_id" : { "$oid" : "5d3a9d483b881e4ca04ae8f1" }, "name" : "Sales" }
2. Default Database not getting created. following line is not having any effect.
MONGO_INITDB_DATABASE: mydb
All files *.json extension will be ignored, it should in *.js. Look into the documentation of mongo DB docker hub
MONGO_INITDB_DATABASE
This variable allows you to specify the name of a database to be used
for creation scripts in /docker-entrypoint-initdb.d/*.js (see
Initializing a fresh instance below). MongoDB is fundamental
designed for "create on first use", so if you do not insert data with
your JavaScript files, then no database is created.
Initializing a fresh instance
When a container is started for the first time it will execute files
with extensions .sh and .js that are found in
/docker-entrypoint-initdb.d. Files will be executed in alphabetical
order. .js files will be executed by mongo using the database
specified by the MONGO_INITDB_DATABASE variable, if it is present, or
test otherwise. You may also switch databases within the .js script.
you can look into this example
create folder data and place create_article.js in it
( in the example I am passing your created DB user)
db = db.getSiblingDB("user");
db.article.drop();
db.article.save( {
title : "this is my title" ,
author : "bob" ,
posted : new Date(1079895594000) ,
pageViews : 5 ,
tags : [ "fun" , "good" , "fun" ] ,
comments : [
{ author :"joe" , text : "this is cool" } ,
{ author :"sam" , text : "this is bad" }
],
other : { foo : 5 }
});
db.article.save( {
title : "this is your title" ,
author : "dave" ,
posted : new Date(4121381470000) ,
pageViews : 7 ,
tags : [ "fun" , "nasty" ] ,
comments : [
{ author :"barbara" , text : "this is interesting" } ,
{ author :"jenny" , text : "i like to play pinball", votes: 10 }
],
other : { bar : 14 }
});
db.article.save( {
title : "this is some other title" ,
author : "jane" ,
posted : new Date(978239834000) ,
pageViews : 6 ,
tags : [ "nasty" , "filthy" ] ,
comments : [
{ author :"will" , text : "i don't like the color" } ,
{ author :"jenny" , text : "can i get that in green?" }
],
other : { bar : 14 }
});
mount the data directory
docker run --rm -it --name some-mongo -v /home/data/:/docker-entrypoint-initdb.d/ -e MONGO_INITDB_DATABASE=user -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=mypass mongo:4.0.10
once container created you will be able to see the DBs,
I added config in my package.json, and the rollup.config.js is below:
const rollupConfig = require('#ionic/app-scripts/config/rollup.config');
enter code hereconst replace = require('rollup-plugin-replace');
const isProd = (process.env.IONIC_ENV === 'prod');
console.log('cur ENV: ', process.env.IONIC_ENV);
const EnvConfig = {
prod: {
API_URL: ''
},
dev: {
API_URL: 'http://localhost:3000'
},
deviceDev: {
API_URL: 'http://192.168.1.7:3000'
}
}
const curConfig = EnvConfig[process.env.IONIC_ENV]
const rollupConfigReplaceEnviroment = replace({
exclude: 'node_modules/**',
delimiters: ['<#', '#>'],
// use the /environments/environment.dev as the default import(!), no stub needed.
// note we only replace the "last" part of the import statement so relative paths are maintained
'API_URL': curConfig.API_URL,
});
rollupConfig.plugins = rollupConfig.plugins || [];
rollupConfig.plugins.splice(0, 0, rollupConfigReplaceEnviroment);
module.exports = rollupConfig;
But when i run ionic serve -b, there is an warns show up:
```
[22:54:11] rollup: commonjs-proxy:/Applications/My-Project/sharemap/node_modules/#angular/http/#angular/http.es5.js
has issued a warning: 'default' is not exported by 'node_modules/#angular/http/#angular/http.es5.js'
[22:54:11] rollup: commonjs-proxy:/Applications/My-Project/sharemap/node_modules/#angular/core/#angular/core.es5.js
has issued a warning: 'default' is not exported by 'node_modules/#angular/core/#angular/core.es5.js'
then i run my app in browser, it show the error:
ERROR ReferenceError: System is not defined
at loadAndCompile (main.js:82094)
at NgModuleLoader.load (main.js:82071)
at ModuleLoader.load (main.js:82147)
at DeepLinker.getNavLinkComponent (main.js:56968)
at DeepLinker.initViews (main.js:57039)
at Nav.ngAfterViewInit (main.js:80489)
at callProviderLifecycles (main.js:13220)
at callElementProvidersLifecycles (main.js:13195)
at callLifecycleHooksChildrenFirst (main.js:13179)
at checkAndUpdateView (main.js:14211)
i think these maybe a bug for rollup-plugin-commonjs#8.0.2, and then i upgrade these lib to 8.2.0, but the problem still go on.
MY #ionic/app-scripts version is 2.1.4
My ionic info:
cli packages: (/Applications/My-Project/sharemap/node_modules)
#ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : not installed
local packages:
#ionic/app-scripts : 2.1.4
Cordova Platforms : none
Ionic Framework : ionic-angular 3.6.0
System:
Android SDK Tools : 26.0.2
ios-deploy : 1.9.1
ios-sim : 6.0.0
Node : v8.4.0
npm : 5.2.0
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
You have to add package.json with a specific path as given below;
"config": {
"ionic_copy": "./config/rollup.config.js"
},
and rollup.config.js file will be in the config directory under the root directory with like projectName/config/rollup.config.js
I have a MongoDB server where I have enabled authentication and created users with DB-specific permissions. The user for this app is defined as shown below i.e. geoAdmin has read, readWrite and dbOwner permissions for the relevant database:
MongoDB shell version: 3.0.0
connecting to: 192.168.2.89/test
> use geo_db
switched to db geo_db
> db.getUser("geoAdmin")
{
"_id" : "geo_db.geoAdmin",
"user" : "geoAdmin",
"db" : "geo_db",
"roles" : [
{
"role" : "read",
"db" : "geo_db"
},
{
"role" : "dbOwner",
"db" : "geo_db"
},
{
"role" : "readWrite",
"db" : "geo_db"
}
]
}
The following query works OK i.e. connecting to the remote server from my local mongo client:
mint:~ $ mongo 192.168.2.89:27017 -u geoAdmin -p secret --authenticationDatabase geo_db
MongoDB shell version: 3.0.0
connecting to: 192.168.2.89/test
> use geo_db
switched to db geo_db
> db.LAD_DEC_2013_GB_BFE.findOne({},{'properties.LAD13NM':1})
{
"_id" : ObjectId("54ffe2824f0787ec1293017f"),
"properties" : {
"LAD13NM" : "Hartlepool"
}
}
I then connect to the same remote host from a ReactiveMongo Play app on the same local client, with this URL in the app config file:
# ReactiveMongo
mongodb.uri = "mongodb://geoAdmin:secret#192.168.2.89:27017/geo_db"
But when my app tries to read from the same collection, I get a MongoDB "code = 13" error:
[DetailedDatabaseException: DatabaseException['not authorized for query on geo_db.LAD_DEC_2013_GB_BFE' (code = 13)]]
The app works fine if I connect to a local MongoDB which does not have authentication enabled.
Any ideas what might be going wrong here?
ReactiveMongo 0.11.7.play23 is supporting mongo 3.0 auth-protocols, but is still using the old as default.
With ReactiveMongo 0.11.7.play23 -plugin, you can make it authenticate with mongo 3.0, by adding "?authMode=scram-sha1" to the end of your mongodb.uri.
E.g.:
mongodb.uri = "mongodb://geoAdmin:secret#192.168.2.89:27017/geo_db?authMode=scram-sha1"
mongo 2.6 uses MONGODB-CR auth protocol and 3.0 uses MONGODB-SHA-1 by default
reactivemongo use MONGODB-CR auth protocol(not sure)
downgrade mongodb 3.0 auth mechanisms to MONGODB-CR
login mongo noauth
remove all user
update the version document for the authSchema.
ex.
db.getSiblingDB("admin").system.users.remove( {} )
db.getSiblingDB("admin").system.version.update(
{ _id: "authSchema" },
{ $set: { currentVersion: 3 } }
);
add authSource parameter to mongodb url
ex.
mongodb.uri = "mongodb://geoAdmin:secret#192.168.2.89:27017/geo_db?authSource=geo_db"
can anyone give me some directions / examples about how to import about 100 million rows from SQL server to Elasticsearch using c# language?
Currently I'm using a NEST client in c# but is very slow ( 5k - 10k / Minute ), the slowness looks like is more from the app side than ES.
Appreciate any help.
You can use IndexMany but if you want to index only one table I think you can try with JDBC plugin. After installation, you can simply execute a .bat script to index your table.
#echo off
set DIR=%~dp0
set LIB=%DIR%..\lib\*
set BIN=%DIR%..\bin
REM ???
echo {^
"type" : "jdbc",^
"jdbc" : {^
"url" : "jdbc:sqlserver://localhost:25488;instanceName=SQLEXPRESS;databaseName=AdventureWorks2014",^
"user" : "hintdesk",^
"password" : "123456",^
"sql" : "SELECT BusinessEntityID as _id, BusinessEntityID, Title, FirstName, MiddleName, LastName FROM Person.Person",^
"treat_binary_as_string" : true,^
"elasticsearch" : {^
"cluster" : "elasticsearch",^
"host" : "localhost",^
"port" : 9200^
},^
"index" : "person",^
"type" : "person"^
}^
}^ | "%JAVA_HOME%\bin\java" -cp "%LIB%" -Dlog4j.configurationFile="%BIN%\log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"