| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.util; |
| | |
| | | } |
| | | } |
| | | |
| | | private static String getSchemaDirectoryPath(boolean userSchema) |
| | | private static String getSchemaDirectoryPath() |
| | | { |
| | | File schemaDir = |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(userSchema); |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(); |
| | | if (schemaDir != null) { |
| | | return schemaDir.getAbsolutePath(); |
| | | } else { |
| | |
| | | { |
| | | schema = getBaseSchema(); |
| | | |
| | | String[] fileNames = null; |
| | | String[] fileNames; |
| | | String schemaDirPath= getSchemaDirectoryPath(); |
| | | try |
| | | { |
| | | String installPath = |
| | | new File(DirectoryServer.getServerRoot()).getCanonicalPath(); |
| | | String instancePath = |
| | | new File(DirectoryServer.getInstanceRoot()).getCanonicalPath(); |
| | | |
| | | // Load install directory schema |
| | | String schemaDirPath= getSchemaDirectoryPath(false); |
| | | File schemaDir = new File(schemaDirPath); |
| | | if (schemaDirPath == null || ! schemaDir.exists()) |
| | | { |
| | |
| | | return accept; |
| | | } |
| | | }; |
| | | File[] schemaInstallDirFiles = schemaDir.listFiles(ldifFiles); |
| | | File[] schemaInstanceDirFiles = null ; |
| | | int size = schemaInstallDirFiles.length; |
| | | |
| | | if (! installPath.equals(instancePath)) |
| | | { |
| | | schemaDirPath= getSchemaDirectoryPath(true); |
| | | schemaDir = new File(schemaDirPath); |
| | | if (schemaDirPath != null |
| | | && |
| | | schemaDir.exists() |
| | | && |
| | | schemaDir.isDirectory()) |
| | | { |
| | | schemaInstanceDirFiles = schemaDir.listFiles(ldifFiles); |
| | | size += schemaInstanceDirFiles.length; |
| | | } |
| | | } |
| | | File[] schemaFiles = schemaDir.listFiles(ldifFiles); |
| | | int size = schemaFiles.length; |
| | | |
| | | ArrayList<String> fileList = new ArrayList<String>(size); |
| | | for (File f : schemaInstallDirFiles) |
| | | for (File f : schemaFiles) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (schemaInstanceDirFiles != null) |
| | | { |
| | | for (File f : schemaInstanceDirFiles) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | | fileList.add(f.getName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | fileNames = new String[fileList.size()]; |
| | | fileList.toArray(fileNames); |
| | | Arrays.sort(fileNames); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | t.printStackTrace(); |
| | | } |
| | | /* |
| | | catch (InitializationException ie) |
| | | { |
| | | throw ie; |
| | |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_CONFIG_SCHEMA_CANNOT_LIST_FILES.get( |
| | | schemaDirPath, getExceptionMessage(e)); |
| | | schemaDirPath, e.getMessage()); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | */ |
| | | |
| | | // Iterate through the schema files and read them as an LDIF file containing |
| | | // a single entry. Then get the attributeTypes and objectClasses attributes |