/*
* #%L
* BroadleafCommerce CMS Module
* %%
* Copyright (C) 2009 - 2014 Broadleaf Commerce
* %%
* 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.
* #L%
*/
package org.broadleafcommerce.cms.url.domain;
import org.broadleafcommerce.cms.url.type.URLRedirectType;
import org.broadleafcommerce.common.copy.CreateResponse;
import org.broadleafcommerce.common.copy.MultiTenantCopyContext;
/**
* A bean representation of a URLHandler
* @author bpolster
*
*/
public class URLHandlerDTO implements URLHandler {
private static final long serialVersionUID = 1L;
protected Long id = null;
protected String incomingURL = "";
protected String newURL;
protected String urlRedirectType;
public URLHandlerDTO(String newUrl, URLRedirectType redirectType) {
setUrlRedirectType(redirectType);
setNewURL(newUrl);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getIncomingURL() {
return incomingURL;
}
public void setIncomingURL(String incomingURL) {
this.incomingURL = incomingURL;
}
public String getNewURL() {
return newURL;
}
public void setNewURL(String newURL) {
this.newURL = newURL;
}
@Override
public URLRedirectType getUrlRedirectType() {
return URLRedirectType.getInstance(urlRedirectType);
}
@Override
public void setUrlRedirectType(URLRedirectType redirectType) {
this.urlRedirectType = redirectType.getType();
}
@Override
public <G extends URLHandler> CreateResponse<G> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException {
CreateResponse<G> createResponse = context.createOrRetrieveCopyInstance(this);
if (createResponse.isAlreadyPopulated()) {
return createResponse;
}
URLHandler cloned = createResponse.getClone();
cloned.setIncomingURL(incomingURL);
cloned.setNewURL(newURL);
cloned.setUrlRedirectType( URLRedirectType.getInstance(urlRedirectType));
return createResponse;
}
}