Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from RaimondKempees/dd4t-compat
Dd4t compat
- Loading branch information
Showing
9 changed files
with
378 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
*.iml | ||
dd4t-core/target | ||
dd4t-databind/target | ||
dd4t-test/target | ||
dd4t-providers-rs/target | ||
dd4t-providers/target | ||
dd4t-api/target | ||
.classpath | ||
.project | ||
.settings | ||
.metadata | ||
.recommenders | ||
cd_*.xml | ||
|
||
target | ||
cd_licenses.xml | ||
META-INF | ||
Servers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>dd4t-parent</artifactId> | ||
<groupId>org.dd4t</groupId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>jar</packaging> | ||
<artifactId>dd4t-compability</artifactId> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.dd4t</groupId> | ||
<artifactId>dd4t-core</artifactId> | ||
<version>${version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
33 changes: 33 additions & 0 deletions
33
dd4t-compatibility/src/main/java/org/dd4t/contentmodel/exceptions/ItemNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright 2011 Capgemini & SDL | ||
* | ||
* 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.dd4t.contentmodel.exceptions; | ||
|
||
public class ItemNotFoundException extends Exception { | ||
|
||
private static final long serialVersionUID = 8243724759254216595L; | ||
|
||
public ItemNotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
public ItemNotFoundException(Throwable t) { | ||
super(t); | ||
} | ||
|
||
public ItemNotFoundException(String message, Throwable t) { | ||
super(message, t); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...mpatibility/src/main/java/org/dd4t/contentmodel/exceptions/NotAuthenticatedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.dd4t.contentmodel.exceptions; | ||
|
||
public class NotAuthenticatedException extends Exception { | ||
|
||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = -1393489613071343863L; | ||
|
||
public NotAuthenticatedException(String message) { | ||
super(message); | ||
} | ||
|
||
public NotAuthenticatedException(Throwable t) { | ||
super(t); | ||
} | ||
|
||
public NotAuthenticatedException(String message, Throwable t) { | ||
super(message, t); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-compatibility/src/main/java/org/dd4t/contentmodel/exceptions/NotAuthorizedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright 2011 Capgemini & SDL | ||
* | ||
* 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.dd4t.contentmodel.exceptions; | ||
|
||
public class NotAuthorizedException extends Exception { | ||
|
||
private static final long serialVersionUID = 7860070186906683875L; | ||
|
||
public NotAuthorizedException(String message) { | ||
super(message); | ||
} | ||
|
||
public NotAuthorizedException(Throwable t) { | ||
super(t); | ||
} | ||
|
||
public NotAuthorizedException(String message, Throwable t) { | ||
super(message, t); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
dd4t-compatibility/src/main/java/org/dd4t/core/factories/ComponentFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* Copyright 2011 Capgemini & SDL | ||
* | ||
* 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.dd4t.core.factories; | ||
|
||
import org.dd4t.contentmodel.Component; | ||
import org.dd4t.contentmodel.exceptions.ItemNotFoundException; | ||
import org.dd4t.contentmodel.exceptions.NotAuthenticatedException; | ||
import org.dd4t.contentmodel.exceptions.NotAuthorizedException; | ||
import org.dd4t.core.request.RequestContext; | ||
|
||
@Deprecated | ||
public interface ComponentFactory extends Factory { | ||
/** | ||
* Get a Component by its uri. No security available; the method will fail if a | ||
* SecurityFilter is configured on the factory. | ||
* @param uri | ||
* @param context | ||
* @return | ||
* @throws ItemNotFoundException | ||
* @throws NotAuthorizedException | ||
* @throws NotAuthenticatedException | ||
*/ | ||
public Component getComponent(String uri) throws ItemNotFoundException, NotAuthorizedException, NotAuthenticatedException; | ||
|
||
/** | ||
* Get a Component by its uri. The request context is used by the security filter (if there is one). | ||
* @param uri | ||
* @param context | ||
* @return | ||
* @throws ItemNotFoundException | ||
* @throws NotAuthorizedException | ||
* @throws NotAuthenticatedException | ||
*/ | ||
public Component getComponent(String uri, RequestContext context) throws ItemNotFoundException, NotAuthorizedException, NotAuthenticatedException; | ||
|
||
/** | ||
* Get a component by its uri and component template uri. No security available; the method will fail if a | ||
* SecurityFilter is configured on the factory. | ||
* @param componentUri | ||
* @param componentTemplateUri | ||
* @param context | ||
* @return | ||
* @throws ItemNotFoundException | ||
* @throws NotAuthorizedException | ||
* @throws NotAuthenticatedException | ||
*/ | ||
public Component getComponent(String componentUri, String componentTemplateUri) throws ItemNotFoundException, NotAuthorizedException, NotAuthenticatedException; | ||
|
||
/** | ||
* Get a component by its uri and component template uri. The request context is used by the security filter (if there is one). | ||
* @param componentUri | ||
* @param componentTemplateUri | ||
* @param context | ||
* @return | ||
* @throws ItemNotFoundException | ||
* @throws NotAuthorizedException | ||
* @throws NotAuthenticatedException | ||
*/ | ||
public Component getComponent(String componentUri, String componentTemplateUri, RequestContext context) throws ItemNotFoundException, NotAuthorizedException, NotAuthenticatedException; | ||
|
||
/** | ||
* Get an embedded (i.e.: stored inside of a DD4T page) component. This method is slightly slower as it has to utilize the componentlinker. | ||
* | ||
* @param tcmUri | ||
* @return | ||
* @throws ItemNotFoundException | ||
*/ | ||
public Component getEmbeddedComponent(String uri) throws ItemNotFoundException; | ||
} |
102 changes: 102 additions & 0 deletions
102
dd4t-compatibility/src/main/java/org/dd4t/core/factories/impl/GenericComponentFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** | ||
* Copyright 2011 Capgemini & SDL | ||
* | ||
* 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.dd4t.core.factories.impl; | ||
|
||
import org.dd4t.contentmodel.Component; | ||
import org.dd4t.contentmodel.ComponentPresentation; | ||
import org.dd4t.contentmodel.exceptions.ItemNotFoundException; | ||
import org.dd4t.contentmodel.exceptions.NotAuthenticatedException; | ||
import org.dd4t.contentmodel.exceptions.NotAuthorizedException; | ||
import org.dd4t.core.exceptions.FactoryException; | ||
import org.dd4t.core.factories.ComponentFactory; | ||
import org.dd4t.core.request.RequestContext; | ||
import org.dd4t.providers.PayloadCacheProvider; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Backwards compatibility class | ||
* @author Rogier Oudshoorn | ||
* | ||
*/ | ||
public class GenericComponentFactory extends BaseFactory implements ComponentFactory { | ||
|
||
private static Logger logger = LoggerFactory | ||
.getLogger(GenericComponentFactory.class); | ||
|
||
@Override | ||
public void setCacheProvider(PayloadCacheProvider cacheAgent) { | ||
// necessary setter, but don't bother | ||
} | ||
|
||
@Override | ||
public Component getComponent(String uri) throws ItemNotFoundException, | ||
NotAuthorizedException, NotAuthenticatedException { | ||
ComponentPresentation cp; | ||
try { | ||
cp = ComponentPresentationFactoryImpl.getInstance().getComponentPresentation(uri, null); | ||
} catch (FactoryException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
|
||
return null; | ||
} | ||
|
||
return cp.getComponent(); | ||
} | ||
|
||
@Override | ||
public Component getComponent(String uri, RequestContext context) | ||
throws ItemNotFoundException, NotAuthorizedException, | ||
NotAuthenticatedException { | ||
return getComponent(uri); | ||
} | ||
|
||
@Override | ||
public Component getComponent(String componentUri, | ||
String componentTemplateUri) throws ItemNotFoundException, | ||
NotAuthorizedException, NotAuthenticatedException { | ||
ComponentPresentation cp; | ||
try { | ||
cp = ComponentPresentationFactoryImpl.getInstance().getComponentPresentation(componentUri, componentTemplateUri); | ||
} catch (FactoryException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
|
||
return null; | ||
} | ||
|
||
return cp.getComponent(); | ||
} | ||
|
||
@Override | ||
public Component getComponent(String componentUri, | ||
String componentTemplateUri, RequestContext context) | ||
throws ItemNotFoundException, NotAuthorizedException, | ||
NotAuthenticatedException { | ||
return getComponent(componentUri, componentTemplateUri); | ||
} | ||
|
||
@Override | ||
public Component getEmbeddedComponent(String uri) | ||
throws ItemNotFoundException { | ||
// Discuss if this is somehting we still should support, we probably do ... | ||
|
||
return null; | ||
} | ||
|
||
|
||
} |
26 changes: 26 additions & 0 deletions
26
dd4t-compatibility/src/main/java/org/dd4t/core/factories/impl/GenericPageFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright 2011 Rogier Oudshoorn | ||
* | ||
* 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.dd4t.core.factories.impl; | ||
|
||
/** | ||
* Backwards compatibility class | ||
* @author Rogier Oudshoorn | ||
* | ||
*/ | ||
@Deprecated | ||
public class GenericPageFactory extends PageFactoryImpl { | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
dd4t-compatibility/src/main/java/org/dd4t/core/request/impl/BasicRequestContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright 2011 Capgemini & SDL | ||
* | ||
* 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.dd4t.core.request.impl; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.dd4t.core.request.RequestContext; | ||
|
||
|
||
/** | ||
* Simple implementation of the RequestContext interface. | ||
* | ||
* @author rooudsho | ||
* | ||
*/ | ||
@Deprecated | ||
public class BasicRequestContext implements RequestContext { | ||
private HttpServletRequest req; | ||
|
||
public BasicRequestContext(HttpServletRequest req){ | ||
this.req = req; | ||
} | ||
|
||
@Override | ||
public HttpServletRequest getServletRequest() { | ||
return req; | ||
} | ||
|
||
@Override | ||
public boolean isUserInRole(String role) { | ||
return req.isUserInRole(role); | ||
} | ||
} |