Policies_Storage_Service/src/com/fincons/policiesstorage/restlet/DBPolicyConnection.java
/**
	 * Verifies if the folder selected is an Organization
	 * 
	 * @param folderRequested
	 *            The name of the element or the ID
	 * @return true if @param folderRequested is an Organization, false
	 *         otherwise
	 */
Verifies if the folder selected is an Organization

@param folderRequested
The name of the element or the ID
@return true if @param folderRequested is an Organization, false
otherwise
Verifies if the folder selected is an Organization @param folderRequested The name of the element or the ID @return true if @param folderRequested is an Organization false otherwise
public boolean isOrganizationName(String folderRequested) {
		logger.debug("Check if the folder requested is an Organization");
		boolean found = false;
		String query = Constants.ALL_ORGANIZATION_NODES_QUERY;
		HashMap<String, Object> params = new HashMap<String, Object>();
		String root = PropertiesHelper.getProps().getProperty(Constants.ROOT_NAME);
		params.put("root", root);
		Integer con_number = dbManager.connect(pathDB, usernameDB, passwordDB);
		JSONObject organizationNodes = new JSONObject();
		try {
			organizationNodes = (JSONObject) dbManager.executeQuery(con_number, query, params);
		} catch (Exception e1) {
			dbManager.rollback(con_number);
			logger.error("Error while reading Organization Nodes", e1);
			try {
				organizationNodes.put("status", "ERROR");
				organizationNodes.put("message", e1.getMessage());
			} catch (JSONException e) {
				logger.error("JSON Exception ", e);
				e.printStackTrace();
			}
		}
		dbManager.disconnect(con_number);
		String statusQuery = organizationNodes.optString("status");
		if (statusQuery.equalsIgnoreCase("ok")) {
			try {
				JSONArray data = organizationNodes.optJSONArray("data");
				data = (data == null) ? new JSONArray() : data;
				for (int i = 0; i < data.length(); i++) {
					JSONObject temp = data.getJSONObject(i);
					String nameNode = temp.optString("name");
					if (folderRequested.equals(nameNode)) {
						found = true;
						logger.debug("Folder requested is an Organization: " + folderRequested);
						break;
					}
				}
			} catch (JSONException e) {
				logger.error("JSON Exception " + e.getMessage());
				e.printStackTrace();
			}
		}
		if (!found) {
			logger.info("Folder requested is not an Organization.");
		}
		return found;
	}
public boolean isOrganizationName ( String folderRequested ) { logger . debug ( "Check if the folder requested is an Organization" ) ; boolean found = false ; String query = Constants . ALL_ORGANIZATION_NODES_QUERY ; HashMap < String , Object > params = new HashMap < String , Object > ( ) ; String root = PropertiesHelper . getProps ( ) . getProperty ( Constants . ROOT_NAME ) ; params . put ( "root" , root ) ; Integer con_number = dbManager . connect ( pathDB , usernameDB , passwordDB ) ; JSONObject organizationNodes = new JSONObject ( ) ; try { organizationNodes = ( JSONObject ) dbManager . executeQuery ( con_number , query , params ) ; } catch ( Exception e1 ) { dbManager . rollback ( con_number ) ; logger . error ( "Error while reading Organization Nodes" , e1 ) ; try { organizationNodes . put ( "status" , "ERROR" ) ; organizationNodes . put ( "message" , e1 . getMessage ( ) ) ; } catch ( JSONException e ) { logger . error ( "JSON Exception " , e ) ; e . printStackTrace ( ) ; } } dbManager . disconnect ( con_number ) ; String statusQuery = organizationNodes . optString ( "status" ) ; if ( statusQuery . equalsIgnoreCase ( "ok" ) ) { try { JSONArray data = organizationNodes . optJSONArray ( "data" ) ; data = ( data == null ) ? new JSONArray ( ) : data ; for ( int i = 0 ; i < data . length ( ) ; i ++ ) { JSONObject temp = data . getJSONObject ( i ) ; String nameNode = temp . optString ( "name" ) ; if ( folderRequested . equals ( nameNode ) ) { found = true ; logger . debug ( "Folder requested is an Organization: " + folderRequested ) ; break ; } } } catch ( JSONException e ) { logger . error ( "JSON Exception " + e . getMessage ( ) ) ; e . printStackTrace ( ) ; } } if ( ! found ) { logger . info ( "Folder requested is not an Organization." ) ; } return found ; }
Verifies if the folder selected is an Organization
Verifies if the folder selected is an Organization