/*******************************************************************************
 * Copyright 2015 InfinitiesSoft Solutions Inc.
 *
 * Licensed 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.
 *******************************************************************************/
package com.infinities.nova.quota;

import javax.ws.rs.NotFoundException;

import com.google.common.base.Strings;
import com.infinities.api.openstack.commons.config.Config;
import com.infinities.api.openstack.commons.context.OpenstackRequestContext;

public abstract class BaseResource {

	private Config config;
	private String name;
	private String flag;


	public BaseResource(Config config) {
		this.config = config;
	}

	public int quota(QuotaDriver driver, OpenstackRequestContext context, String projectid, String quotaClass) {
		if (Strings.isNullOrEmpty(projectid)) {
			projectid = context.getProjectId();
		}

		if (Strings.isNullOrEmpty(quotaClass)) {
			quotaClass = context.getQuotaClass();
		}

		if (!Strings.isNullOrEmpty(projectid)) {
			try {
				return driver.getByProject(context, projectid, name).getHardLimit();
			} catch (NotFoundException e) {
				// pass
			}
		}

		if (!Strings.isNullOrEmpty(quotaClass)) {
			try {
				return driver.getByClass(context, quotaClass, name).getHardLimit();
			} catch (NotFoundException e) {
				// pass
			}
		}

		return getDefault();
	}

	// flag=null;
	public BaseResource(String name, String flag) {
		this.name = name;
		this.flag = flag;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public int getDefault() {
		return Strings.isNullOrEmpty(flag) ? -1 : config.getOpt(flag).asInteger();
	}

	public abstract String getValidMethod();

}

@@ -1056,32 +1056,8 @@
  %7B%0A%0A
-%09private Config config;%0A
 %09pri
@@ -1100,74 +1100,32 @@
 ag;%0A
-%0A%0A%09public BaseResource(Config config) %7B%0A%09%09this.config = config;%0A%09%7D
+%09private Config config;%0A
 %0A%0A%09p
@@ -1140,16 +1140,31 @@
 t quota(
+Config config, 
 QuotaDri

update BaseResource