You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2014/11/24 12:16:04 UTC

[3/6] directory-fortress-enmasse git commit: Added an abstract class that is used by all the managers. It contains two methods used by all the managers

Added an abstract class that is used by all the managers. It contains
two methods used by all the managers

Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/commit/f35bf521
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/tree/f35bf521
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/diff/f35bf521

Branch: refs/heads/master
Commit: f35bf52154fa8d3c5c1371951ae7cdfba94bb50a
Parents: 04e9383
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Sat Nov 22 10:11:04 2014 +0100
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Sat Nov 22 10:11:04 2014 +0100

----------------------------------------------------------------------
 .../directory/fortress/rest/AbstractImpl.java   | 62 ++++++++++++++++++++
 1 file changed, 62 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/f35bf521/src/main/java/org/apache/directory/fortress/rest/AbstractImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/rest/AbstractImpl.java b/src/main/java/org/apache/directory/fortress/rest/AbstractImpl.java
new file mode 100644
index 0000000..90f06d2
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/AbstractImpl.java
@@ -0,0 +1,62 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.directory.fortress.rest;
+
+import org.apache.log4j.Logger;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.rest.FortResponse;
+
+/**
+ * An abstract class containing some methods shared by all the implementations.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+
+ */
+abstract class AbstractImpl
+{
+    /**
+     * Create an error message and log it.
+     * 
+     * @param response The {@link FortResponse} instance in which we will store the error message and ID
+     * @param LOG The Logger
+     * @param se The exception
+     */
+    protected void createError( FortResponse response, Logger LOG, SecurityException se )
+    {
+        LOG.info( "Caught " + se );
+        response.setErrorCode( se.getErrorId() );
+        response.setErrorMessage( se.getMessage() );
+    }
+    
+    
+    /**
+     * Creates a {@link FortResponse} instance where the error code is set with a default value.
+     * 
+     * @return The created instancd
+     */
+    protected FortResponse createResponse()
+    {
+        FortResponse response = new FortResponse();
+        response.setErrorCode( GlobalErrIds.NO_ERROR );
+
+        return response;
+    }
+}