You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by sa...@apache.org on 2013/07/02 10:19:02 UTC
[09/12] Refactoring org.wso2.carbon to org.apache.stratos
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeInformation.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeInformation.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeInformation.java
new file mode 100644
index 0000000..48a0086
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeInformation.java
@@ -0,0 +1 @@
+package org.apache.stratos.adc.mgt.dto;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeWrapper.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeWrapper.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeWrapper.java
new file mode 100644
index 0000000..1339a16
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/CartridgeWrapper.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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 org.apache.stratos.adc.mgt.dto;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.wso2.carbon.utils.Pageable;
+
+/**
+ * This class holds paginated information about cartridges
+ */
+public final class CartridgeWrapper implements Pageable {
+
+ private Cartridge[] cartridges;
+ private int numberOfPages;
+
+ public CartridgeWrapper() {
+ }
+
+ public int getNumberOfPages() {
+ return numberOfPages;
+ }
+
+ public void setNumberOfPages(int numberOfPages) {
+ this.numberOfPages = numberOfPages;
+ }
+
+ public <T> void set(List<T> items) {
+ this.cartridges = items.toArray(new Cartridge[items.size()]);
+ }
+
+ public Cartridge[] getCartridges() {
+ return cartridges != null ? Arrays.copyOf(cartridges, cartridges.length) : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/Policy.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/Policy.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/Policy.java
new file mode 100644
index 0000000..451618d
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/Policy.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.dto;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+public class Policy implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String description;
+ private boolean defaultPolicy;
+
+ private Integer minAppInstances;
+ private Integer maxAppInstances;
+ private Integer maxRequestsPerSecond;
+ private BigDecimal alarmingUpperRate;
+ private BigDecimal alarmingLowerRate;
+ private BigDecimal scaleDownFactor;
+ private Integer roundsToAverage;
+
+ public Policy() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isDefaultPolicy() {
+ return defaultPolicy;
+ }
+
+ public void setDefaultPolicy(boolean defaultPolicy) {
+ this.defaultPolicy = defaultPolicy;
+ }
+
+ public Integer getMinAppInstances() {
+ return minAppInstances;
+ }
+
+ public void setMinAppInstances(Integer minAppInstances) {
+ this.minAppInstances = minAppInstances;
+ }
+
+ public Integer getMaxAppInstances() {
+ return maxAppInstances;
+ }
+
+ public void setMaxAppInstances(Integer maxAppInstances) {
+ this.maxAppInstances = maxAppInstances;
+ }
+
+ public Integer getMaxRequestsPerSecond() {
+ return maxRequestsPerSecond;
+ }
+
+ public void setMaxRequestsPerSecond(Integer maxRequestsPerSecond) {
+ this.maxRequestsPerSecond = maxRequestsPerSecond;
+ }
+
+ public BigDecimal getAlarmingUpperRate() {
+ return alarmingUpperRate;
+ }
+
+ public void setAlarmingUpperRate(BigDecimal alarmingUpperRate) {
+ this.alarmingUpperRate = alarmingUpperRate;
+ }
+
+ public BigDecimal getAlarmingLowerRate() {
+ return alarmingLowerRate;
+ }
+
+ public void setAlarmingLowerRate(BigDecimal alarmingLowerRate) {
+ this.alarmingLowerRate = alarmingLowerRate;
+ }
+
+ public BigDecimal getScaleDownFactor() {
+ return scaleDownFactor;
+ }
+
+ public void setScaleDownFactor(BigDecimal scaleDownFactor) {
+ this.scaleDownFactor = scaleDownFactor;
+ }
+
+ public Integer getRoundsToAverage() {
+ return roundsToAverage;
+ }
+
+ public void setRoundsToAverage(Integer roundsToAverage) {
+ this.roundsToAverage = roundsToAverage;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Policy))
+ return false;
+ Policy other = (Policy) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/PolicyDefinition.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/PolicyDefinition.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/PolicyDefinition.java
new file mode 100644
index 0000000..b21df4f
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/PolicyDefinition.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.dto;
+
+import java.io.Serializable;
+
+public class PolicyDefinition implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String description;
+ private boolean defaultPolicy;
+
+ public PolicyDefinition() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isDefaultPolicy() {
+ return defaultPolicy;
+ }
+
+ public void setDefaultPolicy(boolean defaultPolicy) {
+ this.defaultPolicy = defaultPolicy;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof PolicyDefinition))
+ return false;
+ PolicyDefinition other = (PolicyDefinition) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/RepositoryInformation.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/RepositoryInformation.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/RepositoryInformation.java
new file mode 100644
index 0000000..3a88700
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/RepositoryInformation.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.dto;
+
+import java.io.Serializable;
+
+public class RepositoryInformation implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String repoURL;
+ private String[] refName;
+
+ public String getRepoURL() {
+ return repoURL;
+ }
+
+ public void setRepoURL(String repoURL) {
+ this.repoURL = repoURL;
+ }
+
+ public String[] getRefName() {
+ return refName;
+ }
+
+ public void setRefName(String[] refName) {
+ this.refName = refName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/SubscriptionInfo.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/SubscriptionInfo.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/SubscriptionInfo.java
new file mode 100644
index 0000000..39e3ae2
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/dto/SubscriptionInfo.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.dto;
+
+import java.io.Serializable;
+
+public class SubscriptionInfo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String hostname;
+ private String repositoryURL;
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public String getRepositoryURL() {
+ return repositoryURL;
+ }
+
+ public void setRepositoryURL(String repositoryURL) {
+ this.repositoryURL = repositoryURL;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/ADCException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/ADCException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/ADCException.java
new file mode 100644
index 0000000..d9dbfdf
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/ADCException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class ADCException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String message;
+
+ public ADCException() {
+ super();
+ }
+
+ public ADCException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public ADCException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public ADCException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/AlreadySubscribedException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/AlreadySubscribedException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/AlreadySubscribedException.java
new file mode 100644
index 0000000..954a71b
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/AlreadySubscribedException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class AlreadySubscribedException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ private final String cartridgeType;
+
+ public AlreadySubscribedException(String message, String cartridgeType, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ }
+
+ public AlreadySubscribedException(String message, String cartridgeType) {
+ super(message);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getCartridgeType() {
+ return cartridgeType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DomainMappingExistsException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DomainMappingExistsException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DomainMappingExistsException.java
new file mode 100644
index 0000000..9287a86
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DomainMappingExistsException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class DomainMappingExistsException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ private final String domain;
+
+ public DomainMappingExistsException(String message, String domain, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ this.domain = domain;
+ }
+
+ public DomainMappingExistsException(String message, String domain) {
+ super(message);
+ this.message = message;
+ this.domain = domain;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DuplicateCartridgeAliasException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DuplicateCartridgeAliasException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DuplicateCartridgeAliasException.java
new file mode 100644
index 0000000..94aa14c
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/DuplicateCartridgeAliasException.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class DuplicateCartridgeAliasException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ private final String cartridgeType;
+
+ private final String cartridgeAlias;
+
+ public DuplicateCartridgeAliasException(String message, String cartridgeType, String cartridgeAlias, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ this.cartridgeAlias = cartridgeAlias;
+ }
+
+ public DuplicateCartridgeAliasException(String message, String cartridgeType, String cartridgeAlias) {
+ super(message);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ this.cartridgeAlias = cartridgeAlias;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getCartridgeType() {
+ return cartridgeType;
+ }
+
+ public String getCartridgeAlias() {
+ return cartridgeAlias;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidCartridgeAliasException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidCartridgeAliasException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidCartridgeAliasException.java
new file mode 100644
index 0000000..0fed41b
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidCartridgeAliasException.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class InvalidCartridgeAliasException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ private final String cartridgeType;
+
+ private final String cartridgeAlias;
+
+ public InvalidCartridgeAliasException(String message, String cartridgeType, String cartridgeAlias, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ this.cartridgeAlias = cartridgeAlias;
+ }
+
+ public InvalidCartridgeAliasException(String message, String cartridgeType, String cartridgeAlias) {
+ super(message);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ this.cartridgeAlias = cartridgeAlias;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getCartridgeType() {
+ return cartridgeType;
+ }
+
+ public String getCartridgeAlias() {
+ return cartridgeAlias;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidRepositoryException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidRepositoryException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidRepositoryException.java
new file mode 100644
index 0000000..c545b9e
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/InvalidRepositoryException.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class InvalidRepositoryException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String message;
+
+ public InvalidRepositoryException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/NotSubscribedException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/NotSubscribedException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/NotSubscribedException.java
new file mode 100644
index 0000000..74aef20
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/NotSubscribedException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class NotSubscribedException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ private final String cartridgeAlias;
+
+ public NotSubscribedException(String message, String cartridgeAlias, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ this.cartridgeAlias = cartridgeAlias;
+ }
+
+ public NotSubscribedException(String message, String cartridgeAlias) {
+ super(message);
+ this.message = message;
+ this.cartridgeAlias = cartridgeAlias;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getCartridgeAlias() {
+ return cartridgeAlias;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/PolicyException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/PolicyException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/PolicyException.java
new file mode 100644
index 0000000..2ad3117
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/PolicyException.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class PolicyException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ public PolicyException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public PolicyException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryCredentialsRequiredException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryCredentialsRequiredException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryCredentialsRequiredException.java
new file mode 100644
index 0000000..2de1899
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryCredentialsRequiredException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class RepositoryCredentialsRequiredException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String message;
+
+ public RepositoryCredentialsRequiredException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public RepositoryCredentialsRequiredException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryRequiredException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryRequiredException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryRequiredException.java
new file mode 100644
index 0000000..553dfc2
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryRequiredException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class RepositoryRequiredException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String message;
+
+ public RepositoryRequiredException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public RepositoryRequiredException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryTransportException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryTransportException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryTransportException.java
new file mode 100644
index 0000000..5b5036a
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/RepositoryTransportException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class RepositoryTransportException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ public RepositoryTransportException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public RepositoryTransportException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/UnregisteredCartridgeException.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/UnregisteredCartridgeException.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/UnregisteredCartridgeException.java
new file mode 100644
index 0000000..fb1f656
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/exception/UnregisteredCartridgeException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2013, WSO2, Inc. http://wso2.org
+ *
+ * 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 org.apache.stratos.adc.mgt.exception;
+
+public class UnregisteredCartridgeException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ private final String cartridgeType;
+
+ public UnregisteredCartridgeException(String message, String cartridgeType, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ }
+
+ public UnregisteredCartridgeException(String message, String cartridgeType) {
+ super(message);
+ this.message = message;
+ this.cartridgeType = cartridgeType;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getCartridgeType() {
+ return cartridgeType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/ADCManagementServerComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/ADCManagementServerComponent.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/ADCManagementServerComponent.java
new file mode 100644
index 0000000..e70f9d4
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/ADCManagementServerComponent.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright WSO2, Inc. (http://wso2.com)
+ *
+ * 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 org.apache.stratos.adc.mgt.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.adc.mgt.utils.CartridgeConfigFileReader;
+import org.apache.stratos.adc.mgt.utils.StratosDBUtils;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.adc.topology.mgt.service.TopologyManagementService;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+/**
+ * @scr.component name=
+ * "org.wso2.carbon.hosting.mgt.internal.ADCManagementServerComponent"
+ * immediate="true"
+ * @scr.reference name="config.context.service"
+ * interface="org.wso2.carbon.utils.ConfigurationContextService"
+ * cardinality="1..1" policy="dynamic"
+ * bind="setConfigurationContextService"
+ * unbind="unsetConfigurationContextService"
+ * @scr.reference name="user.realmservice.default"
+ * interface="org.wso2.carbon.user.core.service.RealmService"
+ * cardinality="1..1" policy="dynamic" bind="setRealmService"
+ * unbind="unsetRealmService"
+ * @scr.reference name="registry.service"
+ * interface=
+ * "org.wso2.carbon.registry.core.service.RegistryService"
+ * cardinality="1..1" policy="dynamic" bind="setRegistryService"
+ * unbind="unsetRegistryService"
+ * @scr.reference name="topology.mgt.service"
+ * interface=
+ * "org.wso2.carbon.adc.topology.mgt.service.TopologyManagementService"
+ * cardinality="1..1" policy="dynamic"
+ * bind="setTopologyManagementService"
+ * unbind="unsetTopologyManagementService"
+ */
+
+public class ADCManagementServerComponent {
+ private static final Log log = LogFactory.getLog(ADCManagementServerComponent.class);
+
+ protected void activate(ComponentContext componentContext) throws Exception {
+ if (log.isInfoEnabled()) {
+ log.info("ADC Management Server Component activated");
+ }
+
+ try {
+ CartridgeConfigFileReader.readProperties();
+ StratosDBUtils.initialize();
+ } catch (Exception e) {
+ log.fatal("Error while initializing the ADC Management Server Component", e);
+ }
+ }
+
+ protected void setConfigurationContextService(ConfigurationContextService contextService) {
+ DataHolder.setClientConfigContext(contextService.getClientConfigContext());
+ DataHolder.setServerConfigContext(contextService.getServerConfigContext());
+
+ }
+
+ protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
+ DataHolder.setClientConfigContext(null);
+ DataHolder.setServerConfigContext(null);
+ }
+
+ protected void setRealmService(RealmService realmService) {
+ // keeping the realm service in the DataHolder class
+ DataHolder.setRealmService(realmService);
+ }
+
+ protected void unsetRealmService(RealmService realmService) {
+ }
+
+ protected void setRegistryService(RegistryService registryService) {
+ try {
+ DataHolder.setRegistry(registryService.getGovernanceSystemRegistry());
+ } catch (Exception e) {
+ log.error("Cannot retrieve governance Registry", e);
+ }
+ }
+
+ protected void unsetRegistryService(RegistryService registryService) {
+ }
+
+ protected void setTopologyManagementService(TopologyManagementService topologyMgtService) {
+ DataHolder.setTopologyMgtService(topologyMgtService);
+ }
+
+ protected void unsetTopologyManagementService(TopologyManagementService topologyMgtService) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/DataHolder.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/DataHolder.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/DataHolder.java
new file mode 100644
index 0000000..2d810cf
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/DataHolder.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright WSO2, Inc. (http://wso2.com)
+ *
+ * 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 org.apache.stratos.adc.mgt.internal;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.wso2.carbon.registry.core.Registry;
+import org.wso2.carbon.adc.topology.mgt.service.TopologyManagementService;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.CarbonUtils;
+
+/**
+ * Holds the some of the data required by the webapps component
+ */
+public class DataHolder {
+ private static ConfigurationContext clientConfigContext;
+ private static ConfigurationContext serverConfigContext;
+
+ private static RealmService realmService;
+ private static Registry registry;
+ private static TopologyManagementService topologyMgtService;
+
+ public static RealmService getRealmService() {
+ return realmService;
+ }
+
+ public static void setRealmService(RealmService realmService) {
+ DataHolder.realmService = realmService;
+ }
+
+ public static Registry getRegistry() {
+ return registry;
+ }
+
+ public static ConfigurationContext getClientConfigContext() {
+ CarbonUtils.checkSecurity();
+ return clientConfigContext;
+ }
+
+ public static void setClientConfigContext(ConfigurationContext clientConfigContext) {
+ DataHolder.clientConfigContext = clientConfigContext;
+ }
+
+ public static ConfigurationContext getServerConfigContext() {
+ CarbonUtils.checkSecurity();
+ return serverConfigContext;
+ }
+
+ public static void setServerConfigContext(ConfigurationContext serverConfigContext) {
+ DataHolder.serverConfigContext = serverConfigContext;
+ }
+
+ public static void setRegistry(Registry registry) {
+ DataHolder.registry = registry;
+ }
+
+ public static TopologyManagementService getTopologyMgtService() {
+ return topologyMgtService;
+ }
+
+ public static void setTopologyMgtService(TopologyManagementService topologyMgtService) {
+ DataHolder.topologyMgtService = topologyMgtService;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingConstants.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingConstants.java
new file mode 100644
index 0000000..9259ea6
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingConstants.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright WSO2, Inc. (http://wso2.com)
+ *
+ * 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 org.apache.stratos.adc.mgt.internal;
+
+/**
+ * Web Application Constants
+ */
+public final class HostingConstants {
+ public static final String WEBAPP_PREFIX = "webapps";
+ public static final String WEBAPP_DEPLOYMENT_FOLDER = "webapps";
+ public static final String WEBAPP_EXTENSION = "war";
+
+ public static final class WebappState {
+ public static final String STARTED = "started";
+ public static final String STOPPED = "stopped";
+
+ private WebappState() {
+ }
+ }
+
+ private HostingConstants() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingManagementActivator.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingManagementActivator.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingManagementActivator.java
new file mode 100644
index 0000000..2e61894
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/internal/HostingManagementActivator.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright WSO2, Inc. (http://wso2.com)
+ *
+ * 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 org.apache.stratos.adc.mgt.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.wso2.carbon.utils.CarbonUtils;
+
+/**
+ * Activator for the Webapp Management Bundle
+ */
+public class HostingManagementActivator implements BundleActivator {
+ private static final Log log = LogFactory.getLog(HostingManagementActivator.class);
+
+ @Override
+ public void start(final BundleContext bundleContext) {
+
+ // If Carbon is running as a webapp within some other servlet container,
+ // then we should
+ // uninstall this component
+ if (!CarbonUtils.isRunningInStandaloneMode()) {
+ Thread th = new Thread() {
+ @Override
+ public void run() {
+ try {
+ bundleContext.getBundle().uninstall();
+ } catch (Throwable e) {
+ log.warn("Error occurred while uninstalling hosting.mgt UI bundle", e);
+ }
+ }
+ };
+ try {
+ th.join();
+ } catch (InterruptedException ignored) {
+ }
+ th.start();
+ }
+ }
+
+ @Override
+ public void stop(BundleContext bundleContext) {
+ // No implementation required for this method
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/ApplicationManagementService.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/ApplicationManagementService.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/ApplicationManagementService.java
new file mode 100644
index 0000000..1ae1a87
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/ApplicationManagementService.java
@@ -0,0 +1,620 @@
+/*
+ * Copyright WSO2, Inc. (http://wso2.com)
+ *
+ * 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 org.apache.stratos.adc.mgt.service;
+
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.adc.mgt.custom.domain.RegistryManager;
+import org.apache.stratos.adc.mgt.dao.CartridgeSubscription;
+import org.apache.stratos.adc.mgt.dns.DNSManager;
+import org.apache.stratos.adc.mgt.dto.Cartridge;
+import org.apache.stratos.adc.mgt.dto.CartridgeWrapper;
+import org.apache.stratos.adc.mgt.dto.PolicyDefinition;
+import org.apache.stratos.adc.mgt.dto.RepositoryInformation;
+import org.apache.stratos.adc.mgt.dto.SubscriptionInfo;
+import org.apache.stratos.adc.mgt.exception.*;
+import org.apache.stratos.adc.mgt.internal.DataHolder;
+import org.apache.stratos.adc.mgt.utils.*;
+import org.wso2.carbon.adc.topology.mgt.service.TopologyManagementService;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.core.AbstractAdmin;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.stratos.cloud.controller.util.xsd.CartridgeInfo;
+import org.wso2.carbon.utils.DataPaginator;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ *
+ *
+ *
+ */
+public class ApplicationManagementService extends AbstractAdmin {
+
+
+ private static final Log log = LogFactory.getLog(ApplicationManagementService.class);
+ RegistryManager registryManager = new RegistryManager();
+
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ String tenantDomain = carbonContext.getTenantDomain();
+
+ /*
+ * Instantiate RepoNotificationService. Since this service is in the same
+ * component (org.apache.stratos.adc.mgt), a new object is created.
+ * TODO: Is there a better way to get this service?
+ */
+ private RepoNotificationService repoNotificationService = new RepoNotificationService();
+
+ /**
+ * Get Available Cartridges
+ *
+ * @return Available Cartridges
+ */
+ public Cartridge[] getAvailableCartridges(boolean multiTenant) throws ADCException {
+ List<Cartridge> cartridges = getAvailableCartridges(null, multiTenant);
+ // Following is very important when working with axis2
+ return cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()]);
+ }
+
+ /**
+ * Get Subscribed Cartridges
+ *
+ * @return Subscribed Cartridges
+ */
+ public Cartridge[] getSubscribedCartridges() throws ADCException {
+ checkSuperTenant();
+ List<Cartridge> cartridgeList = getSubscribedCartridges(null);
+ // Following is very important when working with axis2
+ return cartridgeList.isEmpty() ? new Cartridge[0] : cartridgeList.toArray(new Cartridge[cartridgeList.size()]);
+ }
+
+ /**
+ * Get available cartridges
+ */
+ public CartridgeWrapper getPagedAvailableCartridges(String cartridgeSearchString, int pageNumber, boolean multiTenant)
+ throws ADCException {
+ checkSuperTenant();
+ CartridgeWrapper cartridgeWrapper = new CartridgeWrapper();
+ List<Cartridge> cartridges = getAvailableCartridges(cartridgeSearchString, multiTenant);
+
+ // TODO Improve pagination
+ if (!cartridges.isEmpty()) {
+ // Paginate only if cartridges are there.
+ DataPaginator.doPaging(pageNumber, cartridges, cartridgeWrapper);
+ } else {
+ // Must set this value as axis2 stub client will return an array
+ // with length = 1 and null element if cartridges[] is null
+ cartridgeWrapper.set(cartridges);
+ }
+ return cartridgeWrapper;
+ }
+
+ private List<Cartridge> getAvailableCartridges(String cartridgeSearchString, Boolean multiTenant) throws ADCException {
+ List<Cartridge> cartridges = new ArrayList<Cartridge>();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Getting available cartridges. Search String: " + cartridgeSearchString + ", Multi-Tenant: " + multiTenant);
+ }
+
+ boolean allowMultipleSubscription = new Boolean(
+ System.getProperty(CartridgeConstants.FEATURE_MULTI_TENANT_MULTIPLE_SUBSCRIPTION_ENABLED));
+
+ try {
+ Pattern searchPattern = getSearchStringPattern(cartridgeSearchString);
+
+ String[] availableCartridges = ApplicationManagementUtil.getServiceClient().getRegisteredCartridges();
+
+ if (availableCartridges != null) {
+ for (String cartridgeType : availableCartridges) {
+ CartridgeInfo cartridgeInfo = null;
+ try {
+ cartridgeInfo = ApplicationManagementUtil.getServiceClient().getCartridgeInfo(cartridgeType);
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Error when calling getCartridgeInfo for " + cartridgeType + ", Error: "
+ + e.getMessage());
+ }
+ }
+ if (cartridgeInfo == null) {
+ // This cannot happen. But continue
+ if (log.isDebugEnabled()) {
+ log.debug("Cartridge Info not found: " + cartridgeType);
+ }
+ continue;
+ }
+
+ if (multiTenant != null && !multiTenant && cartridgeInfo.getMultiTenant()) {
+ // Need only Single-Tenant cartridges
+ continue;
+ } else if (multiTenant != null && multiTenant && !cartridgeInfo.getMultiTenant()) {
+ // Need only Multi-Tenant cartridges
+ continue;
+ }
+
+ if (!cartridgeMatches(cartridgeInfo, searchPattern)) {
+ continue;
+ }
+
+ Cartridge cartridge = new Cartridge();
+ cartridge.setCartridgeType(cartridgeType);
+ cartridge.setProvider(cartridgeInfo.getProvider());
+ cartridge.setDisplayName(cartridgeInfo.getDisplayName());
+ cartridge.setDescription(cartridgeInfo.getDescription());
+ cartridge.setVersion(cartridgeInfo.getVersion());
+ cartridge.setMultiTenant(cartridgeInfo.getMultiTenant());
+ cartridge.setStatus(CartridgeConstants.NOT_SUBSCRIBED);
+ cartridge.setCartridgeAlias("-");
+ cartridge.setActiveInstances(0);
+ cartridges.add(cartridge);
+
+ if (cartridgeInfo.getMultiTenant() && !allowMultipleSubscription) {
+ // If the cartridge is multi-tenant. We should not let users
+ // subscribe twice.
+ if (PersistenceManager.isAlreadySubscribed(cartridgeType,
+ ApplicationManagementUtil.getTenantId(getConfigContext()))) {
+ if (log.isDebugEnabled()) {
+ log.debug("Already subscribed to " + cartridgeType
+ + ". This multi-tenant cartridge will not be available to subscribe");
+ }
+ cartridge.setStatus(CartridgeConstants.SUBSCRIBED);
+ }
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("There are no available cartridges");
+ }
+ }
+ } catch (Exception e) {
+ String msg = "Error when getting available cartridges. " + e.getMessage();
+ log.error(msg, e);
+ throw new ADCException("An error occurred getting available cartridges ", e);
+ }
+
+ Collections.sort(cartridges);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Returning available cartridges " + cartridges.size());
+ }
+
+ return cartridges;
+ }
+
+ /**
+ * Get subscribed cartridges
+ */
+ public CartridgeWrapper getPagedSubscribedCartridges(String cartridgeSearchString, int pageNumber)
+ throws ADCException {
+ checkSuperTenant();
+ CartridgeWrapper cartridgeWrapper = new CartridgeWrapper();
+ List<Cartridge> cartridges = getSubscribedCartridges(cartridgeSearchString);
+
+ // TODO Improve pagination
+ if (!cartridges.isEmpty()) {
+ // Paginate only if cartridges are there.
+ DataPaginator.doPaging(pageNumber, cartridges, cartridgeWrapper);
+ } else {
+ cartridgeWrapper.set(cartridges);
+ }
+ return cartridgeWrapper;
+ }
+
+ private List<Cartridge> getSubscribedCartridges(String cartridgeSearchString) throws ADCException {
+ List<Cartridge> cartridges = new ArrayList<Cartridge>();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Getting subscribed cartridges. Search String: " + cartridgeSearchString);
+ }
+
+ try {
+ Pattern searchPattern = getSearchStringPattern(cartridgeSearchString);
+
+ List<CartridgeSubscription> subscriptionList = PersistenceManager
+ .retrieveSubscribedCartridges(ApplicationManagementUtil.getTenantId(getConfigContext()));
+
+ if (subscriptionList != null && !subscriptionList.isEmpty()) {
+ for (CartridgeSubscription subscription : subscriptionList) {
+ CartridgeInfo cartridgeInfo = null;
+ try {
+ cartridgeInfo = ApplicationManagementUtil.getServiceClient().getCartridgeInfo(
+ subscription.getCartridge());
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Error when calling getCartridgeInfo for " + subscription.getCartridge()
+ + ", Error: " + e.getMessage());
+ }
+ }
+ if (cartridgeInfo == null) {
+ // This cannot happen. But continue
+ if (log.isDebugEnabled()) {
+ log.debug("Cartridge Info not found: " + subscription.getCartridge());
+ }
+ continue;
+ }
+ if (!cartridgeMatches(cartridgeInfo, subscription, searchPattern)) {
+ continue;
+ }
+ TopologyManagementService topologyMgtService = DataHolder.getTopologyMgtService();
+ String[] ips = topologyMgtService.getActiveIPs(subscription.getCartridge(),
+ subscription.getClusterDomain(), subscription.getClusterSubdomain());
+ Cartridge cartridge = ApplicationManagementUtil.populateCartridgeInfo(cartridgeInfo, subscription, ips, tenantDomain);
+ cartridges.add(cartridge);
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("There are no subscribed cartridges");
+ }
+ }
+ } catch (Exception e) {
+ String msg = "Error when getting subscribed cartridges. " + e.getMessage();
+ log.error(msg, e);
+ throw new ADCException("An Error occurred when getting subscribed cartridges.", e);
+ }
+
+ Collections.sort(cartridges);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Returning subscribed cartridges " + cartridges.size());
+ }
+
+ return cartridges;
+ }
+
+ private Pattern getSearchStringPattern(String searchString) {
+ if (log.isDebugEnabled()) {
+ log.debug("Creating search pattern for " + searchString);
+ }
+ if (searchString != null) {
+ // Copied from org.wso2.carbon.webapp.mgt.WebappAdmin.doesWebappSatisfySearchString(WebApplication, String)
+ String regex = searchString.toLowerCase().replace("..?", ".?").replace("..*", ".*").replaceAll("\\?", ".?")
+ .replaceAll("\\*", ".*?");
+ if (log.isDebugEnabled()) {
+ log.debug("Created regex: " + regex + " for search string " + searchString);
+ }
+
+ Pattern pattern = Pattern.compile(regex);
+ return pattern;
+ }
+ return null;
+ }
+
+ // TODO: Improve search method
+ private boolean cartridgeMatches(CartridgeInfo cartridgeInfo, Pattern pattern) {
+ if (pattern != null) {
+ boolean matches = false;
+ if (cartridgeInfo.getDisplayName() != null) {
+ matches = pattern.matcher(cartridgeInfo.getDisplayName().toLowerCase()).find();
+ }
+ if (!matches && cartridgeInfo.getDescription() != null) {
+ matches = pattern.matcher(cartridgeInfo.getDescription().toLowerCase()).find();
+ }
+ return matches;
+ }
+ return true;
+ }
+
+ private boolean cartridgeMatches(CartridgeInfo cartridgeInfo, CartridgeSubscription cartridgeSubscription, Pattern pattern) {
+ if (pattern != null) {
+ boolean matches = false;
+ if (cartridgeInfo.getDisplayName() != null) {
+ matches = pattern.matcher(cartridgeInfo.getDisplayName().toLowerCase()).find();
+ }
+ if (!matches && cartridgeInfo.getDescription() != null) {
+ matches = pattern.matcher(cartridgeInfo.getDescription().toLowerCase()).find();
+ }
+ if (!matches && cartridgeSubscription.getCartridge() != null) {
+ matches = pattern.matcher(cartridgeSubscription.getCartridge().toLowerCase()).find();
+ }
+ if (!matches && cartridgeSubscription.getAlias() != null) {
+ matches = pattern.matcher(cartridgeSubscription.getAlias().toLowerCase()).find();
+ }
+ return matches;
+ }
+ return true;
+ }
+
+ public Cartridge getCartridgeInfo(String alias) throws ADCException, NotSubscribedException {
+ checkSuperTenant();
+ return ApplicationManagementUtil.getCartridgeInfo(alias, getTenantDomain());
+ }
+
+ public String[] getSubscribedCartridgeAliases() throws AxisFault {
+ try {
+ List<CartridgeSubscription> subscriptionList = PersistenceManager
+ .retrieveSubscribedCartridges(ApplicationManagementUtil.getTenantId(getConfigContext()));
+ List<String> subscribedAliases = new ArrayList<String>();
+ for (CartridgeSubscription cartridgeSubscription : subscriptionList) {
+
+ if(cartridgeSubscription.getProvider().equalsIgnoreCase(CartridgeConstants.PROVIDER_NAME_WSO2) &&
+ getCartridgeInfo(cartridgeSubscription.getAlias()).isMultiTenant()) {
+
+ subscribedAliases.add(cartridgeSubscription.getCartridge());
+ } else {
+ subscribedAliases.add(cartridgeSubscription.getAlias());
+ }
+ }
+ if(subscribedAliases.size() == 0) {
+ return new String[]{""};
+ } else {
+ return subscribedAliases.toArray(new String[subscribedAliases.size()]);
+ }
+
+ } catch (Exception e) {
+ String msg = "Exception in getting subscribed cartridge aliases :" + e.getMessage();
+ log.error(msg, e);
+ throw new AxisFault("An error occurred while getting subscribed cartridge aliases", e);
+ }
+ }
+
+ public PolicyDefinition[] getPolicyDefinitions() {
+ List<PolicyDefinition> policyDefinitions = PolicyHolder.getInstance().getPolicyDefinitions();
+ return policyDefinitions == null || policyDefinitions.isEmpty() ? new PolicyDefinition[0] : policyDefinitions
+ .toArray(new PolicyDefinition[policyDefinitions.size()]);
+ }
+
+ /**
+ * Subscribe to a cartridge
+ */
+ public SubscriptionInfo subscribe(String cartridgeType, String alias, String policy, String repoURL,
+ boolean privateRepo, String repoUsername, String repoPassword, String dataCartridgeType,
+ String dataCartridgeAlias) throws ADCException, PolicyException, UnregisteredCartridgeException,
+ InvalidCartridgeAliasException, DuplicateCartridgeAliasException, RepositoryRequiredException,
+ AlreadySubscribedException, RepositoryCredentialsRequiredException, InvalidRepositoryException,
+ RepositoryTransportException {
+
+ checkSuperTenant();
+
+ return ApplicationManagementUtil.doSubscribe(cartridgeType, alias, policy, repoURL, privateRepo, repoUsername,
+ repoPassword, dataCartridgeType, dataCartridgeAlias, getUsername(),
+ ApplicationManagementUtil.getTenantId(getConfigContext()), getTenantDomain());
+
+ }
+
+
+ /**
+ * Unsubscribing the cartridge
+ *
+ * @param alias name of the cartridge to be unsubscribed
+ */
+ public void unsubscribe(String alias) throws ADCException, NotSubscribedException {
+ checkSuperTenant();
+ CartridgeSubscription subscription = null;
+
+ try {
+ subscription = PersistenceManager.getSubscription(tenantDomain, alias);
+ } catch (Exception e) {
+ String msg = "Failed to get subscription for " + tenantDomain + " and alias " + alias;
+ log.error(msg, e);
+ throw new ADCException(msg, e);
+ }
+
+ if (subscription == null) {
+ String msg = "Tenant " + tenantDomain + " is not subscribed for " + alias;
+ log.error(msg);
+ throw new NotSubscribedException("You have not subscribed for " + alias, alias);
+ }
+
+ try {
+ String clusterDomain = subscription.getClusterDomain();
+ String clusterSubDomain = subscription.getClusterSubdomain();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Finding cartridge information for " + subscription.getCartridge());
+ }
+ CartridgeInfo cartridgeInfo = ApplicationManagementUtil.getServiceClient().getCartridgeInfo(subscription.getCartridge());
+ if (log.isDebugEnabled()) {
+ log.debug("Found " + cartridgeInfo.getDisplayName() + " for " + subscription.getCartridge());
+ }
+ if (!cartridgeInfo.getMultiTenant()) {
+ log.info("Terminating all instances of " + clusterDomain + " " + clusterSubDomain);
+ ApplicationManagementUtil.getServiceClient().terminateAllInstances(clusterDomain, clusterSubDomain);
+ log.info("All instances terminated.");
+ log.info("Unregistering services...");
+ ApplicationManagementUtil.getServiceClient().unregisterService(clusterDomain, clusterSubDomain);
+ log.info("Successfully terminated instances ..");
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("Cartridge "
+ + subscription.getCartridge()
+ + " is a multi-tenant cartridge and therefore will not terminate all instances and unregister services");
+ }
+ }
+
+ new RepositoryFactory().destroyRepository(alias, tenantDomain, getUsername());
+ log.info("Repo is destroyed successfully.. ");
+
+ PersistenceManager.updateSubscriptionState(subscription.getSubscriptionId(), "UNSUBSCRIBED");
+ new DNSManager().removeSubDomain(subscription.getHostName());
+ registryManager.removeDomainMappingFromRegistry(subscription.getHostName());
+ TopologyManagementService topologyMgtService = DataHolder.getTopologyMgtService();
+
+ String[] ips = topologyMgtService.getActiveIPs(subscription.getCartridge(),
+ subscription.getClusterDomain(), subscription.getClusterSubdomain());
+ PersistenceManager.updateInstanceState("INACTIVE", ips, subscription.getClusterDomain(), subscription.getClusterSubdomain(), subscription.getCartridge());
+
+ } catch (ADCException e) {
+ log.error(e.getMessage(), e);
+ throw e;
+ } catch (Exception e1) {
+ String msg1 = "Exception occurred :" + e1.getMessage();
+ log.error(msg1);
+ throw new ADCException("Unsubscribe failed for cartridge " + alias, e1);
+ }
+ }
+
+
+ public String addDomainMapping(String mappedDomain, String cartridgeAlias) throws ADCException, DomainMappingExistsException, NotSubscribedException {
+ checkSuperTenant();
+ // TODO Following was in CLI. Fix this
+ // if (domain.indexOf('.') == -1) {
+ // System.out.println("\nOwn domain should include a '.' ");
+ // }
+
+ CartridgeSubscription subscription = null;
+ String actualHost = null;
+
+ try {
+ subscription = PersistenceManager.getSubscription(tenantDomain, cartridgeAlias);
+ } catch (Exception e) {
+ String msg = "Failed to get subscription for " + tenantDomain + " and alias " + cartridgeAlias;
+ log.error(msg, e);
+ throw new ADCException(msg, e);
+ }
+ if (subscription == null) {
+ String msg = "Tenant " + tenantDomain + " is not subscribed for " + cartridgeAlias;
+ log.error(msg);
+ throw new NotSubscribedException("You have not subscribed for " + cartridgeAlias, cartridgeAlias);
+ }
+
+ try {
+ actualHost = getActualHost(cartridgeAlias);
+ registryManager.addDomainMappingToRegistry(mappedDomain, actualHost);
+ log.info("Domain mapping is added for " + mappedDomain + " tenant: " + tenantDomain);
+ PersistenceManager.updateDomainMapping(
+ ApplicationManagementUtil.getTenantId(getConfigContext()), cartridgeAlias, mappedDomain);
+ } catch (RegistryException e) {
+ String msg = "Unable to add the mapping due to registry transaction error";
+ log.error(msg, e);
+ throw new ADCException("Unable to add the mapping due to internal error!", e);
+ } catch (DomainMappingExistsException e) {
+ String msg = "Domain mapping already exists.";
+ log.error(msg, e);
+ throw e;
+ } catch (Exception e) {
+ String msg = "Error occurred. Reason : " + e.getMessage();
+ log.error(msg, e);
+ throw new ADCException(msg, e);
+ }
+ return actualHost;
+ }
+
+ private String getActualHost(String cartridgeName) throws Exception {
+ return PersistenceManager.getHostNameForCartridgeName(
+ ApplicationManagementUtil.getTenantId(getConfigContext()), cartridgeName);
+ }
+
+ public void removeDomainMapping(String cartridgeAlias) throws ADCException, NotSubscribedException {
+ checkSuperTenant();
+ CartridgeSubscription subscription = null;
+ String actualHost = null;
+
+ try {
+ subscription = PersistenceManager.getSubscription(tenantDomain, cartridgeAlias);
+ } catch (Exception e) {
+ String msg = "Failed to get subscription for " + tenantDomain + " and alias " + cartridgeAlias;
+ log.error(msg, e);
+ throw new ADCException(msg, e);
+ }
+ if (subscription == null) {
+ String msg = "Tenant " + tenantDomain + " is not subscribed for " + cartridgeAlias;
+ log.error(msg);
+ throw new NotSubscribedException("You have not subscribed for " + cartridgeAlias, cartridgeAlias);
+ }
+
+ try {
+ actualHost = getActualHost(cartridgeAlias);
+ registryManager.removeDomainMappingFromRegistry(actualHost);
+ log.info("Domain mapping is removed for " + actualHost + " tenant: " + tenantDomain);
+ PersistenceManager.updateDomainMapping(ApplicationManagementUtil.getTenantId(getConfigContext()),
+ cartridgeAlias, null);
+ } catch (RegistryException e) {
+ String msg = "Unable to remove the mapping due to registry transaction error";
+ log.error(msg, e);
+ throw new ADCException("Unable to remove the mapping due to internal error!", e);
+ } catch (Exception e) {
+ String msg = "Error occurred. Reason : " + e.getMessage();
+ log.error(msg, e);
+ throw new ADCException(msg, e);
+ }
+ }
+
+ public void synchronizeRepository(String cartridgeAlias) throws ADCException, NotSubscribedException {
+ checkSuperTenant();
+ CartridgeSubscription subscription = null;
+
+ // Validating subscription
+ try {
+ subscription = PersistenceManager.getSubscription(tenantDomain, cartridgeAlias);
+ } catch (Exception e) {
+ String msg = "Failed to get subscription for " + tenantDomain + " and alias " + cartridgeAlias;
+ log.error(msg, e);
+ throw new ADCException(msg, e);
+ }
+ if (subscription == null) {
+ String msg = "Tenant " + tenantDomain + " is not subscribed for " + cartridgeAlias;
+ log.error(msg);
+ throw new NotSubscribedException("You have not subscribed for " + cartridgeAlias, cartridgeAlias);
+ }
+
+ try {
+ repoNotificationService.notifyRepoUpdate(tenantDomain, cartridgeAlias);
+ } catch (Exception e) {
+ throw new ADCException(e.getMessage() != null ? e.getMessage() : "Failed to synchronize repository", e);
+ }
+ }
+
+ /**
+ * Validate authentication.
+ * First call of cli tool in the prompt mode after log in.
+ *
+ * @return The tenant domain
+ */
+ public String getTenantDomain() {
+ if (tenantDomain != null) {
+ // This means, authentication is successful
+ log.info("Tenant " + tenantDomain + " is authorized to access Application Management Service!");
+ }
+ return tenantDomain;
+ }
+
+ /**
+ * Allow to check whether features are enabled in the back-end
+ *
+ * @param key
+ * The propery key
+ * @return {@code true} if feature is enabled
+ */
+ public boolean isFeatureEnabled(String key) {
+ if (key != null && key.startsWith("feature.")) {
+ return new Boolean(System.getProperty(key));
+ }
+ return false;
+ }
+
+
+ public RepositoryInformation testRepositoryConnection(String repoURL, String repoUsername, String repoPassword, boolean privateRepo)
+ throws RepositoryRequiredException, ADCException, RepositoryCredentialsRequiredException,
+ InvalidRepositoryException, RepositoryTransportException {
+ return ApplicationManagementUtil.validateRepository(repoURL, repoUsername, repoPassword, privateRepo, true);
+ }
+
+ // TODO Remove following when we support cartridge subscription for Super-tenant
+ private void checkSuperTenant() throws ADCException {
+ if (log.isDebugEnabled()) {
+ log.debug("Checking whether super tenant accesses the service methods. Tenant ID: "
+ + ApplicationManagementUtil.getTenantId(getConfigContext()) + ", Tenant Domain: " + carbonContext.getTenantDomain());
+ }
+ if (MultitenantConstants.SUPER_TENANT_ID == ApplicationManagementUtil.getTenantId(getConfigContext())) {
+ throw new ADCException("Super Tenant is not allowed to complete requested operation");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6724d973/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/InstanceInformationManagementService.java
----------------------------------------------------------------------
diff --git a/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/InstanceInformationManagementService.java b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/InstanceInformationManagementService.java
new file mode 100644
index 0000000..692dafa
--- /dev/null
+++ b/components/stratos/artifact-deployment-coordinator/org.apache.stratos.adc.mgt/2.1.3/src/main/java/org/apache/stratos/adc/mgt/service/InstanceInformationManagementService.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright WSO2, Inc. (http://wso2.com)
+ *
+ * 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 org.apache.stratos.adc.mgt.service;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.adc.mgt.utils.PersistenceManager;
+
+public class InstanceInformationManagementService {
+
+
+ private static final Log log = LogFactory.getLog(InstanceInformationManagementService.class);
+
+ /**
+ * Everytime an instance is started up, this operation is invoked
+ * (by the AgentService)
+ * @param instanceIp
+ * @param tenantId
+ * @param clusterDomain
+ * @param clusterSubDomain
+ * @param cartridge
+ * @param state
+ *
+ */
+ public void updateInstanceState(String instanceIp,
+ int tenantId,
+ String clusterDomain,
+ String clusterSubDomain,
+ String cartridge,
+ String state) {
+
+ log.info("Message receieved in Instance Info Service.." + instanceIp + tenantId + clusterDomain + clusterSubDomain
+ + cartridge + state);
+
+ try {
+ PersistenceManager.persistCartridgeInstanceInfo(instanceIp, clusterDomain, clusterSubDomain, cartridge, state);
+ } catch (Exception e) {
+ log.error("Exception is occurred in updating instance state. Reason, " + e.getMessage());
+ }
+ }
+}