Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonar fixes #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class SliceContextFactory implements ContextFactory {
* @deprecated Use method with explicit injector name
* {@code ContextFactory#getServletRequestContext(String, ServletRequest, ServletResponse)}
*/
@Deprecated
@Override
public Context getServletRequestContext(ServletRequest request, ServletResponse response) {
return getServletRequestContext(COMMON_CONTEXT_NAME, request, response);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*-
* #%L
* Slice - Core
* %%
* Copyright (C) 2012 Cognifide Limited
* %%
* #%L
* Slice - Core
* %%
* Copyright (C) 2012 Cognifide Limited
* %%
* 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
Expand All @@ -14,7 +14,7 @@
* 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.
* limitations under the License.
* #L%
*/

Expand Down Expand Up @@ -46,10 +46,12 @@ public SliceContextScope() {
threadContextProvider = new ThreadLocal<ContextProvider>();
}

@Override
public void setContextProvider(final ContextProvider contextProvider) {
threadContextProvider.set(contextProvider);
}

@Override
public ContextProvider getContextProvider() {
return threadContextProvider.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ private Context createContext(String injectorName, ServletRequest request, Servl

@Override
public void init(final FilterConfig filterConfig) throws ServletException {
// required by the Filter interface but no implementation is needed in this case
}

@Override
public void destroy() {
// required by the Filter interface but no implementation is needed in this case
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@
import com.cognifide.slice.api.model.ModelClassResolver;
import com.cognifide.slice.api.provider.ComponentDefinitionProvider;
import com.cognifide.slice.api.provider.ComponentDefinitionResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component
@Service
public class SliceModelClassResolver implements ModelClassResolver {

private static final Logger LOG = LoggerFactory.getLogger(SliceModelClassResolver.class);

@Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,policyOption = ReferencePolicyOption.GREEDY)
private ComponentDefinitionResolver componentDefinitionResolver;

Expand Down Expand Up @@ -111,6 +115,10 @@ private Map<String, Object> getDefinition(String resourceType) {
private Map<String, Object> getDefinitionWithResolver(String resourceType) {
ResourceResolver resolver = null;
try {
/*
FIXME: This method has been deprecated as of Sling 2.4 (bundle version 2.5.0)
consider replacing it with getServiceResourceResolver
*/
resolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
final Resource componentDefinition = resolver.getResource(resourceType);
if (componentDefinition != null) {
Expand All @@ -121,6 +129,7 @@ private Map<String, Object> getDefinitionWithResolver(String resourceType) {
}
return null;
} catch (LoginException e) {
LOG.error("Failed to load definition due to insufficient permissions.", e);
return null;
} finally {
if (resolver != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class SliceModelProvider implements ModelProvider {

private static final Logger LOG = LoggerFactory.getLogger(SliceModelProvider.class);

public static final String NEW_INSTANCE_FROM_ADAPTABLE_MESSAGE = "creating new instance of {} from {}";

private final Injector injector;

private final ContextScope contextScope;
Expand Down Expand Up @@ -98,7 +100,7 @@ public final <T> T get(final Class<T> type, final String path) {
* against servlet specification.
*/
ExecutionContextImpl executionItem = new ExecutionContextImpl(path);
LOG.debug("creating new instance of {} from {}", new Object[] { type.getName(), path });
LOG.debug(NEW_INSTANCE_FROM_ADAPTABLE_MESSAGE, new Object[] { type.getName(), path });
return get(type, executionItem);
}

Expand All @@ -108,7 +110,7 @@ public final <T> T get(final Class<T> type, final String path) {
@Override
public <T> T get(Class<T> type, Resource resource) {
ExecutionContextImpl executionItem = new ExecutionContextImpl(resource);
LOG.debug("creating new instance of {} from {}", new Object[] { type.getName(), resource });
LOG.debug(NEW_INSTANCE_FROM_ADAPTABLE_MESSAGE, new Object[] { type.getName(), resource });
return get(type, executionItem);
}

Expand All @@ -118,7 +120,7 @@ public <T> T get(Class<T> type, Resource resource) {
@Override
public <T> T get(Key<T> key, Resource resource) {
ExecutionContextImpl executionItem = new ExecutionContextImpl(resource);
LOG.debug("creating new instance of {} from {}", new Object[] { key.toString(), resource });
LOG.debug(NEW_INSTANCE_FROM_ADAPTABLE_MESSAGE, new Object[] { key.toString(), resource });
return get(key, executionItem);
}

Expand All @@ -128,7 +130,7 @@ public <T> T get(Key<T> key, Resource resource) {
@Override
public <T> T get(Key<T> key, String path) {
ExecutionContextImpl executionItem = new ExecutionContextImpl(path);
LOG.debug("creating new instance of {} from {}", new Object[] { key.toString(), path });
LOG.debug(NEW_INSTANCE_FROM_ADAPTABLE_MESSAGE, new Object[] { key.toString(), path });
return get(key, executionItem);
}

Expand Down