Package org.wso2.carbon.adminconsole.core.description

Examples of org.wso2.carbon.adminconsole.core.description.DatabaseInstanceInfo


        instances.addChild(newInstanceElement);
        this.writeDataToRegistry(instances.toString(), PATH_TO_INSTANCE_LIST);
    }

    public void removeDbInstance(String instanceName) throws Exception {
        DatabaseInstanceInfo tobeRemoved = null;
        List<DatabaseInstanceInfo> instanceList = this.getDatabaseInstanceList();
        for (DatabaseInstanceInfo databaseInstanceInfo : instanceList) {
            if (databaseInstanceInfo != null && instanceName.equals(
                    databaseInstanceInfo.getInstanceName())) {
                tobeRemoved = databaseInstanceInfo;
View Full Code Here


        try {
            if (log.isDebugEnabled()) {
                log.debug("Creating Database For The Tenant " + tenantDomain);
            }

            DatabaseInstanceInfo dbInstanceInfo = tenantData.getDatabaseInstanceInfo(
                    dbInfo.getInstanceName());
            String sqlQuery = "CREATE DATABASE " + fullyQualifiedDbName;
            ps = ConnectionHandler.getConnection(
                    dbInstanceInfo.getInstanceUrl(), dbInstanceInfo.getUsername(),
                    dbInstanceInfo.getPassword()).prepareStatement(sqlQuery);
            ps.execute();

            if (log.isDebugEnabled()) {
                log.debug("Database Created For The Tenant " + tenantDomain);
            }

            return dbInstanceInfo.getInstanceUrl() + "/" + dbName;
        } catch (SQLException e) {
            String msg = "Unable To Create Database For Tenant " + tenantDomain;
            throw new SQLException(msg, e);
        } catch (RegistryException e) {
            String msg = "Cannot Retrieve Instance List";
View Full Code Here

    public boolean createDatabaseUser(DatabaseUserInfo userInfo) throws Exception {
        try {
            if (log.isDebugEnabled()) {
                log.debug("Creating A Database User For The Tenant");
            }
            DatabaseInstanceInfo instanceInfo = tenantData.getDatabaseInstanceInfo(
                    userInfo.getInstanceName());
            if (instanceInfo != null) {
                String createUserQuery = "CREATE USER '" + userInfo.getUsername() + "'@'" +
                        this.extractHostName(instanceInfo.getInstanceUrl()) + "' IDENTIFIED BY '" +
                        userInfo.getPassword() + "'";

                String grantPrivilegesQuery = "GRANT ALL PRIVILEGES ON *.* TO '" +
                        userInfo.getUsername() + "'@'" +
                        this.extractHostName(instanceInfo.getInstanceUrl()) + "' IDENTIFIED BY '" +
                        userInfo.getPassword() + "'";

                String systemDbUrl = processJdbcUrl(instanceInfo.getInstanceUrl(), MYSQL_SYSTEM_DB);

                ps = ConnectionHandler.getConnection(
                        systemDbUrl,
                        instanceInfo.getUsername(),
                        instanceInfo.getPassword()).prepareStatement(createUserQuery);
                ps.execute();

                ps = ConnectionHandler.getConnection(
                        systemDbUrl,
                        instanceInfo.getUsername(),
                        instanceInfo.getPassword()).prepareStatement(grantPrivilegesQuery);
                ps.execute();

            }

            if (log.isDebugEnabled()) {
View Full Code Here

            XMLStreamException, ClassNotFoundException, RegistryException {
        try {
            if (log.isDebugEnabled()) {
                log.debug("Dropping Database" + dbName);
            }
            DatabaseInstanceInfo instanceInfo = tenantData.getDatabaseInstanceInfo(instanceName);
            DatabaseUserInfo userInfo = tenantData.getDatabaseUserInfo(instanceName, dbName);

            String dropDatabaseQuery = "DROP DATABASE " + dbName;
            String dropUserQuery = "DROP USER '" + userInfo.getUsername() + "'@'" +
                    this.extractHostName(instanceInfo.getInstanceUrl()) + "'";

            ps = ConnectionHandler.getConnection(
                    instanceInfo.getInstanceUrl(),
                    instanceInfo.getUsername(),
                    instanceInfo.getPassword()).prepareStatement(dropDatabaseQuery);
            ps.execute();

            if (log.isDebugEnabled()) {
                log.debug("Database " + dbName + "Dropped");
            }

            if (log.isDebugEnabled()) {
                log.debug("Dropping Database User " + userInfo.getUsername());
            }
            ps = ConnectionHandler.getConnection(
                    instanceInfo.getInstanceUrl(),
                    instanceInfo.getUsername(),
                    instanceInfo.getPassword()).prepareStatement(dropUserQuery);
            ps.execute();

            if (log.isDebugEnabled()) {
                log.debug("Database User " + userInfo.getUsername() + "Dropped");
            }
View Full Code Here

    public List<DatabaseUserInfo> getUsers(String dbName) throws RegistryException, SQLException,
            XMLStreamException, ClassNotFoundException {
        List<DatabaseUserInfo> users = new ArrayList<DatabaseUserInfo>();
        try {
            DatabaseInstanceInfo instanceInfo = tenantData.getDatabaseInstanceInfo(dbName);
            String sqlQuery = "SELECT Host,User FROM db WHERE Db=?";

            String dbUrl = processJdbcUrl(instanceInfo.getInstanceUrl(), MYSQL_SYSTEM_DB);
            ps = ConnectionHandler.getConnection(dbUrl,
                    instanceInfo.getUsername(),
                    instanceInfo.getPassword()).prepareStatement(sqlQuery);
            ps.setString(1, dbName);

            ResultSet rs = ps.executeQuery();
            if (rs != null) {
                while (rs.next()) {
View Full Code Here

    public String addDatabaseInstance(String strDbInstance) throws AxisFault {
        if (log.isDebugEnabled()) {
            log.debug("Adding Database Instance");
        }
        try {
            DatabaseInstanceInfo databaseInstance = AdminConsoleUtil.createDbInstanceObj(
                    AXIOMUtil.stringToOM(strDbInstance));
            if (isValidInstanceName(databaseInstance.getInstanceName())) {
                tenantData.addDatabaseInstance(databaseInstance);
                return "Database instance has been successfully added";
            } else {
                return "A database instance with the same name already exists";
            }
View Full Code Here

    public String editDatabaseInstanceInfo (String strDbInstance) throws AxisFault {
        if (log.isDebugEnabled()) {
            log.debug("Editing Database Instance Info");
        }
        try {
            DatabaseInstanceInfo databaseInstance = AdminConsoleUtil.createDbInstanceObj(
                    AXIOMUtil.stringToOM(strDbInstance));
            if (!isValidInstanceName(databaseInstance.getInstanceName())) {
                tenantData.editDatabaseInstanceInfo(databaseInstance);
                return "Database instance has been successfully edited";
            } else {
                return "Database instance does not exist";
            }
View Full Code Here

        }
    }

    public String getDatabaseInstanceInfo (String instanceName) throws AxisFault {
        try {
            DatabaseInstanceInfo instanceInfo = tenantData.getDatabaseInstanceInfo(instanceName);
            return ObjSerializer.serializeDbInstanceData(
                    ADMIN_CONSOLE_OM_NAMESPACE, instanceInfo).toString();
        } catch (RegistryException e) {
            throw new AxisFault("", e);
        } catch (XMLStreamException e) {
View Full Code Here

     * @return The end line number, or -1 if could not be determined
     */
    public int getEndLineNumber() {
      int ret=-1;
     
      ActivityInterface parent=getParent();
     
      if (parent != null) {
        int index=parent.getSubActivities().indexOf(this);
       
        if (index != -1) {
          if (index < (parent.getSubActivities().size()-1)) {
            ActivityInterface other=parent.getSubActivities().get(index+1);
           
            ret = other.getStartLineNumber()-1;
          } else {
            ret = parent.getEndLineNumber();
          }
        }
      }
View Full Code Here

     *
     * @param lineNumber The line number
     * @return The activity, or null if not found
     */
    public ActivityInterface getActivityAtLineNumber(int lineNumber) {
      ActivityInterface ret=null;
     
      int endline=getEndLineNumber();
     
      if (getStartLineNumber() <= lineNumber && (endline == -1 || endline >= lineNumber)) {
       
View Full Code Here

TOP

Related Classes of org.wso2.carbon.adminconsole.core.description.DatabaseInstanceInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.