From d948d85bbb1529e202ad3d1cb58e615a820d94cd Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Tue, 15 Aug 2017 14:57:52 +0530 Subject: [PATCH 01/13] App Publisher React application. Initial Commit. --- .gitignore | 1 + .../pom.xml | 169 ++++++++++++++++++ .../src/main/resources/publisher/.babelrc | 5 + .../src/main/resources/publisher/package.json | 51 ++++++ .../publisher/public/images/favicon.png | Bin 0 -> 1923 bytes .../resources/publisher/public/index.html | 42 +++++ .../resources/publisher/public/manifest.json | 15 ++ .../src/main/resources/publisher/src/App.css | 0 .../src/main/resources/publisher/src/App.js | 33 ++++ .../main/resources/publisher/src/App.test.js | 26 +++ .../main/resources/publisher/src/index.css | 5 + .../src/main/resources/publisher/src/index.js | 26 +++ .../publisher/src/registerServiceWorker.js | 126 +++++++++++++ .../resources/publisher/webpack.config.js | 51 ++++++ .../pom.xml | 168 +++++++++++++++++ components/application-mgt/pom.xml | 2 +- .../pom.xml | 16 ++ .../pom.xml | 16 ++ features/application-mgt/pom.xml | 3 +- 19 files changed, 753 insertions(+), 2 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.css create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml create mode 100644 features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml create mode 100644 features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml diff --git a/.gitignore b/.gitignore index 9c3d08d3c06..b720258a6a6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ target # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/node_modules/ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml new file mode 100644 index 00000000000..cb06ef09800 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml @@ -0,0 +1,169 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt + 3.0.46-SNAPSHOT + + + org.wso2.carbon.device.application.mgt.publisher.ui + 3.0.46-SNAPSHOT + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.application.mgt + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + + + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + npm install (initialize) + + exec + + initialize + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + install + + + + + + + + npm run build (compile) + + exec + + compile + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + run + ${npm.build.command} + + + + + + + + + + + + + + + + + + + + + ${npm.working.dir} + + + + + + + + platform-windows + + + windows + + + + + npm.cmd + + + + + false + npm + build_prod + ./src/main/ + + + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc new file mode 100644 index 00000000000..02f08fb6c0f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "es2015" + ] +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json new file mode 100644 index 00000000000..c2513e64c52 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json @@ -0,0 +1,51 @@ +{ + "name": "wso2_iot_app_publisher", + "version": "1.0.0", + "description": "WSO2 IoT Server App Publisher", + "main": "App.js", + "repository": { + "type": "git", + "url": "git://github.com/wso2/carbon-devicemgt" + }, + "author": "WSO2 Org", + "license": "Apache License 2.0", + "dependencies": { + "antd": "^2.12.3", + "axios": "^0.16.2", + "flux": "^3.1.3", + "history": "^4.6.3", + "react": "^15.6.1", + "react-dom": "^15.6.1", + "react-images-uploader": "^1.1.0", + "react-modal": "^2.2.2", + "react-router": "^4.1.2", + "react-router-dom": "^4.1.2", + "react-scripts": "1.0.10", + "react-sliding-pane": "^1.2.3", + "react-table": "^6.5.1" + }, + "devDependencies": { + "babel-core": "^6.24.1", + "babel-loader": "^7.0.0", + "babel-plugin-transform-class-properties": "^6.24.1", + "babel-preset-es2015": "^6.24.1", + "chai": "^4.0.2", + "babel-preset-react": "^6.24.1", + "babel-register": "^6.24.1", + "css-loader": "^0.28.2", + "less": "^2.7.2", + "less-loader": "^4.0.4", + "mocha": "^3.4.1", + "mock-local-storage": "^1.0.2", + "style-loader": "^0.18.1", + "webpack": "^2.5.0" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build --history-api-fallback", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject", + "build_prod": "NODE_ENV=production webpack -p --progress --colors --config webpack.config.js", + "build_dev": "NODE_ENV=development webpack -d --config webpack.config.js --watch " + } +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..a1deab3581b3fc53b7177d653228cda8d079bc3f GIT binary patch literal 1923 zcmbVNX;c$u6pf0YSQJqy3J1sF0u+)=_Cx}NNg`2DNI>F3HDm^iA(=24NCJvWMPyS- zRa~$F6~(IH#tCW>)T*E&f{4_$3W`fb#N8@%qG0>Oh3?T_&GzI~rT4fv}LzJ*Np$_pQ zkp{u)2nDVP4dJU$Ek$Xyp_sIK0!aNG=GJX08Te>|YXsy^ zq790eKOQ>-kiw(P*R?859(Yqk=ph&&olk`w|wu2D1)VntXKzkA4ObVo+gfJ+4M| zfR#}hgC^nvGNJU-5w!Zy(9gs=LtmhXkWo!aJr$(Ts9LS{Tpz6sxD5GM#uu#(5oSF? zl_3T+5mOQQi1p|P6S4ccBdZ~yhCd5a6G>6Vi%?af7SZ8Sk$_Bmp}=aGFJVF4ARz?t zSZt9P1VJvyrimF4Q^Ek*ARUDIIlhDq67fKuLA+Q8PwZO;d^3`AP4l=nMh{0tEMG!+wXcuz1keJ54p*clmAbYWG%F$|;VO9Y2e3qUud22v+-MCAV`VhUmt#xB5 z!)Zef=yOnf?IOjdsLJ8-qju+W3U!qpU1yp2eB!L``+^Sh#lQVKej9x@VU39F@~)dX z{|Uur*Dlv7<#yY%e7oG+XS)Tuhp9WpUyF6Gm=}7xb+PvHzWROoBL$8&1J+1>adCA$ zb$RL1)|W#CKb!W@Oiw6z4=*_Loqm3N zU?bS7mI2j1D|UJX&b3qN-iBn`-kP#o!BH)KKQPFaxgovQx9~W3XbMORSa!BP#v}S> zc)1NG9rDnxo3}Y$lNq@CxVZDeU$q*>nE02kE_-?p`rRRSZT?bPL^n;JPt1pVB=0+5x4-Sa61(v31_9qX%4`c+c)g zn5uzHX{Tn!LCartKJ8JooZJ&Nw(y|SVrWd*-ux>FBjbIJdaiS0U?o!zZ5ZMPs_PD?44YNU4z*f(Yf6s%vAGP&nPf7SyC=>=mJRbxs}R;aBd_h!sOed2c?XGMN?co{q>lw0gpavhGlP)0o~7a>#JKgX-p={p?x7 z=5Ot0oELQajgaPby+738HdNsYjk*fi?UK!T-TWj{Q#5S + + + + + + + + + + + + WSO2 IoT App Publisher + + + +
+ + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json new file mode 100644 index 00000000000..2a700bb50e7 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "App Publisher", + "name": "WSO2 IoT App Publisher", + "icons": [ + { + "src": "images/favicon.png", + "sizes": "16x16", + "type": "image/png" + } + ], + "start_url": "./index.html", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.css new file mode 100644 index 00000000000..e69de29bb2d diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js new file mode 100644 index 00000000000..27c65444b7f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { Component } from 'react'; +import './App.css'; + +class App extends Component { + render() { + return ( +
+
+
+
+ ); + } +} + +export default App; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js new file mode 100644 index 00000000000..79b7f3f6659 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css new file mode 100644 index 00000000000..b4cc7250b98 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css @@ -0,0 +1,5 @@ +body { + margin: 0; + padding: 0; + font-family: sans-serif; +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js new file mode 100644 index 00000000000..369f8d3d362 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.css'; +import App from './App'; +import registerServiceWorker from './registerServiceWorker'; + +ReactDOM.render(, document.getElementById('root')); +registerServiceWorker(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js new file mode 100644 index 00000000000..94bc5f9982c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +export default function register() { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/publisher/service-worker.js`; + + if (!isLocalhost) { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } else { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + } + }); + } +} + +function registerValidSW(swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister(); + }); + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js new file mode 100644 index 00000000000..c03279bd3df --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js @@ -0,0 +1,51 @@ +var path = require('path'); + +const config = { + entry: { + index: './src/index.js' + }, + output: { + path: path.resolve(__dirname, 'public/dist'), + filename: '[name].js' + }, + devtool: "source-map", + plugins: [], + watch: false, + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + options: { + presets: ['es2015', 'react'], + plugins: ['transform-class-properties'] + } + } + ] + }, + { + test: /\.css$/, + use: [ 'style-loader', 'css-loader' ] + }, + { + test: /\.less$/, + use: [{ + loader: "style-loader" // creates style nodes from JS strings + }, { + loader: "css-loader" // translates CSS into CommonJS + }, { + loader: "less-loader" // compiles Less to CSS + }] + } + ] + } +}; + +if (process.env.NODE_ENV === "development") { + config.watch = true; +} + +module.exports = config; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml new file mode 100644 index 00000000000..9cee98dd925 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml @@ -0,0 +1,168 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.store.ui + 3.0.46-SNAPSHOT + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.application.mgt.store + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + + + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + npm install (initialize) + + exec + + initialize + + ${basedir}/src/main/resources/store + ${npm.executable} + + install + + + + + + + + npm run build (compile) + + exec + + compile + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + run + ${npm.build.command} + + + + + + + + + + + + + + + + + + + + + ${npm.working.dir} + + + + + + + + platform-windows + + + windows + + + + + npm.cmd + + + + + false + npm + build_prod + ./src/main/ + + + \ No newline at end of file diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 9770fd06432..61523a4ba9f 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -37,7 +37,7 @@ org.wso2.carbon.device.application.mgt.core org.wso2.carbon.device.application.mgt.common org.wso2.carbon.device.application.mgt.api - org.wso2.carbon.device.application.mgt.ui + org.wso2.carbon.device.application.mgt.publisher.ui diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml new file mode 100644 index 00000000000..e9da7bcff09 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt-feature + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.publisher.ui.feature + 3.0.46-SNAPSHOT + + + \ No newline at end of file diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml new file mode 100644 index 00000000000..33f45fc1e08 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt-feature + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.store.ui.feature + 3.0.46-SNAPSHOT + + + \ No newline at end of file diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 4a39791ffc3..f70cb75863b 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -35,9 +35,10 @@ org.wso2.carbon.device.application.mgt.api.feature - org.wso2.carbon.device.application.mgt.ui.feature + org.wso2.carbon.device.application.mgt.feature org.wso2.carbon.device.application.mgt.server.feature + org.wso2.carbon.device.application.mgt.publisher.ui.feature \ No newline at end of file From 72f0e195b7651ee1e1525957554f79e80a531780 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Tue, 15 Aug 2017 16:04:42 +0530 Subject: [PATCH 02/13] Created basic directory structure --- .../src/main/resources/publisher/src/App.js | 27 ++++++++++++++++--- .../src/actions/ApplicationActions.js | 17 ++++++++++++ .../publisher/src/actions/PlatformActions.js | 17 ++++++++++++ .../publisher/src/common/constants.js | 17 ++++++++++++ .../publisher/src/common/dispatcher.js | 22 +++++++++++++++ .../publisher/src/components/index.js | 21 +++++++++++++++ .../src/main/resources/publisher/src/index.js | 6 +++-- .../publisher/src/stores/ApplicationStore.js | 0 .../publisher/src/stores/PlatformStore.js | 17 ++++++++++++ .../resources/publisher/src/stores/index.js | 17 ++++++++++++ 10 files changed, 155 insertions(+), 6 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ApplicationActions.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/PlatformActions.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/dispatcher.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js index 27c65444b7f..c59fb756931 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -17,17 +17,36 @@ */ import React, { Component } from 'react'; +import {BrowserRouter as Router, Route, Switch, Redirect} from 'react-router-dom' import './App.css'; -class App extends Component { +class Base extends Component { + constructor() { + super(); + this.state = { + + } + } + + render() { + return (); + } +} + +class Publisher extends Component { render() { return (
-
-
+ + + + + + +
); } } -export default App; +export default Publisher; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ApplicationActions.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ApplicationActions.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ApplicationActions.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/PlatformActions.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/PlatformActions.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/PlatformActions.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/dispatcher.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/dispatcher.js new file mode 100644 index 00000000000..96803dfb203 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/dispatcher.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import {Dispatcher} from 'flux'; + +export default new Dispatcher(); + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js new file mode 100644 index 00000000000..e1efb92d1b4 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Contains all UI components related to Application, Login and Platform + */ \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js index 369f8d3d362..70161b9b064 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js @@ -19,8 +19,10 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; -import App from './App'; +import Publisher from './App'; +import { LocaleProvider } from 'antd'; import registerServiceWorker from './registerServiceWorker'; +import enUS from 'antd/lib/locale-provider/en_US'; -ReactDOM.render(, document.getElementById('root')); +ReactDOM.render(, document.getElementById('root')); registerServiceWorker(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js new file mode 100644 index 00000000000..cc77f8a78c0 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ \ No newline at end of file From 03b6faa7c21fe6e60dd968066f3667dc2521b851 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Wed, 16 Aug 2017 21:07:14 +0530 Subject: [PATCH 03/13] Created the project file structure. --- .gitignore | 1 + .../src/main/resources/publisher/package.json | 9 ++++--- .../resources/publisher/public/index.html | 2 -- .../src/main/resources/publisher/src/App.js | 26 ++++++++++++++++--- .../publisher/src/actions/ReviewActions.js | 17 ++++++++++++ .../publisher/src/api/AuthHandler.js | 17 ++++++++++++ .../resources/publisher/src/api/Endpoints.js | 21 +++++++++++++++ .../src/components/Application/AppView.js | 17 ++++++++++++ .../Application/ApplicationListing.js | 17 ++++++++++++ .../src/components/Application/Create.js | 17 ++++++++++++ .../src/components/Base/BaseLayout.js | 26 +++++++++++++++++++ .../src/components/Platform/Create.js | 17 ++++++++++++ .../components/Platform/PlatformListing.js | 17 ++++++++++++ .../src/components/Platform/PlatformView.js | 17 ++++++++++++ .../src/components/Reviews/ReviewListing.js | 17 ++++++++++++ .../src/components/Reviews/ReviewView.js | 17 ++++++++++++ .../src/components/UIComponents/DataTable.js | 17 ++++++++++++ .../src/components/UIComponents/SimpleForm.js | 17 ++++++++++++ .../src/components/User/Logout/Logout.js | 0 .../publisher/src/components/index.js | 7 ++++- .../src/main/resources/publisher/src/index.js | 5 ++-- .../publisher/src/stores/ReviewStore.js | 17 ++++++++++++ 22 files changed, 304 insertions(+), 14 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ReviewActions.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/AuthHandler.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/Endpoints.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/AppView.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/Create.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Logout/Logout.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js diff --git a/.gitignore b/.gitignore index b720258a6a6..b385911f898 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ target # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/node_modules/ +components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/build/ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json index c2513e64c52..dd31508d390 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json @@ -1,5 +1,5 @@ { - "name": "wso2_iot_app_publisher", + "name": "publisher", "version": "1.0.0", "description": "WSO2 IoT Server App Publisher", "main": "App.js", @@ -7,16 +7,17 @@ "type": "git", "url": "git://github.com/wso2/carbon-devicemgt" }, - "author": "WSO2 Org", "license": "Apache License 2.0", "dependencies": { - "antd": "^2.12.3", "axios": "^0.16.2", "flux": "^3.1.3", "history": "^4.6.3", + "latest-version": "^3.1.0", + "material-ui": "^0.19.0", "react": "^15.6.1", "react-dom": "^15.6.1", "react-images-uploader": "^1.1.0", + "react-material-ui-form-validator": "^0.5.0", "react-modal": "^2.2.2", "react-router": "^4.1.2", "react-router-dom": "^4.1.2", @@ -48,4 +49,4 @@ "build_prod": "NODE_ENV=production webpack -p --progress --colors --config webpack.config.js", "build_dev": "NODE_ENV=development webpack -d --config webpack.config.js --watch " } -} \ No newline at end of file +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html index 7739ff27086..e684fd6f875 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html @@ -1,6 +1,4 @@ - - diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js index c59fb756931..258af68b0d7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -19,17 +19,35 @@ import React, { Component } from 'react'; import {BrowserRouter as Router, Route, Switch, Redirect} from 'react-router-dom' import './App.css'; +import {Login, BaseLayout} from './components' class Base extends Component { constructor() { super(); this.state = { - + user: "" } } render() { - return (); + if (this.state.user) { + return( + + + + + + + + + + + + + ) + } + + return () } } @@ -39,8 +57,8 @@ class Publisher extends Component {
- - + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ReviewActions.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ReviewActions.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/actions/ReviewActions.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/AuthHandler.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/AuthHandler.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/AuthHandler.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/Endpoints.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/Endpoints.js new file mode 100644 index 00000000000..e3e76b69c23 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/Endpoints.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Defines the list of App Manager APIs. + * */ \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/AppView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/AppView.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/AppView.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js new file mode 100644 index 00000000000..ba59103adb3 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, {Component} from 'react'; + +class BaseLayout extends Component { + + +} + +export default BaseLayout; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/Create.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/Create.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/Create.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Logout/Logout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Logout/Logout.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js index e1efb92d1b4..c82d9576eec 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js @@ -16,6 +16,11 @@ * under the License. */ +import Login from './User/Login/Login' +import BaseLayout from './Base/BaseLayout' + /** * Contains all UI components related to Application, Login and Platform - */ \ No newline at end of file + */ + +export {Login, BaseLayout}; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js index 70161b9b064..d5ab4c3fe28 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js @@ -20,9 +20,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import Publisher from './App'; -import { LocaleProvider } from 'antd'; import registerServiceWorker from './registerServiceWorker'; -import enUS from 'antd/lib/locale-provider/en_US'; +import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; -ReactDOM.render(, document.getElementById('root')); +ReactDOM.render(, document.getElementById('root')); registerServiceWorker(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js new file mode 100644 index 00000000000..9eb827eb700 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ From 44737750b85aab4ed999a5affb64f3d8df554444 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Wed, 16 Aug 2017 21:07:57 +0530 Subject: [PATCH 04/13] Created the login page. --- .../src/components/User/Login/Login.js | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js new file mode 100644 index 00000000000..4aab3b819ed --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { Component } from 'react'; +import {Card, CardTitle, CardActions, CardMedia} from 'material-ui/Card'; +import RaisedButton from 'material-ui/RaisedButton'; +import { ValidatorForm, TextValidator} from 'react-material-ui-form-validator'; +import Checkbox from 'material-ui/Checkbox'; + +class Login extends Component { + constructor() { + super(); + this.state = { + userName: "", + password: "", + rememberMe: true + } + } + + + handleLogin(event) { + console.log(this.state); + + event.preventDefault(); + } + + onUserNameChange(event) { + this.setState( + { + userName: event.target.value + } + ); + } + + onPasswordChange(event) { + this.setState( + { + password: event.target.value + } + ); + } + + rememberMe() { + this.setState( + { + rememberMe: !this.state.rememberMe + } + ) + } + + render() { + return ( +
+ + + + + + + + console.log(errors)}> + + +
+ +
+ +
+ +
+ +
+
+
); + } +} + + +export default Login; \ No newline at end of file From c7c0f62ca2c094168b5a30f359cec3780b44e27f Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Thu, 17 Aug 2017 23:59:01 +0530 Subject: [PATCH 05/13] The base layout completed. --- .../src/main/resources/publisher/package.json | 3 +- .../src/main/resources/publisher/src/App.js | 48 ++++++++------ .../src/components/Base/BaseLayout.js | 62 ++++++++++++++++++- .../src/components/Error/NotFound.js | 41 ++++++++++++ .../src/components/User/Login/Login.js | 6 +- .../publisher/src/components/index.js | 4 +- 6 files changed, 141 insertions(+), 23 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Error/NotFound.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json index dd31508d390..14b66eaaac1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json @@ -14,6 +14,7 @@ "history": "^4.6.3", "latest-version": "^3.1.0", "material-ui": "^0.19.0", + "material-ui-datatables": "^0.18.2", "react": "^15.6.1", "react-dom": "^15.6.1", "react-images-uploader": "^1.1.0", @@ -23,7 +24,7 @@ "react-router-dom": "^4.1.2", "react-scripts": "1.0.10", "react-sliding-pane": "^1.2.3", - "react-table": "^6.5.1" + "react-tap-event-plugin": "^2.0.1" }, "devDependencies": { "babel-core": "^6.24.1", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js index 258af68b0d7..ba5878f6326 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -16,34 +16,44 @@ * under the License. */ -import React, { Component } from 'react'; -import {BrowserRouter as Router, Route, Switch, Redirect} from 'react-router-dom' -import './App.css'; -import {Login, BaseLayout} from './components' +import React, {Component} from 'react'; +import {BrowserRouter as Router, Redirect, Route, Switch} from 'react-router-dom' +import './App.css' +import {BaseLayout, Create, Login, NotFound} from './components' +import createHistory from 'history/createBrowserHistory'; + +const history = createHistory({basename:'/publisher'}); + class Base extends Component { constructor() { super(); this.state = { - user: "" + user: "m" } } render() { if (this.state.user) { - return( - - - - - - - - - - - - + return( +
+ + + + + + + + + + + + + + + + +
) } @@ -55,7 +65,7 @@ class Publisher extends Component { render() { return (
- + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js index ba59103adb3..6260aa6829b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js @@ -17,10 +17,70 @@ */ import React, {Component} from 'react'; +import AppBar from 'material-ui/AppBar'; +import Drawer from 'material-ui/Drawer'; +import MenuItem from 'material-ui/MenuItem'; +import Menu from 'material-ui/Menu'; +import IconButton from 'material-ui/IconButton'; +import Notifications from 'material-ui/svg-icons/social/notifications'; +import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; +import {withRouter} from 'react-router-dom' + +/** + * Base Layout: + * App bar + * Left Navigation + * Middle content. + * */ class BaseLayout extends Component { + handleApplicationClick() { + console.log("Application"); + window.location = '/publisher/assets/apps'; + } + + render() { + return ( +
+ + + + + { + console.log("Clicked") + }}> + + +
+ } + /> +
+ + + Applications + Platforms + Reviews + + +
+
+ {this.props.children} +
+
); + } } -export default BaseLayout; \ No newline at end of file +export default withRouter(BaseLayout); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Error/NotFound.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Error/NotFound.js new file mode 100644 index 00000000000..626642d663f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Error/NotFound.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React, {Component} from 'react'; + +class Error extends Component { + + constructor() { + super(); + } + + componentWillMount() { + console.log("In Crate") + } + + render() { + + return ( + +
+ 404 not found +
+ ); + } +} + +export default Error; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js index 4aab3b819ed..f93c7b48ad2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js @@ -36,6 +36,7 @@ class Login extends Component { handleLogin(event) { console.log(this.state); + event.preventDefault(); } @@ -66,8 +67,11 @@ class Login extends Component { render() { return (
+ + {/*TODO: Style the components.*/} + - + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js index c82d9576eec..f166fc81be0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js @@ -18,9 +18,11 @@ import Login from './User/Login/Login' import BaseLayout from './Base/BaseLayout' +import Create from './Application/Create' +import NotFound from './Error/NotFound' /** * Contains all UI components related to Application, Login and Platform */ -export {Login, BaseLayout}; \ No newline at end of file +export {Login, BaseLayout, Create, NotFound}; \ No newline at end of file From d2705b14279283434fcf0c79bce8bfe8087e249e Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Sun, 20 Aug 2017 01:44:12 +0530 Subject: [PATCH 06/13] Added the stepper and App creation first step. --- .../src/main/resources/publisher/package.json | 1 + .../src/main/resources/publisher/src/App.js | 61 ++++--- .../src/components/Application/Create.js | 168 ++++++++++++++++++ .../src/components/Application/Forms/Step1.js | 117 ++++++++++++ .../src/components/Application/Forms/Step2.js | 61 +++++++ .../src/components/Application/Forms/Step3.js | 61 +++++++ .../src/components/Application/Forms/index.js | 23 +++ .../src/components/Base/BaseLayout.js | 107 +++++++++-- .../components/Overview/PublisherOverview.js | 41 +++++ .../src/components/User/Login/Login.js | 133 ++++++++------ .../publisher/src/components/index.js | 3 +- 11 files changed, 673 insertions(+), 103 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/index.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json index 14b66eaaac1..fe5f46e4210 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json @@ -15,6 +15,7 @@ "latest-version": "^3.1.0", "material-ui": "^0.19.0", "material-ui-datatables": "^0.18.2", + "qs": "^6.5.0", "react": "^15.6.1", "react-dom": "^15.6.1", "react-images-uploader": "^1.1.0", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js index ba5878f6326..771422d0c14 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -16,41 +16,40 @@ * under the License. */ -import React, {Component} from 'react'; -import {BrowserRouter as Router, Redirect, Route, Switch} from 'react-router-dom' import './App.css' -import {BaseLayout, Create, Login, NotFound} from './components' -import createHistory from 'history/createBrowserHistory'; - -const history = createHistory({basename:'/publisher'}); +import React, {Component} from 'react'; +import createHistory from 'history/createHashHistory'; +import {HashRouter as Router, Redirect, Route, Switch} from 'react-router-dom' +import {BaseLayout, Create, Login, NotFound, PublisherOverview} from './components' +const history = createHistory({basename: '/publisher'}); class Base extends Component { constructor() { super(); this.state = { - user: "m" + user: "s" } } render() { if (this.state.user) { - return( + return (
- - - - - - - - - + + + {/**/} + {/**/} + + {/**/} + + + - +
@@ -62,19 +61,19 @@ class Base extends Component { } class Publisher extends Component { - render() { - return ( -
- - - - - - - -
- ); - } + render() { + return ( +
+ + + + + + + +
+ ); + } } export default Publisher; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js index 9eb827eb700..58fa7aa8ecb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js @@ -15,3 +15,171 @@ * specific language governing permissions and limitations * under the License. */ + +import React, {Component} from 'react'; +import Dialog from 'material-ui/Dialog'; +import {withRouter} from 'react-router-dom'; +import {Step1, Step2, Step3} from './Forms'; +import FlatButton from 'material-ui/FlatButton'; +import RaisedButton from 'material-ui/RaisedButton'; +import {Card, CardActions, CardTitle} from 'material-ui/Card'; +import {Step, StepLabel, Stepper,} from 'material-ui/Stepper'; + +class Create extends Component { + constructor() { + super(); + this.setStepData.bind(this); + this.removeStepData.bind(this); + this.handleSubmit.bind(this); + this.handleCancel.bind(this); + this.handleYes.bind(this); + this.handleNo.bind(this); + this.state = { + finished: false, + stepIndex: 0, + stepData: [], + isDialogOpen: false + }; + } + + handleNext = () => { + const {stepIndex} = this.state; + this.setState({ + stepIndex: stepIndex + 1, + finished: stepIndex >= 2, + }); + }; + + handleSubmit = () => { + console.log(this.state.stepData); + }; + + handleCancel = () => { + this.setState({isDialogOpen: true}); + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.removeStepData(); + this.setState({stepIndex: stepIndex - 1}); + } + }; + + setStepData = (step, data) => { + console.log(step, data, this.state.stepData); + let tmpStepData = this.state.stepData; + tmpStepData.push({step: step, data: data}); + + this.setState({stepData: tmpStepData}) + }; + + /** + * Remove the last data point + * */ + removeStepData = () => { + let tempData = this.state.stepData; + tempData.pop(); + this.setState({stepData: tempData}); + }; + + handleYes = () => { + this.setState({finished: false, stepIndex: 0, stepData: [], isDialogOpen: false}); + }; + + handleNo = () => { + this.setState({isDialogOpen: false}); + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return ; + case 1: + return ; + case 2: + return ; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + + render() { + const {finished, stepIndex} = this.state; + const contentStyle = {margin: '0 16px'}; + + const actions = [ + , + , + ]; + + + return ( +
+ + + + {/** + * The stepper goes here. + */} + +
+ + + Select Application Platform + + + Enter Application Details + + + Release + + +
+ {finished ? ( +
+

Create App?

+
+ + + +
+ ) : ( +
+ {this.getStepContent(stepIndex)} +
+ )} +
+
+
+
+ + Do you really want to cancel? + +
); + } +} + +export default withRouter(Create); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js new file mode 100644 index 00000000000..a8fbec5e844 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, {Component} from 'react'; +import RaisedButton from 'material-ui/RaisedButton'; +import FlatButton from 'material-ui/FlatButton'; +import TextField from 'material-ui/TextField'; +import SelectField from 'material-ui/SelectField'; +import MenuItem from 'material-ui/MenuItem'; + +class Step1 extends Component { + constructor() { + super(); + this.state = { + finished: false, + stepIndex: 0, + store: 1, + platform: 1, + stepData: [] + }; + } + + handleNext = () => { + this.props.handleNext(); + }; + + setStepData() { + this.props.setData("step1", {step:"Dfds"}); + this.handleNext.bind(this); + } + + handleClick() { + this.setStepData(); + this.handleNext(); + } + + handlePrev() { + this.props.handlePrev(); + } + + onChangePlatform = (event, index, value) => { + this.setState({platform: value}); + }; + + onChangeStore = (event, index, value) => { + this.setState({store: value}); + }; + + render() { + const {finished, stepIndex} = this.state; + const contentStyle = {margin: '0 16px'}; + return ( +
+
+
+
+
+ + + +
+ + + + + +
+
+ + +
+
+
+
+ ); + } +} + +export default Step1; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js new file mode 100644 index 00000000000..166e3e1c688 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, {Component} from 'react'; +import RaisedButton from 'material-ui/RaisedButton'; +import FlatButton from 'material-ui/FlatButton'; + +class Step2 extends Component { + constructor() { + super(); + } + + handleNext() { + this.props.handleNext(); + } + + handlePrev() { + this.props.handlePrev(); + } + + render() { + const contentStyle = {margin: '0 16px'}; + return ( +
+ Step2 +
+
+ + +
+
+
+ ); + } +} + +export default Step2; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js new file mode 100644 index 00000000000..305c55d688f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, {Component} from 'react'; +import RaisedButton from 'material-ui/RaisedButton'; +import FlatButton from 'material-ui/FlatButton'; + +class Step3 extends Component { + constructor() { + super(); + } + + handleFinish() { + this.props.handleFinish(); + } + + handlePrev() { + this.props.handlePrev(); + } + + render() { + const contentStyle = {margin: '0 16px'}; + return ( +
+ Step3 +
+
+ + +
+
+
+ ); + } +} + +export default Step3; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/index.js new file mode 100644 index 00000000000..9f5ad0bdacd --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/index.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import Step1 from './Step1'; +import Step2 from './Step2'; +import Step3 from './Step3'; + +export {Step1, Step2, Step3}; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js index 6260aa6829b..c6b218464c2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js @@ -19,12 +19,17 @@ import React, {Component} from 'react'; import AppBar from 'material-ui/AppBar'; import Drawer from 'material-ui/Drawer'; -import MenuItem from 'material-ui/MenuItem'; -import Menu from 'material-ui/Menu'; import IconButton from 'material-ui/IconButton'; -import Notifications from 'material-ui/svg-icons/social/notifications'; +import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; +import Apps from 'material-ui/svg-icons/navigation/apps'; +import DevicesOther from 'material-ui/svg-icons/hardware/devices-other'; import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; +import Dashboard from 'material-ui/svg-icons/action/dashboard'; +import Add from 'material-ui/svg-icons/content/add-circle'; +import Feedback from 'material-ui/svg-icons/action/feedback'; import {withRouter} from 'react-router-dom' +import Badge from 'material-ui/Badge'; +import {List, ListItem} from 'material-ui/List'; /** @@ -35,9 +40,48 @@ import {withRouter} from 'react-router-dom' * */ class BaseLayout extends Component { + constructor() { + super(); + this.state = { + notifications: 0, + user: 'Admin' + } + } + + componentWillMount() { + + } + handleApplicationClick() { - console.log("Application"); - window.location = '/publisher/assets/apps'; + this.handleHistory('/assets/apps'); + } + + handleOverviewClick() { + this.handleHistory('/overview'); + } + + handleApplicationCreateClick() { + this.handleHistory('/assets/apps/create'); + } + + handlePlatformClick() { + this.handleHistory('/assets/platforms'); + } + + handlePlatformCreateClick() { + this.handleHistory('/assets/platforms/create'); + } + + handleReviewClick() { + this.handleHistory('/assets/reviews'); + } + + /** + * The method to update the history. + * to: The URL to route. + * */ + handleHistory(to) { + this.props.history.push(to); } render() { @@ -46,9 +90,15 @@ class BaseLayout extends Component { - - - + + + + + { console.log("Clicked") }}> @@ -58,12 +108,41 @@ class BaseLayout extends Component { } />
- - - Applications - Platforms - Reviews - + + + }/> + } + initiallyOpen={false} + primaryTogglesNestedList={true} + onClick={this.handleApplicationClick.bind(this)} + nestedItems={[ + } + />]} + /> + } + initiallyOpen={false} + primaryTogglesNestedList={true} + onClick={this.handlePlatformClick.bind(this)} + nestedItems={[ + } + />]} + /> + }/> +
+ Overview +
+ ); + } +} + +export default PublisherOverview; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js index f93c7b48ad2..c9197de1041 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js @@ -16,27 +16,40 @@ * under the License. */ -import React, { Component } from 'react'; -import {Card, CardTitle, CardActions, CardMedia} from 'material-ui/Card'; +import React, {Component} from 'react'; +import {Redirect, Switch} from 'react-router-dom'; +import {Card, CardActions, CardMedia, CardTitle} from 'material-ui/Card'; import RaisedButton from 'material-ui/RaisedButton'; -import { ValidatorForm, TextValidator} from 'react-material-ui-form-validator'; +import {TextValidator, ValidatorForm} from 'react-material-ui-form-validator'; import Checkbox from 'material-ui/Checkbox'; +import qs from 'qs'; + +//todo: remove the {TextValidator, ValidatorForm} and implement it manually. class Login extends Component { constructor() { super(); this.state = { + isLoggedIn: true, + referrer: "/", userName: "", password: "", rememberMe: true } } + componentDidMount() { + let queryString = this.props.location.search; + console.log(queryString); + queryString = queryString.replace(/^\?/, ''); + /* With QS version up we can directly use {ignoreQueryPrefix: true} option */ + let params = qs.parse(queryString); + if (params.referrer) { + this.setState({referrer: params.referrer}); + } + } handleLogin(event) { - console.log(this.state); - - event.preventDefault(); } @@ -45,7 +58,7 @@ class Login extends Component { { userName: event.target.value } - ); + ); } onPasswordChange(event) { @@ -65,56 +78,62 @@ class Login extends Component { } render() { - return ( -
- - {/*TODO: Style the components.*/} - - - - - - - - - console.log(errors)}> - - -
- -
- -
- -
- -
-
-
); + + if (!this.state.isLoggedIn) { + return ( +
+ + {/*TODO: Style the components.*/} + + + + + + console.log(errors)}> + + +
+ +
+ +
+ +
+ +
+
+
); + } else { + return ( + + + + ); + } + } } - -export default Login; \ No newline at end of file +export default Login; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js index f166fc81be0..dde690556be 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js @@ -20,9 +20,10 @@ import Login from './User/Login/Login' import BaseLayout from './Base/BaseLayout' import Create from './Application/Create' import NotFound from './Error/NotFound' +import PublisherOverview from './Overview/PublisherOverview' /** * Contains all UI components related to Application, Login and Platform */ -export {Login, BaseLayout, Create, NotFound}; \ No newline at end of file +export {Login, BaseLayout, Create, NotFound, PublisherOverview}; \ No newline at end of file From 4d16d73b232cf0e6d2cf2dea95afbd404f1d75ab Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Sun, 20 Aug 2017 13:39:37 +0530 Subject: [PATCH 07/13] Created the Step 2 and 3 basic forms. Code Formatting. --- .../src/components/Application/Forms/Step1.js | 24 ++-- .../src/components/Application/Forms/Step2.js | 136 ++++++++++++++++-- .../src/components/Application/Forms/Step3.js | 72 +++++++--- .../src/components/Base/BaseLayout.js | 14 +- .../src/components/User/Login/Login.js | 6 +- 5 files changed, 198 insertions(+), 54 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js index a8fbec5e844..ca3e050c1c8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js @@ -17,11 +17,11 @@ */ import React, {Component} from 'react'; -import RaisedButton from 'material-ui/RaisedButton'; -import FlatButton from 'material-ui/FlatButton'; +import MenuItem from 'material-ui/MenuItem'; import TextField from 'material-ui/TextField'; +import FlatButton from 'material-ui/FlatButton'; import SelectField from 'material-ui/SelectField'; -import MenuItem from 'material-ui/MenuItem'; +import RaisedButton from 'material-ui/RaisedButton'; class Step1 extends Component { constructor() { @@ -40,7 +40,7 @@ class Step1 extends Component { }; setStepData() { - this.props.setData("step1", {step:"Dfds"}); + this.props.setData("step1", {step: "Dfds"}); this.handleNext.bind(this); } @@ -73,31 +73,31 @@ class Step1 extends Component { hintText="Enter a title for your application." floatingLabelText="Title*" floatingLabelFixed={true} - />
+ />
- - -
+ + +
- - - + + +
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js index 166e3e1c688..7b89a6bc0c7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step2.js @@ -16,13 +16,48 @@ * under the License. */ +import Chip from 'material-ui/Chip'; import React, {Component} from 'react'; -import RaisedButton from 'material-ui/RaisedButton'; +import MenuItem from 'material-ui/MenuItem'; +import TextField from 'material-ui/TextField'; import FlatButton from 'material-ui/FlatButton'; +import SelectField from 'material-ui/SelectField'; +import RaisedButton from 'material-ui/RaisedButton'; class Step2 extends Component { constructor() { super(); + this.state = { + tags: [], + defValue: "", + category: 1 + }; + + this.styles = { + chip: { + margin: 4, + }, + wrapper: { + display: 'flex', + flexWrap: 'wrap', + }, + }; + + } + + addTags(event) { + let tags = this.state.tags; + if (event.charCode === 13) { + event.preventDefault(); + tags.push({key: Math.floor(Math.random() * 1000), value: event.target.value}); + this.setState({tags, defValue: ""}, console.log(this.state.tags)); + } + } + + handleTagChange(event) { + let defaultValue = this.state.defValue; + defaultValue = event.target.value; + this.setState({defValue: defaultValue}) } handleNext() { @@ -33,27 +68,98 @@ class Step2 extends Component { this.props.handlePrev(); } + + handleRequestDelete = (key) => { + if (key === 3) { + alert('Why would you want to delete React?! :)'); + return; + } + + this.chipData = this.state.tags; + const chipToDelete = this.chipData.map((chip) => chip.key).indexOf(key); + this.chipData.splice(chipToDelete, 1); + this.setState({tags: this.chipData}); + }; + + renderChip(data) { + console.log(data); + return ( + this.handleRequestDelete(data.key)} + style={this.styles.chip} + > + {data.value} + + ); + } + render() { const contentStyle = {margin: '0 16px'}; return ( -
- Step2 +
+
-
- - +
+
+
+
+
+
+ {this.state.tags.map(this.renderChip, this)}
+
+ + +
+
+ +
+ +
+
); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js index 305c55d688f..fb46507d06f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step3.js @@ -17,12 +17,20 @@ */ import React, {Component} from 'react'; -import RaisedButton from 'material-ui/RaisedButton'; +import Toggle from 'material-ui/Toggle'; +import MenuItem from 'material-ui/MenuItem'; +import TextField from 'material-ui/TextField'; import FlatButton from 'material-ui/FlatButton'; +import SelectField from 'material-ui/SelectField'; +import RaisedButton from 'material-ui/RaisedButton'; class Step3 extends Component { constructor() { super(); + this.state = { + showForm: false, + releaseChannel: 1 + } } handleFinish() { @@ -33,27 +41,57 @@ class Step3 extends Component { this.props.handlePrev(); } + handleToggle() { + let hide = this.state.showForm; + this.setState({showForm: !hide}); + } + + render() { const contentStyle = {margin: '0 16px'}; return ( -
- Step3 -
-
- - -
+
+
+ + + {/*If toggle is true, the release form will be shown.*/} + {!this.state.showForm ?
:
+ + + + +
+
+
} + +
+ +
+
); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js index c6b218464c2..cfea271a83c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Base/BaseLayout.js @@ -16,20 +16,20 @@ * under the License. */ +import Badge from 'material-ui/Badge'; import React, {Component} from 'react'; import AppBar from 'material-ui/AppBar'; import Drawer from 'material-ui/Drawer'; +import {withRouter} from 'react-router-dom'; import IconButton from 'material-ui/IconButton'; -import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; +import {List, ListItem} from 'material-ui/List'; import Apps from 'material-ui/svg-icons/navigation/apps'; -import DevicesOther from 'material-ui/svg-icons/hardware/devices-other'; -import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; -import Dashboard from 'material-ui/svg-icons/action/dashboard'; import Add from 'material-ui/svg-icons/content/add-circle'; import Feedback from 'material-ui/svg-icons/action/feedback'; -import {withRouter} from 'react-router-dom' -import Badge from 'material-ui/Badge'; -import {List, ListItem} from 'material-ui/List'; +import Dashboard from 'material-ui/svg-icons/action/dashboard'; +import DevicesOther from 'material-ui/svg-icons/hardware/devices-other'; +import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; +import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; /** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js index c9197de1041..67b4e317192 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js @@ -16,13 +16,13 @@ * under the License. */ +import qs from 'qs'; import React, {Component} from 'react'; +import Checkbox from 'material-ui/Checkbox'; import {Redirect, Switch} from 'react-router-dom'; -import {Card, CardActions, CardMedia, CardTitle} from 'material-ui/Card'; import RaisedButton from 'material-ui/RaisedButton'; +import {Card, CardActions, CardTitle} from 'material-ui/Card'; import {TextValidator, ValidatorForm} from 'react-material-ui-form-validator'; -import Checkbox from 'material-ui/Checkbox'; -import qs from 'qs'; //todo: remove the {TextValidator, ValidatorForm} and implement it manually. From cbc061f739128dae9ba2cbda65eefb503b47eeb5 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Mon, 21 Aug 2017 14:14:34 +0530 Subject: [PATCH 08/13] Changes as per the comments. --- .../pom.xml | 74 +++++-------------- .../src/main/resources/publisher/.babelrc | 2 +- .../src/main/resources/publisher/package.json | 2 + .../resources/publisher/public/index.html | 17 +++++ .../src/main/resources/publisher/src/App.js | 40 +++++++--- .../{Create.js => ApplicationCreate.js} | 52 ++++++++++++- .../Application/ApplicationListing.js | 13 ++++ .../{AppView.js => ApplicationView.js} | 13 ++++ .../src/components/Application/Forms/Step1.js | 47 +++++++++--- .../src/components/Application/Forms/Step2.js | 56 ++++++++++++-- .../src/components/Application/Forms/Step3.js | 36 ++++++++- .../src/components/Base/BaseLayout.js | 3 +- .../src/components/Error/NotFound.js | 13 ++-- .../components/Overview/PublisherOverview.js | 8 +- .../Platform/{Create.js => PlatformCreate.js} | 21 ++++++ .../components/Platform/PlatformListing.js | 21 ++++++ .../src/components/Platform/PlatformView.js | 21 ++++++ .../src/components/Reviews/ReviewListing.js | 21 ++++++ .../src/components/Reviews/ReviewView.js | 21 ++++++ .../src/components/UIComponents/DataTable.js | 21 ++++++ .../src/components/UIComponents/SimpleForm.js | 17 ----- .../src/components/User/Login/Login.js | 28 +++++-- .../src/components/User/Logout/Logout.js | 0 .../publisher/src/components/index.js | 13 ++-- .../src/main/resources/publisher/src/index.js | 7 +- .../publisher/src/stores/ApplicationStore.js | 19 +++++ .../publisher/src/stores/PlatformStore.js | 1 + .../publisher/src/stores/ReviewStore.js | 2 + .../resources/publisher/src/stores/index.js | 9 ++- .../resources/publisher/webpack.config.js | 17 +++++ 30 files changed, 479 insertions(+), 136 deletions(-) rename components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/{Create.js => ApplicationCreate.js} (79%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/{AppView.js => ApplicationView.js} (72%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/{Create.js => PlatformCreate.js} (67%) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Logout/Logout.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml index cb06ef09800..8f8412c9afe 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml @@ -1,4 +1,21 @@ + @@ -9,18 +26,9 @@ application-mgt 3.0.46-SNAPSHOT - org.wso2.carbon.device.application.mgt.publisher.ui 3.0.46-SNAPSHOT - - - - - - - - @@ -77,36 +85,6 @@ - - - npm run build (compile) @@ -122,21 +100,6 @@ - - - - - - - - - - - - - - - ${npm.working.dir} @@ -165,5 +128,4 @@ build_prod ./src/main/ - - \ No newline at end of file + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc index 02f08fb6c0f..3c078e9f990 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc @@ -2,4 +2,4 @@ "presets": [ "es2015" ] -} \ No newline at end of file +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json index fe5f46e4210..804eea3d0de 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json @@ -15,9 +15,11 @@ "latest-version": "^3.1.0", "material-ui": "^0.19.0", "material-ui-datatables": "^0.18.2", + "prop-types": "^15.5.10", "qs": "^6.5.0", "react": "^15.6.1", "react-dom": "^15.6.1", + "react-dropzone": "^4.1.0", "react-images-uploader": "^1.1.0", "react-material-ui-form-validator": "^0.5.0", "react-modal": "^2.2.2", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html index e684fd6f875..b7e1fc8d4d8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html @@ -1,4 +1,21 @@ + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js index 771422d0c14..faa4e14359d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -20,15 +20,26 @@ import './App.css' import React, {Component} from 'react'; import createHistory from 'history/createHashHistory'; import {HashRouter as Router, Redirect, Route, Switch} from 'react-router-dom' -import {BaseLayout, Create, Login, NotFound, PublisherOverview} from './components' +import {BaseLayout, ApplicationCreate, Login, NotFound, PublisherOverview, PlatformCreate} from './components' const history = createHistory({basename: '/publisher'}); +/** + * This component defines the layout and the routes for the app. + * All the content will be loaded inside the Base component. + * The base component includes the Core layout and the routers according to which the content will be displayed. + * + * The Router and Route components. + * The Router and Route is used for navigation. + * We specify the component which needs to be rendered for an URL. + * Ex: When navigate to publisher/overview, the overview component will be rendered inside the main layout. + * */ + class Base extends Component { constructor() { super(); this.state = { - user: "s" + user: "admin" } } @@ -40,15 +51,15 @@ class Base extends Component { - {/**/} - {/**/} - - {/**/} - - - - - + + + + + + + + + @@ -60,6 +71,9 @@ class Base extends Component { } } +/** + * This component is referred by the index.js to initiate the application. + * */ class Publisher extends Component { render() { return ( @@ -76,4 +90,8 @@ class Publisher extends Component { } } +Publisher.propTypes = { + user: Object +}; + export default Publisher; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationCreate.js similarity index 79% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationCreate.js index 58fa7aa8ecb..849a994663f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Create.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationCreate.js @@ -25,7 +25,16 @@ import RaisedButton from 'material-ui/RaisedButton'; import {Card, CardActions, CardTitle} from 'material-ui/Card'; import {Step, StepLabel, Stepper,} from 'material-ui/Stepper'; -class Create extends Component { + +/** + * The App Create Component. + * + * Application creation is handled through a Wizard. (We use Material UI Stepper.) + * + * In each step, data will be set to the state separately. + * When the wizard is completed, data will be arranged and sent to the api. + * */ +class ApplicationCreate extends Component { constructor() { super(); this.setStepData.bind(this); @@ -42,6 +51,9 @@ class Create extends Component { }; } + /** + * Handles next button click event. + * */ handleNext = () => { const {stepIndex} = this.state; this.setState({ @@ -50,14 +62,25 @@ class Create extends Component { }); }; + /** + * Handles form submit. + * */ handleSubmit = () => { console.log(this.state.stepData); }; + /** + * Handles cancel button click event. + * This will show a confirmation dialog to cancel the application creation process. + * */ handleCancel = () => { this.setState({isDialogOpen: true}); }; + /** + * Handled [ < Prev ] button click. + * This clears the data in the current step and returns to the previous step. + * */ handlePrev = () => { const {stepIndex} = this.state; if (stepIndex > 0) { @@ -66,6 +89,9 @@ class Create extends Component { } }; + /** + * Saves form data in each step in to the state. + * */ setStepData = (step, data) => { console.log(step, data, this.state.stepData); let tmpStepData = this.state.stepData; @@ -83,14 +109,31 @@ class Create extends Component { this.setState({stepData: tempData}); }; + /** + * Handles the Yes button in app creation cancellation dialog. + * Clears all the form data and reset the wizard. + * */ handleYes = () => { this.setState({finished: false, stepIndex: 0, stepData: [], isDialogOpen: false}); }; + /** + * Handles No button in app creation cancellation dialog. + * Returns to the same step. + * */ handleNo = () => { this.setState({isDialogOpen: false}); }; + /** + * Defines all the Steps in the stepper. (Wizard) + * + * Extension Point: If any extra steps needed, follow the instructions below. + * 1. Create the required form ./Forms directory. + * 2. Add defined case statements. + * 3. Define the Step in render function. + * + * */ getStepContent(stepIndex) { switch (stepIndex) { case 0: @@ -117,6 +160,9 @@ class Create extends Component { const {finished, stepIndex} = this.state; const contentStyle = {margin: '0 16px'}; + /** + * Defines the dialog box actions. [Yes][No] + * */ const actions = [

Create App?

-
+ @@ -182,4 +228,4 @@ class Create extends Component { } } -export default withRouter(Create); +export default withRouter(ApplicationCreate); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js index 9eb827eb700..d81c32a7905 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.js @@ -15,3 +15,16 @@ * specific language governing permissions and limitations * under the License. */ + +import React, {Component} from 'react'; +import {withRouter} from 'react-router-dom'; + + +/** + * Application List Component. + * */ +class ApplicationListing extends Component{ + +} + +export default withRouter(ApplicationListing); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/AppView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationView.js similarity index 72% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/AppView.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationView.js index 9eb827eb700..3959357f2ec 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/AppView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationView.js @@ -15,3 +15,16 @@ * specific language governing permissions and limitations * under the License. */ + +import React, {Component} from 'react'; +import {withRouter} from 'react-router-dom'; + +/** + * Application view component. + * Shows the details of the application. + * */ +class ApplicationView extends Component{ + +} + +export default withRouter(ApplicationView); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js index ca3e050c1c8..8ce132ba24d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/Forms/Step1.js @@ -23,6 +23,19 @@ import FlatButton from 'material-ui/FlatButton'; import SelectField from 'material-ui/SelectField'; import RaisedButton from 'material-ui/RaisedButton'; +/** + * The first step of the application creation wizard. + * This contains following components: + * * Application Title + * * Store Type + * * Application Platform + * + * Parent Component: Create + * Props: + * 1. handleNext: {type: function, Invokes handleNext function of parent component} + * 2. setData : {type: function, Sets current form data to the state of the parent component} + * 3. removeData: {type: function, Invokes the removeStepData function click of parent} + * */ class Step1 extends Component { constructor() { super(); @@ -35,34 +48,47 @@ class Step1 extends Component { }; } + /** + * Invokes the handleNext function in Create component. + * */ handleNext = () => { this.props.handleNext(); }; + /** + * Persist the current form data to the state. + * */ setStepData() { this.props.setData("step1", {step: "Dfds"}); this.handleNext.bind(this); } + /** + * Handles Next button click. + * Validates the form. + * Sets the data to the state. + * Invokes the handleNext method of Create component. + * */ handleClick() { this.setStepData(); this.handleNext(); } - handlePrev() { - this.props.handlePrev(); - } - + /** + * Triggers when changing the Platform selection. + * */ onChangePlatform = (event, index, value) => { this.setState({platform: value}); }; + /** + * Triggers when changing the Store selection. + * */ onChangeStore = (event, index, value) => { this.setState({store: value}); }; render() { - const {finished, stepIndex} = this.state; const contentStyle = {margin: '0 16px'}; return (
@@ -94,13 +120,10 @@ class Step1 extends Component {
+ +
+
- { - if (key === 3) { - alert('Why would you want to delete React?! :)'); - return; - } - this.chipData = this.state.tags; const chipToDelete = this.chipData.map((chip) => chip.key).indexOf(key); this.chipData.splice(chipToDelete, 1); this.setState({tags: this.chipData}); }; + /** + * Creates Chip array from state.tags. + * */ renderChip(data) { console.log(data); return ( @@ -143,8 +179,14 @@ class Step2 extends Component { >
+ {/*Platform Specific Properties.*/} +
+ fdfdfd +
+
+
{/*If toggle is true, the release form will be shown.*/} - {!this.state.showForm ?
:
+ {!this.state.showForm ?
:
- 404 not found + 404 not found
); } } -export default Error; \ No newline at end of file +export default Error; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js index d4230f44d35..c9640bab151 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Overview/PublisherOverview.js @@ -17,6 +17,13 @@ */ import React, {Component} from 'react'; +/** + * + * ***NEW*** + * The Publisher overview component. + * This component could be used to view app analytics. + * i.e number of overall downloads, ratings ect. + * */ class PublisherOverview extends Component { constructor() { @@ -24,7 +31,6 @@ class PublisherOverview extends Component { } componentWillMount() { - console.log("In Crate") } render() { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/Create.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformCreate.js similarity index 67% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/Create.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformCreate.js index 9eb827eb700..0928586b5af 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/Create.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformCreate.js @@ -15,3 +15,24 @@ * specific language governing permissions and limitations * under the License. */ +import React, {Component} from 'react'; + +/** + * Platform Create component + * */ +class PlatformCreate extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Create Platform +
+ ); + } +} + +export default PlatformCreate; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js index 9eb827eb700..e51137e453a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformListing.js @@ -15,3 +15,24 @@ * specific language governing permissions and limitations * under the License. */ +import React, {Component} from 'react'; + +/** + * Platform Listing component. + * */ +class PlatformListing extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Platform View +
+ ); + } +} + +export default PlatformListing; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js index 9eb827eb700..dce6e9f716d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Platform/PlatformView.js @@ -15,3 +15,24 @@ * specific language governing permissions and limitations * under the License. */ +import React, {Component} from 'react'; + +/** + * Platform view component. + * */ +class PlatformView extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Platform View +
+ ); + } +} + +export default PlatformView; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js index 9eb827eb700..2575b736f7b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewListing.js @@ -15,3 +15,24 @@ * specific language governing permissions and limitations * under the License. */ +import React, {Component} from 'react'; + +/** + * Review Listing. + * */ +class ReviewListing extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Reviews List +
+ ); + } +} + +export default ReviewListing; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js index 9eb827eb700..da5bdac6070 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Reviews/ReviewView.js @@ -15,3 +15,24 @@ * specific language governing permissions and limitations * under the License. */ +import React, {Component} from 'react'; + +/** + * Review details view. + * */ +class ReviewView extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Review +
+ ); + } +} + +export default ReviewView; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js index 9eb827eb700..649d93f32be 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/DataTable.js @@ -15,3 +15,24 @@ * specific language governing permissions and limitations * under the License. */ +import React, {Component} from 'react'; + +/** + * Error page. + * */ +class DataTable extends Component { + + constructor() { + super(); + } + + render() { + return ( +
+ Data Table +
+ ); + } +} + +export default DataTable; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js deleted file mode 100644 index 9eb827eb700..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/UIComponents/SimpleForm.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js index 67b4e317192..72255be8dd5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Login/Login.js @@ -26,6 +26,15 @@ import {TextValidator, ValidatorForm} from 'react-material-ui-form-validator'; //todo: remove the {TextValidator, ValidatorForm} and implement it manually. + +/** + * The Login Component. + * + * This component contains the Login form and methods to handle field change events. + * The user name and password will be set to the state and sent to the api. + * + * If the user is already logged in, it will redirect to the last point where the user was. + * */ class Login extends Component { constructor() { super(); @@ -53,6 +62,9 @@ class Login extends Component { event.preventDefault(); } + /** + * Handles the username field change event. + * */ onUserNameChange(event) { this.setState( { @@ -61,6 +73,9 @@ class Login extends Component { ); } + /** + * Handles the password field change event. + * */ onPasswordChange(event) { this.setState( { @@ -69,12 +84,15 @@ class Login extends Component { ); } - rememberMe() { + /** + * Handles the remember me check. + * */ + handleRememberMe() { this.setState( { rememberMe: !this.state.rememberMe } - ) + ); } render() { @@ -87,13 +105,11 @@ class Login extends Component { - console.log(errors)}> -

-
); @@ -132,7 +147,6 @@ class Login extends Component { ); } - } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Logout/Logout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/User/Logout/Logout.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js index dde690556be..3ed7d23ef64 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/index.js @@ -16,14 +16,15 @@ * under the License. */ -import Login from './User/Login/Login' -import BaseLayout from './Base/BaseLayout' -import Create from './Application/Create' -import NotFound from './Error/NotFound' -import PublisherOverview from './Overview/PublisherOverview' +import Login from './User/Login/Login'; +import NotFound from './Error/NotFound'; +import BaseLayout from './Base/BaseLayout'; +import PlatformCreate from './Platform/PlatformCreate'; +import PublisherOverview from './Overview/PublisherOverview'; +import ApplicationCreate from './Application/ApplicationCreate'; /** * Contains all UI components related to Application, Login and Platform */ -export {Login, BaseLayout, Create, NotFound, PublisherOverview}; \ No newline at end of file +export {Login, BaseLayout, ApplicationCreate, NotFound, PublisherOverview, PlatformCreate}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js index d5ab4c3fe28..e94b5727376 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js @@ -16,12 +16,15 @@ * under the License. */ -import React from 'react'; -import ReactDOM from 'react-dom'; import './index.css'; +import React from 'react'; import Publisher from './App'; +import ReactDOM from 'react-dom'; import registerServiceWorker from './registerServiceWorker'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; +/** + * This is the base js file of the app. All the content will be rendered in the root element. + * */ ReactDOM.render(, document.getElementById('root')); registerServiceWorker(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js index e69de29bb2d..8d3763b6f00 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ApplicationStore.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export class ApplicationStore {}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js index 9eb827eb700..51babc360d5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/PlatformStore.js @@ -15,3 +15,4 @@ * specific language governing permissions and limitations * under the License. */ +export class PlatformStore{}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js index 9eb827eb700..08ce7b2504f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/ReviewStore.js @@ -15,3 +15,5 @@ * specific language governing permissions and limitations * under the License. */ + +export class ReviewStore{}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js index cc77f8a78c0..74161552173 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/stores/index.js @@ -14,4 +14,11 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - */ \ No newline at end of file + */ + +import ReviewStore from './ReviewStore'; +import PlatformStore from './PlatformStore'; +import ApplicationStore from './ApplicationStore'; + + +export {ApplicationStore, PlatformStore, ReviewStore}; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js index c03279bd3df..c6483f4aaa0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ var path = require('path'); const config = { From dc2aa386bfa6561a3273bafe1355f7ae5a3a0811 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Tue, 22 Aug 2017 01:42:16 +0530 Subject: [PATCH 09/13] Fixed license header and removed empty tags. --- .../pom.xml | 9 --- .../resources/publisher/public/index.html | 2 +- .../pom.xml | 76 +++++-------------- .../pom.xml | 17 +++++ .../pom.xml | 17 +++++ 5 files changed, 52 insertions(+), 69 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml index 8f8412c9afe..e7d27b5f748 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml @@ -53,15 +53,6 @@ - - - - - - - - - diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html index b7e1fc8d4d8..39ac2df1c60 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html @@ -1,6 +1,6 @@ @@ -13,11 +30,6 @@ 3.0.46-SNAPSHOT - - - - - @@ -44,15 +56,6 @@ - - - - - - - - - @@ -76,36 +79,6 @@ - - - npm run build (compile) @@ -121,21 +94,6 @@ - - - - - - - - - - - - - - - ${npm.working.dir} diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml index e9da7bcff09..3bb9936115d 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml @@ -1,4 +1,21 @@ + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml index 33f45fc1e08..521c1665051 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml @@ -1,4 +1,21 @@ + From 17c23b9674c8d02eb2d59329eddf7fded823613d Mon Sep 17 00:00:00 2001 From: megala21 Date: Tue, 22 Aug 2017 21:34:04 +0530 Subject: [PATCH 10/13] Fixing some issues --- .../services/ApplicationManagementAPI.java | 95 ++++++++- .../impl/ApplicationManagementAPIImpl.java | 45 ++++- .../application/mgt/common/Application.java | 40 +--- .../services/ApplicationReleaseManager.java | 12 +- .../services/ApplicationStorageManager.java | 12 ++ .../mgt/core/dao/ApplicationDAO.java | 13 +- .../mgt/core/dao/ApplicationReleaseDAO.java | 18 +- .../application/mgt/core/dao/common/Util.java | 4 +- .../GenericApplicationDAOImpl.java | 117 +++++++----- .../GenericApplicationReleaseDAOImpl.java | 81 +++++++- .../mgt/core/impl/ApplicationManagerImpl.java | 24 +-- .../impl/ApplicationReleaseManagerImpl.java | 27 ++- .../impl/ApplicationStorageManagerImpl.java | 180 ++++++++++-------- .../application/mgt/core/util/Constants.java | 5 + .../main/resources/conf/application-mgt.xml | 3 +- .../dbscripts/cdm/application-mgt/h2.sql | 6 +- .../dbscripts/cdm/application-mgt/mysql.sql | 6 +- 17 files changed, 487 insertions(+), 201 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java index ca883183cc4..9c524570bac 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java @@ -232,7 +232,6 @@ public interface ApplicationManagementAPI { required = true) @Valid Application application); - @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -649,4 +648,98 @@ public interface ApplicationManagementAPI { name = "version", value = "Version of the application") @QueryParam("version") String version); + + @GET + @Path("/image-artifacts/{uuid}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Consumes(MediaType.APPLICATION_JSON) + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "DELETE", + value = "Delete the releases of a particular applicaion", + notes = "This will delete the releases or specific release of an application", + tags = "Application Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:application:get") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully deleted the Application release."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while deleting the release of a" + + "particular application.", + response = ErrorResponse.class) + }) + Response getApplicationImageArtifacts( + @ApiParam( + name = "UUID", + value = "Unique identifier of the Application", + required = true) + @PathParam("uuid") String applicationUUID, + @ApiParam( + name = "name", + value = "Name of the artifact to be retrieved", + required = true) + @QueryParam("name") String name, + @ApiParam( + name = "count", + value = "Count of the screen-shot artifact to be retrieved", + required = false) + @QueryParam("count") int count); + + @PUT + @Consumes("application/json") + @Path("/{uuid}/{version}/{channel}") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Make the particular application release as default or not", + notes = "Make the particular application release as default or not", + tags = "Application Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:application-mgt:login") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved the lifecycle states.", + response = List.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting the life-cycle states.", + response = ErrorResponse.class) + }) + Response updateDefaultVersion( + @ApiParam( + name = "UUID", + value = "Unique identifier of the Application", + required = true) + @PathParam("uuid") String applicationUUID, + @ApiParam( + name = "Version", + value = "Version of the Application Release", + required = true) + @PathParam("version") String version, + @ApiParam( + name = "Release Channel", + value = "Release Channel", + required = true) + @PathParam("channel") String channel, + @ApiParam( + name = "isDefault", + value = "Whether to make it default or not", + required = false) + @QueryParam("isDefault") boolean isDefault); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java index e488db3fb58..2c08e5fae78 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java @@ -425,7 +425,50 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { + applicationUUID).build(); } } catch (ApplicationManagementException e) { - log.error("Error while deleting application release with the applicaion UUID " + applicationUUID, e); + log.error("Error while deleting application release with the application UUID " + applicationUUID, e); + return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); + } + } + + @Override + @GET + @Path("/image-artifacts/{uuid}") + public Response getApplicationImageArtifacts(@PathParam("uuid") String applicationUUID, + @QueryParam("name") String name, @QueryParam("count") int count) { + if (name == null || name.isEmpty()) { + return Response.status(Response.Status.BAD_REQUEST).entity("Name should not be null. Name is mandatory to" + + " retrieve the particular image artifact of the release").build(); + } + ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager(); + try { + InputStream imageArtifact = applicationStorageManager.getImageArtifact(applicationUUID, name, count); + FileStreamingOutput fileStreamingOutput = new FileStreamingOutput(imageArtifact); + Response.ResponseBuilder response = Response.status(Response.Status.OK).entity(fileStreamingOutput); + response.header("Content-Disposition", "attachment; filename=\"" + name + "\""); + return response.build(); + } catch (ApplicationStorageManagementException e) { + log.error("Application Storage Management Exception while getting the image artifact " + name + " of " + + "the application with UUID " + applicationUUID, e); + return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); + } + } + + @Override + @PUT + @Consumes("application/json") + @Path("/{uuid}/{version}/{channel}") + public Response updateDefaultVersion(@PathParam("uuid") String applicationUUID, @PathParam("version") String + version, @PathParam("channel") String channel, @QueryParam("isDefault") boolean isDefault) { + ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager(); + try { + applicationReleaseManager.changeDefaultRelease(applicationUUID, version, isDefault, channel); + return Response.status(Response.Status.OK) + .entity("Successfully changed the default version for the " + "release channel " + channel + + " for the application UUID " + applicationUUID).build(); + } catch (ApplicationManagementException e) { + log.error("Application Release Management Exception while changing the default release for the release " + + "channel " + channel + " for the application with UUID " + applicationUUID + " for the version " + + version); return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java index 4fe9a25c384..77c84bdf6a7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java @@ -43,14 +43,8 @@ public class Application { private String description; - private String iconName; - - private String bannerName; - private String videoName; - private List screenshots; - private List tags; private Platform platform; @@ -73,6 +67,8 @@ public class Application { private Visibility visibility; + private int screenShotCount; + private User user; public int getId() { @@ -155,22 +151,6 @@ public class Application { this.description = description; } - public String getIconName() { - return iconName; - } - - public void setIconName(String iconName) { - this.iconName = iconName; - } - - public String getBannerName() { - return bannerName; - } - - public void setBannerName(String bannerName) { - this.bannerName = bannerName; - } - public String getVideoName() { return videoName; } @@ -179,14 +159,6 @@ public class Application { this.videoName = videoName; } - public List getScreenshots() { - return screenshots; - } - - public void setScreenshots(List screenshots) { - this.screenshots = screenshots; - } - public List getTags() { return tags; } @@ -251,6 +223,14 @@ public class Application { this.user = user; } + public void setScreenShotCount (int screenShotCount) { + this.screenShotCount = screenShotCount; + } + + public int getScreenShotCount() { + return screenShotCount; + } + @Override public String toString() { return "UUID : " + uuid + "\tIdentifier : " + identifier + "\tName : " + name + "\tShort Description : " diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java index d0b8d546d0b..db1a852f9be 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java @@ -59,11 +59,15 @@ public interface ApplicationReleaseManager { public List getReleases(String applicationUuid) throws ApplicationManagementException; /** - * To make a release as the default one for an application. - * - * @param id ID of the ApplicationRelease, that need to be made default. + * To make a particular application release as the default / not default-one + * @param uuid UUID of the application + * @param version Version of the application + * @param isDefault is default or not. + * @param releaseChannel Release channel to make the + * @throws ApplicationManagementException Application Management Exception. */ - public void makeDefaultRelease(int id) throws ApplicationManagementException; + public void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel) + throws ApplicationManagementException; /** * To update with a new release for an Application. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java index 8d1f073f10a..860812244ac 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java @@ -83,4 +83,16 @@ public interface ApplicationStorageManager { */ public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws ApplicationStorageManagementException; + + /** + * To get particular image artifact of the application. + * + * @param applicationUUID UUID of the application, to retrieve the image artifact. + * @param name Name of the artifact - icon/banner/screenshot + * @param count Position of a parameter to get the image artifact. + * @return the relevant image artifact. + * @throws ApplicationStorageManagementException Application Storage Management Exception. + */ + public InputStream getImageArtifact(String applicationUUID, String name, int count) throws + ApplicationStorageManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java index 3fbd9ea56ba..6c556757c38 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java @@ -35,15 +35,15 @@ public interface ApplicationDAO { Application createApplication(Application application) throws ApplicationManagementDAOException; - ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException; + ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException; - Application getApplication(String uuid) throws ApplicationManagementDAOException; + Application getApplication(String uuid, int tenantId) throws ApplicationManagementDAOException; - int getApplicationId(String uuid) throws ApplicationManagementDAOException; + int getApplicationId(String uuid, int tenantId) throws ApplicationManagementDAOException; Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException; - void deleteApplication(String uuid) throws ApplicationManagementDAOException; + void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException; int getApplicationCount(Filter filter) throws ApplicationManagementDAOException; @@ -57,10 +57,13 @@ public interface ApplicationDAO { void addRelease(ApplicationRelease release) throws ApplicationManagementDAOException; - void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String username) throws + void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String username, int tenantId) throws ApplicationManagementDAOException; List getNextLifeCycleStates(String applicationUUID, int tenantId) throws ApplicationManagementDAOException; + void updateScreenShotCount(String applicationUUID, int tenantId, int count) throws + ApplicationManagementDAOException; + } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java index 1cb2becfd19..2fce3102667 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java @@ -45,7 +45,8 @@ public interface ApplicationReleaseDAO { * @return ApplicationRelease for the particular version of the given application * @throws ApplicationManagementDAOException Application Management DAO Exception. */ - ApplicationRelease getRelease(String applicationUuid, String versionName) throws ApplicationManagementDAOException; + ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId) throws + ApplicationManagementDAOException; /** * To get all the releases of a particular application. @@ -54,7 +55,8 @@ public interface ApplicationReleaseDAO { * @return list of the application releases * @throws ApplicationManagementDAOException Application Management DAO Exception. */ - List getApplicationReleases(String applicationUUID) throws ApplicationManagementDAOException; + List getApplicationReleases(String applicationUUID, int tenantId) throws + ApplicationManagementDAOException; /** * To update an Application release. @@ -80,4 +82,16 @@ public interface ApplicationReleaseDAO { * @throws ApplicationManagementDAOException Application Management DAO Exception. */ void deleteReleaseProperties(int id) throws ApplicationManagementDAOException; + + /** + * To change the default version of a particular release channel. + * @param uuid UUID of the application + * @param version Version of the application + * @param isDefault true if the request is to make the application as default one unless false + * @throws ApplicationManagementDAOException Application Management DAO Exception. + */ + void changeReleaseDefault(String uuid, String version, boolean isDefault, String releaseChannel, int tenantId) + throws ApplicationManagementDAOException; + + } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java index bb4284b00c4..9354d1bddb8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java @@ -63,10 +63,8 @@ public class Util { application.setIdentifier(rs.getString("IDENTIFIER")); application.setShortDescription(rs.getString("SHORT_DESCRIPTION")); application.setDescription(rs.getString("DESCRIPTION")); - application.setIconName(rs.getString("ICON_NAME")); - application.setBannerName(rs.getString("BANNER_NAME")); + application.setScreenShotCount(rs.getInt("SCREEN_SHOT_COUNT")); application.setVideoName(rs.getString("VIDEO_NAME")); - application.setScreenshots(JSONUtil.jsonArrayStringToList(rs.getString("SCREENSHOTS"))); application.setCreatedAt(rs.getDate("CREATED_AT")); application.setModifiedAt(rs.getDate("MODIFIED_AT")); application.setUser(new User(rs.getString("CREATED_BY"), rs.getInt("TENANT_ID"))); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index b513fd12894..51747a46a7c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -33,7 +33,6 @@ import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; -import org.wso2.carbon.device.application.mgt.core.util.JSONUtil; import java.sql.Connection; import java.sql.Date; @@ -65,34 +64,32 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic ResultSet rs = null; String sql = ""; boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported(); - + int index = 0; try { conn = this.getDBConnection(); - sql += "INSERT INTO APPM_APPLICATION (UUID, IDENTIFIER, NAME, SHORT_DESCRIPTION, DESCRIPTION, ICON_NAME, " - + "BANNER_NAME, VIDEO_NAME, SCREENSHOTS, CREATED_BY, CREATED_AT, MODIFIED_AT, " + sql += "INSERT INTO APPM_APPLICATION (UUID, IDENTIFIER, NAME, SHORT_DESCRIPTION, DESCRIPTION, " + + "VIDEO_NAME, SCREEN_SHOT_COUNT, CREATED_BY, CREATED_AT, MODIFIED_AT, " + "APPLICATION_CATEGORY_ID, PLATFORM_ID, TENANT_ID, LIFECYCLE_STATE_ID, " + "LIFECYCLE_STATE_MODIFIED_AT, LIFECYCLE_STATE_MODIFIED_BY) VALUES " - + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); - stmt.setString(1, application.getUuid()); - stmt.setString(2, application.getIdentifier()); - stmt.setString(3, application.getName()); - stmt.setString(4, application.getShortDescription()); - stmt.setString(5, application.getDescription()); - stmt.setString(6, application.getIconName()); - stmt.setString(7, application.getBannerName()); - stmt.setString(8, application.getVideoName()); - stmt.setString(9, JSONUtil.listToJsonArrayString(application.getScreenshots())); - stmt.setString(10, application.getUser().getUserName()); - stmt.setDate(11, new Date(application.getCreatedAt().getTime())); - stmt.setDate(12, new Date(application.getModifiedAt().getTime())); - stmt.setInt(13, application.getCategory().getId()); - stmt.setInt(14, application.getPlatform().getId()); - stmt.setInt(15, application.getUser().getTenantId()); - stmt.setInt(16, application.getCurrentLifecycle().getLifecycleState().getId()); - stmt.setDate(17, new Date(application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime())); - stmt.setString(18, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy()); + stmt.setString(++index, application.getUuid()); + stmt.setString(++index, application.getIdentifier()); + stmt.setString(++index, application.getName()); + stmt.setString(++index, application.getShortDescription()); + stmt.setString(++index, application.getDescription()); + stmt.setString(++index, application.getVideoName()); + stmt.setInt(++index, application.getScreenShotCount()); + stmt.setString(++index, application.getUser().getUserName()); + stmt.setDate(++index, new Date(application.getCreatedAt().getTime())); + stmt.setDate(++index, new Date(application.getModifiedAt().getTime())); + stmt.setInt(++index, application.getCategory().getId()); + stmt.setInt(++index, application.getPlatform().getId()); + stmt.setInt(++index, application.getUser().getTenantId()); + stmt.setInt(++index, application.getCurrentLifecycle().getLifecycleState().getId()); + stmt.setDate(++index, new Date(application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime())); + stmt.setString(++index, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy()); stmt.executeUpdate(); rs = stmt.getGeneratedKeys(); @@ -112,7 +109,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic @Override - public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException { + public ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application data from the database"); log.debug(String.format("Filter: limit=%s, offset=%", filter.getLimit(), filter.getOffset())); @@ -125,6 +122,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic ApplicationList applicationList = new ApplicationList(); List applications = new ArrayList<>(); Pagination pagination = new Pagination(); + int index = 0; if (filter == null) { throw new ApplicationManagementDAOException("Filter need to be instantiated"); @@ -140,15 +138,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID "; + + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ?"; if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { - sql += "WHERE APP.NAME LIKE ? "; + sql += "AND APP.NAME LIKE ? "; } sql += "LIMIT ?,?;"; stmt = conn.prepareStatement(sql); - int index = 0; + stmt.setInt(++index, tenantId); if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); } @@ -243,11 +241,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public Application getApplication(String uuid) throws ApplicationManagementDAOException { + public Application getApplication(String uuid, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the UUID(" + uuid + ") from the database"); } - Connection conn = null; + Connection conn; PreparedStatement stmt = null; ResultSet rs = null; String sql = ""; @@ -260,10 +258,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ?"; + + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ? AND APP.TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); + stmt.setInt(2, tenantId); rs = stmt.executeQuery(); if (log.isDebugEnabled()) { @@ -301,8 +300,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String userName) throws - ApplicationManagementDAOException { + public void changeLifecycle(String applicationUUID, String lifecycleIdentifier, String userName, int tenantId) + throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Change Life cycle status change " + lifecycleIdentifier + "request received to the DAO " + "level for the application with " + "the UUID '" + applicationUUID + "' from the user " @@ -314,12 +313,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic conn = this.getDBConnection(); String sql = "UPDATE APPM_APPLICATION SET " + "LIFECYCLE_STATE_ID = (SELECT ID FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ?), " - + "LIFECYCLE_STATE_MODIFIED_BY = ?, LIFECYCLE_STATE_MODIFIED_AT = ? WHERE UUID = ?"; + + "LIFECYCLE_STATE_MODIFIED_BY = ?, LIFECYCLE_STATE_MODIFIED_AT = ? WHERE UUID = ? AND TENANT_ID " + + "= ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, lifecycleIdentifier); stmt.setString(2, userName); stmt.setDate(3, new Date(System.currentTimeMillis())); stmt.setString(4, applicationUUID); + stmt.setInt(5, tenantId); stmt.executeUpdate(); } catch (DBConnectionException e) { throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); @@ -341,13 +342,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic String sql = "SELECT STATE.NAME, TRANSITION.DESCRIPTION, TRANSITION.PERMISSION FROM ( SELECT * FROM " + "APPM_LIFECYCLE_STATE ) STATE RIGHT JOIN (SELECT * FROM APPM_LIFECYCLE_STATE_TRANSITION WHERE " - + "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ?)) " + + "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)) " + "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID"; try { connection = this.getDBConnection(); preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, applicationUUID); + preparedStatement.setInt(2, tenantId); resultSet = preparedStatement.executeQuery(); List lifecycleStateTransitions = new ArrayList<>(); @@ -370,6 +372,31 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } } + @Override + public void updateScreenShotCount(String applicationUUID, int tenantId, int count) + throws ApplicationManagementDAOException { + Connection connection; + PreparedStatement statement = null; + String sql = "UPDATE APPM_APPLICATION SET SCREEN_SHOT_COUNT = ? where UUID = ? and TENANT_ID = ?"; + + try { + connection = this.getDBConnection(); + statement = connection.prepareStatement(sql); + statement.setInt(1, count); + statement.setString(2, applicationUUID); + statement.setInt(3, tenantId); + + } catch (DBConnectionException e) { + throw new ApplicationManagementDAOException("Database connection while trying to update the screen-shot " + + "count for the application with UUID " + applicationUUID + " for the tenant " + tenantId); + } catch (SQLException e) { + throw new ApplicationManagementDAOException("SQL exception while executing the query '" + sql + "' .", e); + } finally { + Util.cleanupResources(statement, null); + } + + } + @Override public Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException { Connection conn; @@ -380,9 +407,9 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic conn = this.getDBConnection(); int index = 0; sql += "UPDATE APPM_APPLICATION SET NAME = IFNULL (?, NAME), SHORT_DESCRIPTION = IFNULL " - + "(?, SHORT_DESCRIPTION), DESCRIPTION = IFNULL (?, DESCRIPTION), ICON_NAME = IFNULL (?, ICON_NAME)" - + ", BANNER_NAME = IFNULL (?, BANNER_NAME), VIDEO_NAME = IFNULL (?, VIDEO_NAME), " - + "SCREENSHOTS = IFNULL (?, SCREENSHOTS), MODIFIED_AT = IFNULL (?, MODIFIED_AT), "; + + "(?, SHORT_DESCRIPTION), DESCRIPTION = IFNULL (?, DESCRIPTION), SCREEN_SHOT_COUNT = IFNULL (?, " + + "SCREEN_SHOT_COUNT), VIDEO_NAME = IFNULL (?, VIDEO_NAME), " + + "MODIFIED_AT = IFNULL (?, MODIFIED_AT), "; if (application.getPayment() != null) { sql += " IS_FREE = IFNULL (?, IS_FREE), "; @@ -404,10 +431,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic stmt.setString(++index, application.getName()); stmt.setString(++index, application.getShortDescription()); stmt.setString(++index, application.getDescription()); - stmt.setString(++index, application.getIconName()); - stmt.setString(++index, application.getBannerName()); + stmt.setInt(++index, application.getScreenShotCount()); stmt.setString(++index, application.getVideoName()); - stmt.setString(++index, JSONUtil.listToJsonArrayString(application.getScreenshots())); stmt.setDate(++index, new Date(application.getModifiedAt().getTime())); if (application.getPayment() != null) { stmt.setBoolean(++index, application.getPayment().isFreeApp()); @@ -427,7 +452,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic stmt.setString(++index, application.getUuid()); stmt.executeUpdate(); - application.setId(getApplicationId(application.getUuid())); + application.setId(getApplicationId(application.getUuid(), tenantId)); sql = "DELETE FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID = ?"; stmt = conn.prepareStatement(sql); @@ -499,14 +524,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public void deleteApplication(String uuid) throws ApplicationManagementDAOException { + public void deleteApplication(String uuid, int tenantId) throws ApplicationManagementDAOException { Connection conn; PreparedStatement stmt = null; try { conn = this.getDBConnection(); - String sql = "DELETE FROM APPM_APPLICATION WHERE UUID = ?"; + String sql = "DELETE FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); + stmt.setInt(2, tenantId); stmt.executeUpdate(); } catch (DBConnectionException e) { @@ -561,7 +587,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public int getApplicationId(String uuid) throws ApplicationManagementDAOException { + public int getApplicationId(String uuid, int tenantId) throws ApplicationManagementDAOException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; @@ -569,9 +595,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic int id = 0; try { conn = this.getDBConnection(); - sql = "SELECT ID FROM APPM_APPLICATION WHERE UUID = ?"; + sql = "SELECT ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); + stmt.setInt(2, tenantId); rs = stmt.executeQuery(); if (rs.next()) { id = rs.getInt(1); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index 50d39a780df..163326f075f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -27,7 +27,12 @@ import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; -import java.sql.*; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -44,6 +49,10 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; + + if (applicationRelease.isDefault()) { + + } String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RESOURCE, RELEASE_CHANNEL ," + "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)"; int index = 0; @@ -79,13 +88,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } @Override - public ApplicationRelease getRelease(String applicationUuid, String versionName) + public ApplicationRelease getRelease(String applicationUuid, String versionName, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE VERSION_NAME = ? AND APPM_APPLICATION_ID = " - + "(SELECT ID FROM APPM_APPLICATION WHERE UUID = ?)"; + + "(SELECT ID FROM APPM_APPLICATION WHERE UUID = ? and TENANT_ID = ?)"; ApplicationRelease applicationRelease = null; ResultSet rsProperties = null; @@ -94,6 +103,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements statement = connection.prepareStatement(sql); statement.setString(1, versionName); statement.setString(2, applicationUuid); + statement.setInt(3, tenantId); resultSet = statement.executeQuery(); if (resultSet.next()) { @@ -132,13 +142,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } @Override - public List getApplicationReleases(String applicationUUID) + public List getApplicationReleases(String applicationUUID, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; String sql = "SELECT * FROM APPM_APPLICATION_RELEASE WHERE APPM_APPLICATION_ID = (SELECT ID FROM " - + "APPM_APPLICATION WHERE UUID = ?)"; + + "APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)"; List applicationReleases = new ArrayList<>(); ResultSet rsProperties = null; @@ -146,6 +156,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements connection = this.getDBConnection(); statement = connection.prepareStatement(sql); statement.setString(1, applicationUUID); + statement.setInt(2, tenantId); resultSet = statement.executeQuery(); while (resultSet.next()) { @@ -264,6 +275,40 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } } + @Override + public void changeReleaseDefault(String uuid, String version, boolean isDefault, String releaseChannel, + int tenantId) throws ApplicationManagementDAOException { + Connection connection; + PreparedStatement statement = null; + String sql = "UPDATE APPM_APPLICATION_RELEASE SET IS_DEFAULT = ? AND RELEASE_CHANNEL = ? WHERE " + + "APPM_APPLICATION_ID = (SELECT ID from APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?) " + + "AND VERSION_NAME = ?"; + + try { + if (isDefault) { + removeDefaultReleases(uuid, releaseChannel, tenantId); + } + connection = this.getDBConnection(); + statement = connection.prepareStatement(sql); + statement.setBoolean(1, isDefault); + statement.setString(2, releaseChannel.toUpperCase()); + statement.setString(3, uuid); + statement.setInt(4, tenantId); + statement.setString(5, version); + statement.executeUpdate(); + } catch (DBConnectionException e) { + throw new ApplicationManagementDAOException( + "Database Connection exception while try to change the " + "default release of the release channel " + + releaseChannel + " for the application " + uuid, e); + } catch (SQLException e) { + throw new ApplicationManagementDAOException( + "SQL Exception while trying to change the default release of " + "the release channel " + + releaseChannel + " for the application " + uuid, e); + } finally { + Util.cleanupResources(statement, null); + } + } + /** * To insert the application release properties. * @param connection Database Connection @@ -294,4 +339,30 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } } } + + /** + * To make all the releases of particular release channel as non-default ones. + * + * @param uuid UUID of the Application. + * @param releaseChannel ReleaseChannel for which we need to make all the releases as non-default ones. + * @param tenantId ID of the tenant. + * @throws DBConnectionException Database Connection Exception. + * @throws SQLException SQL Exception. + */ + private void removeDefaultReleases(String uuid, String releaseChannel, int tenantId) + throws DBConnectionException, SQLException { + PreparedStatement statement = null; + try { + Connection connection = this.getDBConnection(); + String sql = "UPDATE APPM_APPLICATION_RELEASE SET IS_DEFAULT = FALSE WHERE APPM_APPLICATION_ID = (SELECT " + + "ID from APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?) AND RELEASE_CHANNEL = ?"; + statement = connection.prepareStatement(sql); + statement.setString(1, uuid); + statement.setInt(2, tenantId); + statement.setString(3, releaseChannel.toUpperCase()); + statement.executeUpdate(); + } finally { + Util.cleanupResources(statement, null); + } + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 837ba1ea7c8..f9f8dae6807 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -46,7 +46,6 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -158,10 +157,10 @@ public class ApplicationManagerImpl implements ApplicationManager { try { ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); ConnectionManagerUtil.beginDBTransaction(); - int appId = applicationDAO.getApplicationId(uuid); + int appId = applicationDAO.getApplicationId(uuid, tenantId); applicationDAO.deleteTags(appId); applicationDAO.deleteProperties(appId); - applicationDAO.deleteApplication(uuid); + applicationDAO.deleteApplication(uuid, tenantId); ConnectionManagerUtil.commitDBTransaction(); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); @@ -174,15 +173,14 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public ApplicationList getApplications(Filter filter) throws ApplicationManagementException { - + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { ConnectionManagerUtil.openDBConnection(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); - return applicationDAO.getApplications(filter); + return applicationDAO.getApplications(filter, tenantId); } finally { ConnectionManagerUtil.closeDBConnection(); } - } @Override @@ -190,6 +188,7 @@ public class ApplicationManagerImpl implements ApplicationManager { ApplicationManagementException { boolean isAvailableNextState = false; String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); List nextLifeCycles = getLifeCycleStates(applicationUuid); for (LifecycleStateTransition lifecycleStateTransition : nextLifeCycles) { @@ -210,7 +209,7 @@ public class ApplicationManagerImpl implements ApplicationManager { try { ConnectionManagerUtil.beginDBTransaction(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); - applicationDAO.changeLifecycle(applicationUuid, lifecycleIdentifier, userName); + applicationDAO.changeLifecycle(applicationUuid, lifecycleIdentifier, userName, tenantId); ConnectionManagerUtil.commitDBTransaction(); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); @@ -278,20 +277,15 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public Application getApplication(String uuid) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationDAO().getApplication(uuid); + return DAOFactory.getApplicationDAO().getApplication(uuid, tenantId); } finally { ConnectionManagerUtil.closeDBConnection(); } } - public void uploadArtifacts(String applicationUUID, InputStream iconFileStream, InputStream bannerFileStream, - List screenShotStreams) - throws ApplicationManagementException { - - } - /** * To check whether current user is application owner or admin. * @@ -310,7 +304,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } try { ConnectionManagerUtil.openDBConnection(); - Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID); + Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID, tenantId); return application.getUser().getUserName().equals(userName) && application.getUser().getTenantId() == tenantId; } finally { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java index 39eb043c826..b405f8f3dba 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.application.mgt.core.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; @@ -64,6 +65,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager @Override public ApplicationRelease getRelease(String applicationUuid, String version) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); Application application = validateApplication(applicationUuid); if (log.isDebugEnabled()) { log.debug("Application release retrieval request is received for the application " + @@ -71,7 +73,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version); + return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version, tenantId); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -79,6 +81,7 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager @Override public List getReleases(String applicationUuid) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); Application application = validateApplication(applicationUuid); if (log.isDebugEnabled()) { log.debug("Request is received to retrieve all the releases related with the application " + @@ -86,15 +89,33 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid); + return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid, tenantId); } finally { ConnectionManagerUtil.closeDBConnection(); } } @Override - public void makeDefaultRelease(int id) throws ApplicationManagementException { + public void changeDefaultRelease(String uuid, String version, boolean isDefault, String releaseChannel) throws + ApplicationManagementException { + Application application = validateApplication(uuid); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + if (log.isDebugEnabled()) { + log.debug("Request received to change the default release for the release channel " + releaseChannel + + "for the application " + application.toString()); + } + try { + ConnectionManagerUtil.beginDBTransaction(); + DAOFactory.getApplicationReleaseDAO() + .changeReleaseDefault(uuid, version, isDefault, releaseChannel, tenantId); + ConnectionManagerUtil.commitDBTransaction(); + } catch (ApplicationManagementDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + throw e; + } finally { + ConnectionManagerUtil.closeDBConnection(); + } } @Override diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java index c5882ef1d8f..2a72e7ef551 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -21,12 +21,18 @@ package org.wso2.carbon.device.application.mgt.core.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException; +import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; +import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; +import org.wso2.carbon.device.application.mgt.core.dao.common.DAOFactory; +import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; +import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.Constants; import java.io.File; @@ -36,6 +42,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Arrays; import java.util.List; /** @@ -47,18 +54,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public void uploadImageArtifacts(String applicationUUID, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot upload the artifacts to non-existing application."); - } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + Application application = validateApplication(applicationUUID); String artifactDirectoryPath = Constants.artifactPath + application.getId(); if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the artifacts related with application " + applicationUUID @@ -66,10 +63,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } createArtifactDirectory(artifactDirectoryPath); if (iconFileStream != null) { - String iconName = application.getIconName(); - iconName = (iconName == null) ? "icon" : iconName; try { - saveFile(iconFileStream, artifactDirectoryPath + File.separator + iconName); + saveFile(iconFileStream, artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[0]); } catch (IOException e) { throw new ApplicationStorageManagementException( "IO Exception while saving the icon file in the server for " + "the application " @@ -77,10 +72,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } if (bannerFileStream != null) { - String bannerName = application.getBannerName(); - bannerName = (bannerName == null) ? "banner" : bannerName; try { - saveFile(bannerFileStream, artifactDirectoryPath + File.separator + bannerName); + saveFile(bannerFileStream, artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[1]); } catch (IOException e) { throw new ApplicationStorageManagementException( "IO Exception while saving the banner file in the server for" + " the application " @@ -88,18 +81,11 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } if (screenShotStreams != null) { - int count = 1; + int count = application.getScreenShotCount() + 1; String screenshotName; - List screenShotNames = application.getScreenshots(); - boolean isScreenShotNameExist = (screenShotNames == null || screenShotNames.isEmpty()); - int screenShotNameLength = isScreenShotNameExist ? screenShotNames.size() : 0; for (InputStream screenshotStream : screenShotStreams) { try { - if (isScreenShotNameExist && count <= screenShotNameLength) { - screenshotName = screenShotNames.get(count); - } else { - screenshotName = "screenshot_" + count; - } + screenshotName = Constants.IMAGE_ARTIFACTS[2] + count; saveFile(screenshotStream, artifactDirectoryPath + File.separator + screenshotName); count++; } catch (IOException e) { @@ -108,24 +94,30 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager e); } } + try { + ConnectionManagerUtil.beginDBTransaction(); + DAOFactory.getApplicationDAO().updateScreenShotCount(applicationUUID, tenantId, count); + ConnectionManagerUtil.closeDBConnection(); + } catch (TransactionManagementException e) { + throw new ApplicationStorageManagementException("Transaction Management exception while trying to " + + "update the screen-shot count of the application " + applicationUUID + " for the tenant " + + tenantId, e); + } catch (DBConnectionException e) { + throw new ApplicationStorageManagementException("Database connection management exception while " + + "trying to update the screen-shot count for the application " + applicationUUID + " for the" + + " tenant " + tenantId, e); + } catch (ApplicationManagementDAOException e) { + throw new ApplicationStorageManagementException("Application Management DAO exception while trying to" + + " update the screen-shot count for the application " + applicationUUID + " for the tenant " + + tenantId, e); + } } } @Override public void uploadReleaseArtifacts(String applicationUUID, String versionName, InputStream binaryFile) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot upload release artifacts for not existing application."); - } + Application application = validateApplication(applicationUUID); String artifactDirectoryPath = Constants.artifactPath + application.getId(); if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the application release related artifacts related with " @@ -148,18 +140,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public InputStream getReleasedArtifacts(String applicationUUID, String versionName) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot retrieve release artifacts for not existing application."); - } + Application application = validateApplication(applicationUUID); String artifactPath = Constants.artifactPath + application.getId() + File.separator + versionName; if (log.isDebugEnabled()) { @@ -182,18 +163,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot delete the artifacts of a non-existing application."); - } + Application application = validateApplication(applicationUUID); String artifactDirectoryPath = Constants.artifactPath + application.getId(); File artifactDirectory = new File(artifactDirectoryPath); @@ -205,18 +175,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public void deleteApplicationReleaseArtifacts(String applicationUUID, String version) throws ApplicationStorageManagementException { - Application application; - try { - application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while retrieving the application details for " + "the application with UUID " - + applicationUUID); - } - if (application == null) { - throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " - + "exist. Cannot delete the artifacts of a non-existing application."); - } + Application application = validateApplication(applicationUUID); String artifactPath = Constants.artifactPath + application.getId() + File.separator + version; File artifact = new File(artifactPath); @@ -225,8 +184,10 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } - @Override public void deleteAllApplicationReleaseArtifacts(String applicationUUID) - throws ApplicationStorageManagementException { + @Override + public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws + ApplicationStorageManagementException { + Application application = validateApplication(applicationUUID); try { List applicationReleases = DataHolder.getInstance().getReleaseManager() .getReleases(applicationUUID); @@ -240,6 +201,31 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } + @Override + public InputStream getImageArtifact(String applicationUUID, String name, int count) throws + ApplicationStorageManagementException { + Application application = validateApplication(applicationUUID); + validateImageArtifactNames(name); + String imageArtifactPath = Constants.artifactPath + application.getId() + File.separator + name.toLowerCase(); + + if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) { + imageArtifactPath += count; + } + File imageFile = new File(imageArtifactPath); + if (!imageFile.exists()) { + throw new ApplicationStorageManagementException( + "Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID); + } else { + try { + return new FileInputStream(imageArtifactPath); + } catch (FileNotFoundException e) { + throw new ApplicationStorageManagementException( + "File not found exception while trying to get the image artifact " + name + " for the " + + "application " + applicationUUID, e); + } + } + } + /** * To save a file in a given location. * @@ -294,4 +280,44 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } artifactDirectory.delete(); } + + /** + * To validate the image artifact names. + * @param name Name of the image artifact. + * @throws ApplicationStorageManagementException Application Storage Management Exception + */ + private void validateImageArtifactNames(String name) throws ApplicationStorageManagementException { + if (name == null || name.isEmpty()) { + throw new ApplicationStorageManagementException("Image artifact name cannot be null or empty. It is a " + + "required parameter"); + } + if (!Arrays.asList(Constants.IMAGE_ARTIFACTS).contains(name.toLowerCase())) { + throw new ApplicationStorageManagementException("Provide artifact name is not valid. Please provide the " + + "name among " + Arrays.toString(Constants.IMAGE_ARTIFACTS)); + } + } + + /** + * To validate the Application before storing and retrieving the artifacts of a particular application. + * + * @param uuid UUID of the Application + * @return {@link Application} if it is validated + * @throws ApplicationStorageManagementException Application Storage Management Exception will be thrown if a + * valid application related with the specific UUID + * could not be found. + */ + private Application validateApplication(String uuid) throws ApplicationStorageManagementException { + Application application = null; + try { + application = DataHolder.getInstance().getApplicationManager().getApplication(uuid); + } catch (ApplicationManagementException e) { + throw new ApplicationStorageManagementException( + "Exception while retrieving the application details for the application with UUID " + + uuid); + } + if (application == null) { + throw new ApplicationStorageManagementException("Application with UUID " + uuid + " does not exist."); + } + return application; + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java index 467be38824b..9c6992b204a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java @@ -58,4 +58,9 @@ public class Constants { * Path to save the Application related artifacts. */ public static String artifactPath = ""; + + /** + * Name of the image artifacts that are saved in the file system. + */ + public static final String[] IMAGE_ARTIFACTS = {"icon", "banner", "screenshot"}; } diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index 1fb22c2b4a5..cd8091d2616 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -61,7 +61,6 @@ - ${carbon.home}/repository/resources/mobileapps/images/ - ${carbon.home}/repository/resources/mobileapps/binary/ + repository/resources/mobileapps/ \ No newline at end of file diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index f344747a4a5..809efada346 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -125,10 +125,8 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( `NAME` VARCHAR(100) NOT NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL, `DESCRIPTION` TEXT NULL, - `ICON_NAME` VARCHAR(100) NULL, - `BANNER_NAME` VARCHAR(100) NULL, + `SCREEN_SHOT_COUNT` INT DEFAULT 0, `VIDEO_NAME` VARCHAR(100) NULL, - `SCREENSHOTS` TEXT NULL, `CREATED_BY` VARCHAR(255) NULL, `CREATED_AT` DATETIME NOT NULL, `MODIFIED_AT` DATETIME NULL, @@ -183,7 +181,7 @@ CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( ID INT NOT NULL AUTO_INCREMENT, VERSION_NAME VARCHAR(100) NOT NULL, RESOURCE TEXT NULL, - RELEASE_CHANNEL VARCHAR(50) NULL, + RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', RELEASE_DETAILS TEXT NULL, CREATED_AT DATETIME NOT NULL, APPM_APPLICATION_ID INT NOT NULL, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index 379b6de3da1..cbf35064b30 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -126,10 +126,8 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( `NAME` VARCHAR(100) NOT NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL, `DESCRIPTION` TEXT NULL, - `ICON_NAME` VARCHAR(100) NULL, - `BANNER_NAME` VARCHAR(100) NULL, `VIDEO_NAME` VARCHAR(100) NULL, - `SCREENSHOTS` TEXT NULL, + `SCREEN_SHOT_COUNT` INT DEFAULT 0, `CREATED_BY` VARCHAR(255) NULL, `CREATED_AT` DATETIME NOT NULL, `MODIFIED_AT` DATETIME NULL, @@ -191,7 +189,7 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_RELEASE` ( `ID` INT NOT NULL AUTO_INCREMENT UNIQUE , `VERSION_NAME` VARCHAR(100) NOT NULL, `RESOURCE` TEXT NULL, - `RELEASE_CHANNEL` VARCHAR(50) NULL, + `RELEASE_CHANNEL` VARCHAR(50) DEFAULT 'ALPHA', `RELEASE_DETAILS` TEXT NULL, `CREATED_AT` DATETIME NOT NULL, `APPM_APPLICATION_ID` INT NOT NULL, From 053008932dcaa469b2c16dca65e9721e179e8779 Mon Sep 17 00:00:00 2001 From: megala21 Date: Wed, 23 Aug 2017 16:36:11 +0530 Subject: [PATCH 11/13] Minor fixes to mysql script and refactoring --- .../services/impl/ApplicationManagementAPIImpl.java | 1 + .../common/services/ApplicationReleaseManager.java | 2 +- .../application/mgt/core/dao/common/Util.java | 1 - .../impl/application/GenericApplicationDAOImpl.java | 13 ++++++++----- .../core/impl/ApplicationStorageManagerImpl.java | 9 +++++++-- .../dbscripts/cdm/application-mgt/mysql.sql | 4 ++-- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java index 2c08e5fae78..ad968282b43 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java @@ -433,6 +433,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { @Override @GET @Path("/image-artifacts/{uuid}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response getApplicationImageArtifacts(@PathParam("uuid") String applicationUUID, @QueryParam("name") String name, @QueryParam("count") int count) { if (name == null || name.isEmpty()) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java index db1a852f9be..a97050d19f0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java @@ -25,7 +25,7 @@ import java.util.List; /** * ApplicationReleaseManager is responsible for handling all the operations related with - * {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updation , + * {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updating , * deletion and viewing. * */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java index 9354d1bddb8..769e8a50ede 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java @@ -27,7 +27,6 @@ import org.wso2.carbon.device.application.mgt.common.Lifecycle; import org.wso2.carbon.device.application.mgt.common.LifecycleState; import org.wso2.carbon.device.application.mgt.common.Platform; import org.wso2.carbon.device.application.mgt.common.User; -import org.wso2.carbon.device.application.mgt.core.util.JSONUtil; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 51747a46a7c..6f921a104b2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -138,7 +138,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ?"; + + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? "; if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { sql += "AND APP.NAME LIKE ? "; @@ -181,11 +181,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic applicationList.setApplications(applications); applicationList.setPagination(pagination); } catch (SQLException e) { - throw new ApplicationManagementDAOException("Error occurred while getting application List", e); + throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant" + + " " + tenantId + ". While executing " + sql, e); } catch (JSONException e) { - throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); + throw new ApplicationManagementDAOException("Error occurred while parsing JSON, while getting application" + + " list for the tenant " + tenantId, e); } catch (DBConnectionException e) { - throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); + throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection while " + + "getting application list for the tenant " + tenantId, e); } finally { Util.cleanupResources(stmt, rs); } @@ -385,7 +388,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic statement.setInt(1, count); statement.setString(2, applicationUUID); statement.setInt(3, tenantId); - + statement.executeUpdate(); } catch (DBConnectionException e) { throw new ApplicationManagementDAOException("Database connection while trying to update the screen-shot " + "count for the application with UUID " + applicationUUID + " for the tenant " + tenantId); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java index 2a72e7ef551..287cd5370ba 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -96,20 +96,25 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } try { ConnectionManagerUtil.beginDBTransaction(); - DAOFactory.getApplicationDAO().updateScreenShotCount(applicationUUID, tenantId, count); - ConnectionManagerUtil.closeDBConnection(); + DAOFactory.getApplicationDAO().updateScreenShotCount(applicationUUID, tenantId, count - 1); + ConnectionManagerUtil.commitDBTransaction(); } catch (TransactionManagementException e) { + ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationStorageManagementException("Transaction Management exception while trying to " + "update the screen-shot count of the application " + applicationUUID + " for the tenant " + tenantId, e); } catch (DBConnectionException e) { + ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationStorageManagementException("Database connection management exception while " + "trying to update the screen-shot count for the application " + applicationUUID + " for the" + " tenant " + tenantId, e); } catch (ApplicationManagementDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationStorageManagementException("Application Management DAO exception while trying to" + " update the screen-shot count for the application " + applicationUUID + " for the tenant " + tenantId, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); } } } diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index cbf35064b30..48456970264 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -305,8 +305,8 @@ CREATE TABLE IF NOT EXISTS `APPM_PLATFORM_TENANT_MAPPING` ( CONSTRAINT `fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1` FOREIGN KEY (`PLATFORM_ID`) REFERENCES `APPM_PLATFORM` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION) + ON DELETE CASCADE + ON UPDATE CASCADE ) ENGINE = InnoDB COMMENT = 'This table contains the data related relationship between application platofrm and appication mappings'; From 9c31b93937052610297cc747efb4074943351308 Mon Sep 17 00:00:00 2001 From: megala21 Date: Tue, 29 Aug 2017 09:52:35 +0530 Subject: [PATCH 12/13] Fixing minor issues --- .../device/application/mgt/common/Filter.java | 11 +++++++- .../mgt/core/dao/ApplicationDAO.java | 2 +- .../GenericApplicationDAOImpl.java | 16 ++++++++++-- .../mgt/core/impl/ApplicationManagerImpl.java | 26 +++++++++++++++++-- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java index 1834d9c83fd..becd16fb21d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java @@ -46,6 +46,8 @@ public class Filter { private String sortBy; + private String userName; + public int getLimit() { return limit; } @@ -102,6 +104,14 @@ public class Filter { this.sortBy = sortBy; } + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + public boolean hasCondition() { if (filterProperties != null || searchQuery != null || filter != null) { return true; @@ -109,5 +119,4 @@ public class Filter { return false; } - } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java index 6c556757c38..f49a2d3f4bb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java @@ -37,7 +37,7 @@ public interface ApplicationDAO { ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException; - Application getApplication(String uuid, int tenantId) throws ApplicationManagementDAOException; + Application getApplication(String uuid, int tenantId, String userName) throws ApplicationManagementDAOException; int getApplicationId(String uuid, int tenantId) throws ApplicationManagementDAOException; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 6f921a104b2..6531ca6e3ca 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -140,12 +140,17 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? "; + String userName = filter.getUserName(); + if (!userName.equals("ALL")) { + sql += " AND APP.CREATED_BY = ? "; + } if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { sql += "AND APP.NAME LIKE ? "; } sql += "LIMIT ?,?;"; stmt = conn.prepareStatement(sql); + stmt.setString(++index, userName); stmt.setInt(++index, tenantId); if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); @@ -244,7 +249,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public Application getApplication(String uuid, int tenantId) throws ApplicationManagementDAOException { + public Application getApplication(String uuid, int tenantId, String userName) throws + ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the UUID(" + uuid + ") from the database"); } @@ -261,11 +267,17 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ? AND APP.TENANT_ID = ?"; + + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ? AND APP.TENANT_ID = ? "; + stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); stmt.setInt(2, tenantId); + + if (!userName.equals("ALL")) { + sql += "AND APP.CREATED_BY = ?"; + stmt.setString(3, userName); + } rs = stmt.executeQuery(); if (log.isDebugEnabled()) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index f9f8dae6807..ee67fa29d56 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -174,6 +174,18 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public ApplicationList getApplications(Filter filter) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + + try { + if (isAuthorized(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { + userName = "ALL"; + } + } catch (UserStoreException e) { + throw new ApplicationManagementException("User-store exception while checking whether the user " + + userName + " of tenant " + tenantId + " has the publisher permission"); + } + filter.setUserName(userName); + try { ConnectionManagerUtil.openDBConnection(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); @@ -278,9 +290,19 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public Application getApplication(String uuid) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + + try { + if (isAuthorized(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { + userName = "ALL"; + } + } catch (UserStoreException e) { + throw new ApplicationManagementException( + "User-store exception while getting application with the UUID " + uuid); + } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationDAO().getApplication(uuid, tenantId); + return DAOFactory.getApplicationDAO().getApplication(uuid, tenantId, userName); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -304,7 +326,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } try { ConnectionManagerUtil.openDBConnection(); - Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID, tenantId); + Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID, tenantId,userName); return application.getUser().getUserName().equals(userName) && application.getUser().getTenantId() == tenantId; } finally { From 5278fa88bf0bdf38c727dd9c8b4d56aadde95f0a Mon Sep 17 00:00:00 2001 From: megala21 Date: Mon, 4 Sep 2017 17:23:44 +0530 Subject: [PATCH 13/13] Adding postgresql database support for application and applicaion release --- .../mgt/core/dao/common/DAOFactory.java | 3 + .../GenericApplicationDAOImpl.java | 30 +-- .../mgt/core/impl/ApplicationManagerImpl.java | 3 +- .../cdm/application-mgt/postgresql.sql | 204 +++++++++++++++++- 4 files changed, 225 insertions(+), 15 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java index 5f97b518fa7..4a29ee90a73 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java @@ -60,6 +60,7 @@ public class DAOFactory { switch (databaseEngine) { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: + case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new GenericApplicationDAOImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); @@ -90,6 +91,7 @@ public class DAOFactory { switch (databaseEngine) { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: + case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new GenericLifecycleStateImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); @@ -107,6 +109,7 @@ public class DAOFactory { switch (databaseEngine) { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: + case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new GenericApplicationReleaseDAOImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 6531ca6e3ca..de6896921cf 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -147,16 +147,20 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { sql += "AND APP.NAME LIKE ? "; } - sql += "LIMIT ?,?;"; + sql += "LIMIT ? OFFSET ?;"; stmt = conn.prepareStatement(sql); - stmt.setString(++index, userName); stmt.setInt(++index, tenantId); + + if (!userName.equals("ALL")) { + stmt.setString(++index, userName); + } if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); } - stmt.setInt(++index, filter.getOffset()); + stmt.setInt(++index, filter.getLimit()); + stmt.setInt(++index, filter.getOffset()); rs = stmt.executeQuery(); @@ -421,26 +425,26 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic try { conn = this.getDBConnection(); int index = 0; - sql += "UPDATE APPM_APPLICATION SET NAME = IFNULL (?, NAME), SHORT_DESCRIPTION = IFNULL " - + "(?, SHORT_DESCRIPTION), DESCRIPTION = IFNULL (?, DESCRIPTION), SCREEN_SHOT_COUNT = IFNULL (?, " - + "SCREEN_SHOT_COUNT), VIDEO_NAME = IFNULL (?, VIDEO_NAME), " - + "MODIFIED_AT = IFNULL (?, MODIFIED_AT), "; + sql += "UPDATE APPM_APPLICATION SET NAME = COALESCE (?, NAME), SHORT_DESCRIPTION = COALESCE " + + "(?, SHORT_DESCRIPTION), DESCRIPTION = COALESCE (?, DESCRIPTION), SCREEN_SHOT_COUNT = " + + "COALESCE (?, SCREEN_SHOT_COUNT), VIDEO_NAME = COALESCE (?, VIDEO_NAME), MODIFIED_AT = COALESCE " + + "(?, MODIFIED_AT), "; if (application.getPayment() != null) { - sql += " IS_FREE = IFNULL (?, IS_FREE), "; + sql += " IS_FREE = COALESCE (?, IS_FREE), "; if (application.getPayment().getPaymentCurrency() != null) { - sql += "PAYMENT_CURRENCY = IFNULL (?, PAYMENT_CURRENCY), "; + sql += "PAYMENT_CURRENCY = COALESCE (?, PAYMENT_CURRENCY), "; } - sql += "PAYMENT_PRICE = IFNULL (?, PAYMENT_PRICE), "; + sql += "PAYMENT_PRICE = COALESCE (?, PAYMENT_PRICE), "; } if (application.getCategory() != null && application.getCategory().getId() != 0) { - sql += "APPLICATION_CATEGORY_ID = IFNULL (?, APPLICATION_CATEGORY_ID), "; + sql += "APPLICATION_CATEGORY_ID = COALESCE (?, APPLICATION_CATEGORY_ID), "; } if (application.getPlatform() != null && application.getPlatform().getId() != 0) { - sql += "PLATFORM_ID = IFNULL (?, PLATFORM_ID), "; + sql += "PLATFORM_ID = COALESCE (?, PLATFORM_ID), "; } - sql += "TENANT_ID = IFNULL (?, TENANT_ID) WHERE UUID = ?"; + sql += "TENANT_ID = COALESCE (?, TENANT_ID) WHERE UUID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(++index, application.getName()); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index ee67fa29d56..6b2e0411f74 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -326,7 +326,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } try { ConnectionManagerUtil.openDBConnection(); - Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID, tenantId,userName); + Application application = DAOFactory.getApplicationDAO() + .getApplication(applicationUUID, tenantId, userName); return application.getUser().getUserName().equals(userName) && application.getUser().getTenantId() == tenantId; } finally { diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql index 96e806a0121..6616a56c2a6 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql @@ -41,4 +41,206 @@ FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE, PRIMARY KEY (ID, TENANT_ID, PLATFORM_ID) ); -CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC); \ No newline at end of file +CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC); + +DROP TABLE IF EXISTS APPM_APPLICATION_CATEGORY; +DROP SEQUENCE IF EXISTS APPM_APPLICATION_CATEGORY_PK_SEQ; +CREATE SEQUENCE APPM_APPLICATION_CATEGORY_PK_SEQ; + +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY ( + ID INT DEFAULT NEXTVAL('APPM_APPLICATION_CATEGORY_PK_SEQ'), + NAME VARCHAR(100) NOT NULL, + DESCRIPTION TEXT NULL, + PUBLISHED BOOLEAN DEFAULT FALSE, + PRIMARY KEY (ID)); + +INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION, PUBLISHED) VALUES ('Enterprise', 'Enterprise level +applications which the artifacts need to be provided', TRUE); +INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION, PUBLISHED) VALUES ('Public', 'Public category in which the +application need to be downloaded from the public application store', TRUE); + +DROP TABLE IF EXISTS APPM_LIFECYCLE_STATE; +DROP SEQUENCE IF EXISTS APPM_LIFECYCLE_STATE_PK_SEQ; +CREATE SEQUENCE APPM_LIFECYCLE_STATE_PK_SEQ; + +-- ----------------------------------------------------- +-- Table APPM_LIFECYCLE_STATE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE ( + ID INT DEFAULT NEXTVAL('APPM_LIFECYCLE_STATE_PK_SEQ'), + NAME VARCHAR(100) NOT NULL, + IDENTIFIER VARCHAR(100) NOT NULL, + DESCRIPTION TEXT NULL, + PRIMARY KEY (ID)); + +DROP INDEX IF EXISTS APPM_LIFECYCLE_STATE_IDENTIFIER_UNIQUE; +CREATE INDEX APPM_LIFECYCLE_STATE_IDENTIFIER_UNIQUE ON APPM_LIFECYCLE_STATE(IDENTIFIER ASC); + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('CREATED', 'CREATED', 'Application creation +initial state'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('IN REVIEW', 'IN REVIEW', 'Application is in in-review state'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('APPROVED', 'APPROVED', 'State in which Application is approved after reviewing.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('REJECTED', 'REJECTED', 'State in which Application is rejected after reviewing.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('PUBLISHED', 'PUBLISHED', 'State in which Application is in published state.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('UNPUBLISHED', 'UNPUBLISHED', 'State in which Application is in un published state.'); +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); + +DROP TABLE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION; +DROP SEQUENCE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ; +CREATE SEQUENCE APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ; + +CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION +( + ID INT DEFAULT NEXTVAL('APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ'), + INITIAL_STATE INT, + NEXT_STATE INT, + PERMISSION VARCHAR(1024), + DESCRIPTION VARCHAR(2048), + PRIMARY KEY (INITIAL_STATE, NEXT_STATE), + FOREIGN KEY (INITIAL_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE, + FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE +); + +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (1, 2, null, 'Submit for review'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 1, null, 'Revoke from review'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (3, 5, null, 'PUBLISH'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (5, 6, null, 'UN PUBLISH'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 5, null, 'PUBLISH'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (4, 1, null, 'Return to CREATE STATE'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 1, null, 'Return to CREATE STATE'); +INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 7, null, 'Retire'); + + +DROP TABLE IF EXISTS APPM_APPLICATION; +DROP SEQUENCE IF EXISTS APPM_APPLICATION_PK_SEQ; +CREATE SEQUENCE APPM_APPLICATION_PK_SEQ; + +CREATE TABLE IF NOT EXISTS APPM_APPLICATION ( + ID INT DEFAULT NEXTVAL('APPM_APPLICATION_PK_SEQ') UNIQUE, + UUID VARCHAR(100) NOT NULL, + IDENTIFIER VARCHAR(255) NULL, + NAME VARCHAR(100) NOT NULL, + SHORT_DESCRIPTION VARCHAR(255) NULL, + DESCRIPTION TEXT NULL, + SCREEN_SHOT_COUNT INT DEFAULT 0, + VIDEO_NAME VARCHAR(100) NULL, + CREATED_BY VARCHAR(255) NULL, + CREATED_AT TIMESTAMP NOT NULL, + MODIFIED_AT TIMESTAMP NULL, + IS_FREE BOOLEAN DEFAULT TRUE, + PAYMENT_CURRENCY VARCHAR(45) NULL, + PAYMENT_PRICE DECIMAL(10,2) NULL, + APPLICATION_CATEGORY_ID INT NOT NULL, + LIFECYCLE_STATE_ID INT NOT NULL, + LIFECYCLE_STATE_MODIFIED_BY VARCHAR(255) NULL, + LIFECYCLE_STATE_MODIFIED_AT TIMESTAMP NULL, + TENANT_ID INT NOT NULL, + PLATFORM_ID INT NOT NULL, + PRIMARY KEY (ID, APPLICATION_CATEGORY_ID, LIFECYCLE_STATE_ID, PLATFORM_ID), + FOREIGN KEY (APPLICATION_CATEGORY_ID) + REFERENCES APPM_APPLICATION_CATEGORY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT fk_APPM_APPLICATION_APPM_LIFECYCLE_STATE1 + FOREIGN KEY (LIFECYCLE_STATE_ID) + REFERENCES APPM_LIFECYCLE_STATE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT fk_APPM_APPLICATION_APPM_PLATFORM1 + FOREIGN KEY (PLATFORM_ID) + REFERENCES APPM_PLATFORM (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX IF NOT EXISTS FK_APPLICATION_APPLICATION_CATEGORY ON APPM_APPLICATION(APPLICATION_CATEGORY_ID ASC); +CREATE INDEX IF NOT EXISTS UK_APPLICATION_UUID ON APPM_APPLICATION(UUID ASC); + +DROP TABLE IF EXISTS APPM_APPLICATION_PROPERTY; +-- ----------------------------------------------------- +-- Table APPM_APPLICATION_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTY ( + PROP_KEY VARCHAR(255) NOT NULL, + PROP_VAL TEXT NULL, + APPLICATION_ID INT NOT NULL, + PRIMARY KEY (PROP_KEY, APPLICATION_ID), + CONSTRAINT FK_APPLICATION_PROPERTY_APPLICATION + FOREIGN KEY (APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX FK_APPLICATION_PROPERTY_APPLICATION ON APPM_APPLICATION_PROPERTY(APPLICATION_ID ASC); + +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TAG ( + NAME VARCHAR(45) NOT NULL, + APPLICATION_ID INT NOT NULL, + PRIMARY KEY (APPLICATION_ID, NAME), + CONSTRAINT fk_APPM_APPLICATION_TAG_APPM_APPLICATION1 + FOREIGN KEY (APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX IF NOT EXISTS FK_APPLICATION_TAG_APPLICATION ON APPM_APPLICATION_TAG(APPLICATION_ID ASC); + +DROP TABLE IF EXISTS APPM_APPLICATION_RELEASE; +DROP SEQUENCE IF EXISTS APPM_APPLICATION_RELEASE_PK_SEQ; +CREATE SEQUENCE APPM_APPLICATION_RELEASE_PK_SEQ; +-- ----------------------------------------------------- +-- Table APPM_APPLICATION_RELEASE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( + ID INT DEFAULT NEXTVAL('APPM_APPLICATION_RELEASE_PK_SEQ') UNIQUE, + VERSION_NAME VARCHAR(100) NOT NULL, + RESOURCE TEXT NULL, + RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', + RELEASE_DETAILS TEXT NULL, + CREATED_AT TIMESTAMP NOT NULL, + APPM_APPLICATION_ID INT NOT NULL, + IS_DEFAULT BOOLEAN DEFAULT FALSE, + PRIMARY KEY (APPM_APPLICATION_ID, VERSION_NAME), + CONSTRAINT FK_APPLICATION_VERSION_APPLICATION + FOREIGN KEY (APPM_APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX FK_APPLICATION_VERSION_APPLICATION ON APPM_APPLICATION_RELEASE(APPM_APPLICATION_ID ASC); + +DROP TABLE IF EXISTS APPM_RELEASE_PROPERTY; +-- ----------------------------------------------------- +-- Table APPM_RELEASE_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS APPM_RELEASE_PROPERTY ( + PROP_KEY VARCHAR(255) NOT NULL, + PROP_VALUE TEXT NULL, + APPLICATION_RELEASE_ID INT NOT NULL, + PRIMARY KEY (PROP_KEY, APPLICATION_RELEASE_ID), + CONSTRAINT FK_RELEASE_PROPERTY_APPLICATION_RELEASE + FOREIGN KEY (APPLICATION_RELEASE_ID) + REFERENCES APPM_APPLICATION_RELEASE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +CREATE INDEX FK_RELEASE_PROPERTY_APPLICATION_RELEASE ON APPM_RELEASE_PROPERTY(APPLICATION_RELEASE_ID ASC);