Skip to content

Commit

Permalink
added a new data migration layer - when importing data from an older …
Browse files Browse the repository at this point in the history
…version of apiman, we now first migrate the data to the newest data model
  • Loading branch information
EricWittmann committed Mar 17, 2016
1 parent a33125e commit 0026ff4
Show file tree
Hide file tree
Showing 78 changed files with 9,910 additions and 203 deletions.
Expand Up @@ -42,7 +42,7 @@
@Table(name = "apis")
@IdClass(OrganizationBasedCompositeId.class)
@JsonInclude(Include.NON_NULL)
public class ApiBean implements Serializable {
public class ApiBean implements Serializable, Cloneable {

private static final long serialVersionUID = 1526742536153467539L;

Expand Down Expand Up @@ -181,4 +181,12 @@ public String toString() {
+ ", description=" + description + ", createdBy=" + createdBy + ", createdOn=" + createdOn
+ "]";
}

/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
Expand Up @@ -52,7 +52,7 @@
@Table(name = "api_versions",
uniqueConstraints = { @UniqueConstraint(columnNames = { "api_id", "api_org_id", "version" }) })
@JsonInclude(Include.NON_NULL)
public class ApiVersionBean implements Serializable {
public class ApiVersionBean implements Serializable, Cloneable {

private static final long serialVersionUID = -2218697175049442690L;

Expand Down Expand Up @@ -414,4 +414,12 @@ public String toString() {
+ ", publishedOn=" + publishedOn + ", retiredOn=" + retiredOn + ", definitionType="
+ definitionType + "]";
}

/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
Expand Up @@ -42,7 +42,7 @@
@Table(name = "clients")
@IdClass(OrganizationBasedCompositeId.class)
@JsonInclude(Include.NON_NULL)
public class ClientBean implements Serializable {
public class ClientBean implements Serializable, Cloneable {

private static final long serialVersionUID = -197129444021040365L;

Expand Down Expand Up @@ -158,5 +158,13 @@ public String toString() {
+ ", description=" + description + ", createdBy=" + createdBy + ", createdOn=" + createdOn
+ "]";
}

/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}

}
Expand Up @@ -48,7 +48,7 @@
@UniqueConstraint(columnNames = { "client_id", "client_org_id", "version" }),
@UniqueConstraint(columnNames = { "apikey" })})
@JsonInclude(Include.NON_NULL)
public class ClientVersionBean implements Serializable {
public class ClientVersionBean implements Serializable, Cloneable {

private static final long serialVersionUID = -2218697175049442690L;

Expand Down Expand Up @@ -282,5 +282,13 @@ public String toString() {
+ ", modifiedBy=" + modifiedBy + ", modifiedOn=" + modifiedOn + ", publishedOn="
+ publishedOn + ", retiredOn=" + retiredOn + ", apikey=" + apikey + "]";
}

/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}

}
Expand Up @@ -44,7 +44,7 @@
@Entity
@Table(name = "contracts",
uniqueConstraints = { @UniqueConstraint(columnNames = { "clientv_id", "apiv_id" }) })
public class ContractBean implements Serializable {
public class ContractBean implements Serializable, Cloneable {

private static final long serialVersionUID = -8534463608508756791L;

Expand Down Expand Up @@ -169,5 +169,13 @@ public String toString() {
return "ContractBean [id=" + id + ", client=" + client + ", api=" + api + ", plan="
+ plan + ", createdBy=" + createdBy + ", createdOn=" + createdOn + "]";
}


/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}

}
Expand Up @@ -42,7 +42,7 @@
@Table(name = "plans")
@IdClass(OrganizationBasedCompositeId.class)
@JsonInclude(Include.NON_NULL)
public class PlanBean implements Serializable {
public class PlanBean implements Serializable, Cloneable {

private static final long serialVersionUID = -7961331943587584049L;

Expand Down Expand Up @@ -157,5 +157,13 @@ public String toString() {
return "PlanBean [organization=" + organization + ", id=" + id + ", name=" + name + ", description="
+ description + ", createdBy=" + createdBy + ", createdOn=" + createdOn + "]";
}

/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}

}
Expand Up @@ -42,7 +42,7 @@
@Entity
@Table(name = "plan_versions",
uniqueConstraints = { @UniqueConstraint(columnNames = { "plan_id", "plan_org_id", "version" }) })
public class PlanVersionBean implements Serializable {
public class PlanVersionBean implements Serializable, Cloneable {

private static final long serialVersionUID = -2218697175049442690L;

Expand Down Expand Up @@ -243,5 +243,13 @@ public String toString() {
+ ", createdBy=" + createdBy + ", createdOn=" + createdOn + ", modifiedBy=" + modifiedBy
+ ", modifiedOn=" + modifiedOn + ", lockedOn=" + lockedOn + "]";
}

/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}

}
Expand Up @@ -52,7 +52,7 @@
@Entity
@Table(name = "policies")
@JsonInclude(Include.NON_NULL)
public class PolicyBean implements Serializable {
public class PolicyBean implements Serializable, Cloneable {

private static final long serialVersionUID = -8534463608508756791L;

Expand Down Expand Up @@ -346,5 +346,13 @@ public String toString() {
+ createdBy + ", createdOn=" + createdOn + ", modifiedBy=" + modifiedBy + ", modifiedOn="
+ modifiedOn + ", definition=" + definition + ", orderIndex=" + orderIndex + "]";
}

/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}

}
@@ -0,0 +1,105 @@
/*
* Copyright 2016 JBoss 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 io.apiman.manager.api.core.logging;

/**
* Logs to a string builder.
* @author eric.wittmann@gmail.com
*/
@SuppressWarnings("nls")
public class StringBuilderLogger implements IApimanLogger {

private StringBuilder builder = new StringBuilder();

/**
* Constructor.
*/
public StringBuilderLogger() {
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#info(java.lang.String)
*/
@Override
public void info(String message) {
append("INFO: " + message);
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#warn(java.lang.String)
*/
@Override
public void warn(String message) {
append("WARN: " + message);
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#debug(java.lang.String)
*/
@Override
public void debug(String message) {
append("DEBUG: " + message);
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#trace(java.lang.String)
*/
@Override
public void trace(String message) {
append("TRACE: " + message);
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#error(java.lang.Throwable)
*/
@Override
public void error(Throwable error) {
append("ERROR: " + error.getMessage());
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#error(java.lang.String, java.lang.Throwable)
*/
@Override
public void error(String message, Throwable error) {
append("ERROR: " + message);
}

/**
* Append to the builder.
* @param message
*/
private void append(String message) {
builder.append(message);
builder.append("\n");
}

/**
* @return the log data
*/
public String string() {
return builder.toString();
}

/**
* Reset the builder to empty.
*/
public void reset() {
builder = new StringBuilder();
}

}
@@ -0,0 +1,80 @@
/*
* Copyright 2016 JBoss 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 io.apiman.manager.api.core.logging;

/**
* @author eric.wittmann@gmail.com
*/
public class SystemOutLogger implements IApimanLogger {

/**
* Constructor.
*/
public SystemOutLogger() {
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#info(java.lang.String)
*/
@Override
public void info(String message) {
System.out.println("INFO: " + message); //$NON-NLS-1$
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#warn(java.lang.String)
*/
@Override
public void warn(String message) {
System.out.println("WARN: " + message); //$NON-NLS-1$
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#debug(java.lang.String)
*/
@Override
public void debug(String message) {
System.out.println("DEBUG: " + message); //$NON-NLS-1$
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#trace(java.lang.String)
*/
@Override
public void trace(String message) {
System.out.println("TRACE: " + message); //$NON-NLS-1$
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#error(java.lang.Throwable)
*/
@Override
public void error(Throwable error) {
System.out.println("** ERROR **"); //$NON-NLS-1$
error.printStackTrace();
}

/**
* @see io.apiman.manager.api.core.logging.IApimanLogger#error(java.lang.String, java.lang.Throwable)
*/
@Override
public void error(String message, Throwable error) {
System.out.println("** ERROR: " + message + " **"); //$NON-NLS-1$ //$NON-NLS-2$
error.printStackTrace();
}

}

0 comments on commit 0026ff4

Please sign in to comment.