repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/ProjectsHandlerAdapter.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/ProjectsHandlerAdapter.java
/* * 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.studio.schemaeditor.controller; import org.apache.directory.studio.schemaeditor.model.Project; /** * This adapter class provides default implementations for the methods * described by the ProjectsHandlerListener interface. * <p> * Classes that wish to deal with Project events can extend this class * and override only the methods which they are interested in. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ProjectsHandlerAdapter implements ProjectsHandlerListener { /** * {@inheritDoc} */ public void projectAdded( Project project ) { } /** * {@inheritDoc} */ public void projectRemoved( Project project ) { } /** * {@inheritDoc} */ public void openProjectChanged( Project oldProject, Project newProject ) { } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.PluginUtils; import org.apache.directory.studio.schemaeditor.view.ViewUtils; import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditor; import org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditor; import org.apache.directory.studio.schemaeditor.view.views.HierarchyView; import org.apache.directory.studio.schemaeditor.view.views.SchemaView; import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; /** * This action opens the selected element in the Viewer in the Hierarchy View. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenTypeHierarchyAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of DeleteSchemaElementAction. */ public OpenTypeHierarchyAction( TreeViewer viewer ) { super( Messages.getString( "OpenTypeHierarchyAction.OpenTypeAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenTypeHierarchyAction.OpenTypeToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_OPEN_TYPE_HIERARCHY ); setActionDefinitionId( PluginConstants.CMD_OPEN_TYPE_HIERARCHY ); setEnabled( false ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { StructuredSelection selection = ( StructuredSelection ) event.getSelection(); setEnabled( ( selection.size() == 1 ) && ( ( selection.getFirstElement() instanceof AttributeTypeWrapper ) || ( selection.getFirstElement() instanceof ObjectClassWrapper ) ) ); } } ); } /** * {@inheritDoc} */ public void run() { IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); if ( part instanceof SchemaView ) { openTypeHierarchyFromTreeViewer( ( ( SchemaView ) part ).getViewer() ); } else if ( part instanceof HierarchyView ) { openTypeHierarchyFromTreeViewer( ( ( HierarchyView ) part ).getViewer() ); } else if ( part instanceof AttributeTypeEditor ) { openTypeHierarchy( ( ( AttributeTypeEditor ) part ).getOriginalAttributeType() ); } else if ( part instanceof ObjectClassEditor ) { openTypeHierarchy( ( ( ObjectClassEditor ) part ).getOriginalObjectClass() ); } } /** * Gets the selection of the TreeViewer and opens the selection in the Hierarchy View. * * @param treeViewer * the Tree Viewer */ private void openTypeHierarchyFromTreeViewer( TreeViewer treeViewer ) { Object firstElement = ( ( StructuredSelection ) treeViewer.getSelection() ).getFirstElement(); if ( firstElement instanceof ObjectClassWrapper ) { ObjectClassWrapper ocw = ( ObjectClassWrapper ) firstElement; openTypeHierarchy( ocw.getObjectClass() ); } else if ( firstElement instanceof AttributeTypeWrapper ) { AttributeTypeWrapper atw = ( AttributeTypeWrapper ) firstElement; openTypeHierarchy( atw.getAttributeType() ); } } /** * Opens the Type Hierarchy with the given element. * * @param element * the element to open */ private void openTypeHierarchy( SchemaObject element ) { HierarchyView view = ( HierarchyView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .findView( HierarchyView.ID ); if ( view == null ) { try { view = ( HierarchyView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( HierarchyView.ID ); } catch ( PartInitException e ) { PluginUtils.logError( Messages.getString( "OpenTypeHierarchyAction.ErrorOpeningView" ), e ); //$NON-NLS-1$ ViewUtils .displayErrorMessageDialog( Messages.getString( "OpenTypeHierarchyAction.Error" ), Messages.getString( "OpenTypeHierarchyAction.ErrorOpeningView" ) ); //$NON-NLS-1$ //$NON-NLS-2$ } } if ( view != null ) { view.setInput( element ); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( view ); } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/RunCurrentSearchAgainAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/RunCurrentSearchAgainAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.views.SearchView; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action is used to run the current search again. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class RunCurrentSearchAgainAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated view */ private SearchView view; /** * Creates a new instance of ShowSearchFieldAction. */ public RunCurrentSearchAgainAction( SearchView view ) { super( Messages.getString( "RunCurrentSearchAgainAction.RerunSearchAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_RUN_CURRENT_SEARCH_AGAIN ) ); setEnabled( true ); this.view = view; } /** * {@inheritDoc} */ public void run() { view.runCurrentSearchAgain(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSchemaViewPreferenceAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSchemaViewPreferenceAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.view.preferences.SchemaViewPreferencePage; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This action opens the Preference Page for the SchemaView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenSchemaViewPreferenceAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of OpenSchemaViewPreferenceAction. */ public OpenSchemaViewPreferenceAction() { super( Messages.getString( "OpenSchemaViewPreferenceAction.PreferencesAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenSchemaViewPreferenceAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( false ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); PreferencesUtil.createPreferenceDialogOn( shell, SchemaViewPreferencePage.ID, new String[] { SchemaViewPreferencePage.ID }, null ).open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportSchemasForADSAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportSchemasForADSAction.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.view.wizards.ExportSchemasForADSWizard; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the ExportSchemasAsXmlWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportSchemasForADSAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of ExportSchemasAsXmlAction. */ public ExportSchemasForADSAction( TreeViewer viewer ) { super( Messages.getString( "ExportSchemasForADSAction.SchemaForADSAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMAS_EXPORT_FOR_ADS ) ); setEnabled( true ); this.viewer = viewer; } /** * {@inheritDoc} */ public void run() { List<Schema> selectedSchemas = new ArrayList<Schema>(); // Getting the selection StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() > 0 ) ) { for ( Iterator<?> i = selection.iterator(); i.hasNext(); ) { Object o = i.next(); if ( o instanceof SchemaWrapper ) { selectedSchemas.add( ( ( SchemaWrapper ) o ).getSchema() ); } } } // Instantiates and initializes the wizard ExportSchemasForADSWizard wizard = new ExportSchemasForADSWizard(); wizard.setSelectedSchemas( selectedSchemas.toArray( new Schema[0] ) ); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportSchemasFromOpenLdapAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportSchemasFromOpenLdapAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.ImportSchemasFromOpenLdapWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the ImportSchemasFromOpenLdapWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportSchemasFromOpenLdapAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of ImportSchemasFromOpenLdapAction. */ public ImportSchemasFromOpenLdapAction() { super( Messages.getString( "ImportSchemasFromOpenLdapAction.SchemaFromOpenLDAPFilesAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMAS_IMPORT ) ); setEnabled( true ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard ImportSchemasFromOpenLdapWizard wizard = new ImportSchemasFromOpenLdapWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSearchViewSortingDialogAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSearchViewSortingDialogAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.views.SearchViewSortingDialog; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action opens the Sorting Dialog for the SearchView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenSearchViewSortingDialogAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of OpenSearchViewSortingDialogAction. */ public OpenSearchViewSortingDialogAction() { super( Messages.getString( "OpenSearchViewSortingDialogAction.SortingAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenSearchViewSortingDialogAction.SortingToolTip" ) ); //$NON-NLS-1$ setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SORTING ) ); setEnabled( true ); } /** * {@inheritDoc} */ public void run() { SearchViewSortingDialog svsd = new SearchViewSortingDialog( PlatformUI.getWorkbench().getDisplay() .getActiveShell() ); svsd.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/RenameProjectAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/RenameProjectAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.view.dialogs.RenameProjectDialog; import org.apache.directory.studio.schemaeditor.view.wrappers.ProjectWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action launches the NewProjectWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class RenameProjectAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TableViewer viewer; /** The ProjectsHandler */ private ProjectsHandler projectsHandler; /** * Creates a new instance of RenameProjectAction. * * @param view * the associate view */ public RenameProjectAction( TableViewer viewer ) { super( Messages.getString( "RenameProjectAction.RenameProjectAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setId( PluginConstants.CMD_RENAME_PROJECT ); setActionDefinitionId( PluginConstants.CMD_RENAME_PROJECT ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_RENAME ) ); setEnabled( false ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { StructuredSelection selection = ( StructuredSelection ) event.getSelection(); setEnabled( selection.size() == 1 ); } } ); projectsHandler = Activator.getDefault().getProjectsHandler(); } /** * {@inheritDoc} */ public void run() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { Project project = ( ( ProjectWrapper ) selection.getFirstElement() ).getProject(); RenameProjectDialog dialog = new RenameProjectDialog( project.getName() ); if ( dialog.open() == Dialog.OK ) { projectsHandler.renameProject( project, dialog.getNewName() ); } } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportSchemasAsXmlAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportSchemasAsXmlAction.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.view.wizards.ExportSchemasAsXmlWizard; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the ExportSchemasAsXmlWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportSchemasAsXmlAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of ExportSchemasAsXmlAction. */ public ExportSchemasAsXmlAction( TreeViewer viewer ) { super( Messages.getString( "ExportSchemasAsXmlAction.SchemaAsXMLFileAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMAS_EXPORT ) ); setEnabled( true ); this.viewer = viewer; } /** * {@inheritDoc} */ public void run() { List<Schema> selectedSchemas = new ArrayList<Schema>(); // Getting the selection StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() > 0 ) ) { for ( Iterator<?> i = selection.iterator(); i.hasNext(); ) { Object o = i.next(); if ( o instanceof SchemaWrapper ) { selectedSchemas.add( ( ( SchemaWrapper ) o ).getSchema() ); } } } // Instantiates and initializes the wizard ExportSchemasAsXmlWizard wizard = new ExportSchemasAsXmlWizard(); wizard.setSelectedSchemas( selectedSchemas.toArray( new Schema[0] ) ); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/LinkWithEditorHierarchyViewAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/LinkWithEditorHierarchyViewAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditor; import org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditor; import org.apache.directory.studio.schemaeditor.view.views.HierarchyView; import org.eclipse.jface.action.Action; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.PlatformUI; /** * This class implements the Link With Editor Action for the Hierarchy View * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LinkWithEditorHierarchyViewAction extends Action { /** The String for storing the checked state of the action */ private static final String LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY = LinkWithEditorHierarchyViewAction.class .getName() + ".dialogsettingkey"; //$NON-NLS-1$ /** The associated view */ private HierarchyView view; /** The listener listening on changes on editors */ private IPartListener2 editorListener = new IPartListener2() { /** * {@inheritDoc} */ public void partVisible( IWorkbenchPartReference partRef ) { IWorkbenchPart part = partRef.getPart( true ); if ( part instanceof ObjectClassEditor ) { linkViewWithEditor( ( ( ObjectClassEditor ) part ).getOriginalObjectClass() ); } else if ( part instanceof AttributeTypeEditor ) { linkViewWithEditor( ( ( AttributeTypeEditor ) part ).getOriginalAttributeType() ); } } /** * {@inheritDoc} */ public void partActivated( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partClosed( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partDeactivated( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partHidden( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partInputChanged( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partOpened( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partBroughtToTop( IWorkbenchPartReference partRef ) { } }; /** * Creates a new instance of LinkWithEditorSchemasView. * * @param view * the associated view */ public LinkWithEditorHierarchyViewAction( HierarchyView view ) { super( Messages.getString( "LinkWithEditorHierarchyViewAction.LinkEditorAction" ), AS_CHECK_BOX ); //$NON-NLS-1$ setToolTipText( Messages.getString( "LinkWithEditorHierarchyViewAction.LinkEditorToolTip" ) ); //$NON-NLS-1$ setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_LINK_WITH_EDITOR ) ); setEnabled( true ); this.view = view; // Setting up the default key value (if needed) if ( Activator.getDefault().getDialogSettings().get( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY ) == null ) { Activator.getDefault().getDialogSettings().put( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY, false ); } // Setting state from the dialog settings setChecked( Activator.getDefault().getDialogSettings().getBoolean( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY ) ); // Enabling the listeners if ( isChecked() ) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener ); } } /** * {@inheritDoc} */ public void run() { setChecked( isChecked() ); Activator.getDefault().getDialogSettings().put( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY, isChecked() ); if ( isChecked() ) // Enabling the listeners { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener ); IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); if ( activeEditor instanceof ObjectClassEditor ) { linkViewWithEditor( ( ( ObjectClassEditor ) activeEditor ).getOriginalObjectClass() ); } else if ( activeEditor instanceof AttributeTypeEditor ) { linkViewWithEditor( ( ( AttributeTypeEditor ) activeEditor ).getOriginalAttributeType() ); } } else // Disabling the listeners { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener( editorListener ); } } /** * Links the view with the right editor * * @param schemaElement * the Schema Element */ private void linkViewWithEditor( SchemaObject schemaElement ) { if ( schemaElement instanceof AttributeType ) { view.setInput( schemaElement ); } else if ( schemaElement instanceof ObjectClass ) { view.setInput( schemaElement ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportCoreSchemasAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportCoreSchemasAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.ImportCoreSchemasWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the {@link ImportCoreSchemasWizard}. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportCoreSchemasAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of ImportCoreSchemasAction. */ public ImportCoreSchemasAction() { super( Messages.getString( "ImportCoreSchemasAction.CoreSchemaFilesAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMAS_IMPORT ) ); setEnabled( true ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard ImportCoreSchemasWizard wizard = new ImportCoreSchemasWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/RenameSchemaElementAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/RenameSchemaElementAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.PluginUtils; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.view.dialogs.RenameAttributeTypeDialog; import org.apache.directory.studio.schemaeditor.view.dialogs.RenameObjectClassDialog; import org.apache.directory.studio.schemaeditor.view.dialogs.RenameSchemaDialog; import org.apache.directory.studio.schemaeditor.view.editors.EditorsUtils; import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action launches a rename dialog for schema elements (schema, attribute type and object class). * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class RenameSchemaElementAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of RenameProjectAction. * * @param viewer * the associated viewer */ public RenameSchemaElementAction( TreeViewer viewer ) { super( Messages.getString( "RenameSchemaElementAction.RenameSchemaElementAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setId( PluginConstants.CMD_RENAME_SCHEMA_ELEMENT ); setActionDefinitionId( PluginConstants.CMD_RENAME_SCHEMA_ELEMENT ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_RENAME ) ); setEnabled( false ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { StructuredSelection selection = ( StructuredSelection ) event.getSelection(); setEnabled( ( selection.size() == 1 ) && ( ( selection.getFirstElement() instanceof SchemaWrapper ) || ( selection.getFirstElement() instanceof AttributeTypeWrapper ) || ( selection.getFirstElement() instanceof ObjectClassWrapper ) ) ); } } ); } /** * {@inheritDoc} */ public void run() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { Object selectedElement = selection.getFirstElement(); // Saving all dirty editors before processing the renaming if ( EditorsUtils.saveAllDirtyEditors() ) { // SCHEMA if ( selectedElement instanceof SchemaWrapper ) { Schema schema = ( ( SchemaWrapper ) selectedElement ).getSchema(); RenameSchemaDialog dialog = new RenameSchemaDialog( schema.getSchemaName() ); if ( dialog.open() == RenameSchemaDialog.OK ) { Activator.getDefault().getSchemaHandler().renameSchema( schema, dialog.getNewName() ); } } // ATTRIBUTE TYPE else if ( selectedElement instanceof AttributeTypeWrapper ) { AttributeType attributeType = ( ( AttributeTypeWrapper ) selectedElement ).getAttributeType(); RenameAttributeTypeDialog dialog = new RenameAttributeTypeDialog( attributeType.getNames() ); if ( dialog.open() == RenameAttributeTypeDialog.OK ) { AttributeType modifiedAttributeType = PluginUtils.getClone( attributeType ); modifiedAttributeType.setNames( dialog.getAliases() ); Activator.getDefault().getSchemaHandler() .modifyAttributeType( attributeType, modifiedAttributeType ); } } // OBJECT CLASS else if ( selectedElement instanceof ObjectClassWrapper ) { ObjectClass objectClass = ( ( ObjectClassWrapper ) selectedElement ).getObjectClass(); RenameObjectClassDialog dialog = new RenameObjectClassDialog( objectClass.getNames() ); if ( dialog.open() == RenameObjectClassDialog.OK ) { ObjectClass modifiedObjectClass = PluginUtils.getClone( objectClass ); modifiedObjectClass.setNames( dialog.getAliases() ); Activator.getDefault().getSchemaHandler() .modifyObjectClass( objectClass, modifiedObjectClass ); } } } } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewAttributeTypeAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewAttributeTypeAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.view.wizards.NewAttributeTypeWizard; import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.Folder; import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.TreeNode; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the NewAttributeTypeWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewAttributeTypeAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of NewAttributeTypeAction. */ public NewAttributeTypeAction( TreeViewer viewer ) { super( Messages.getString( "NewAttributeTypeAction.NewAttributeTypeAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "NewAttributeTypeAction.NewAttributeTypeToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_NEW_ATTRIBUTE_TYPE ); setActionDefinitionId( PluginConstants.CMD_NEW_ATTRIBUTE_TYPE ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_ATTRIBUTE_TYPE_NEW ) ); setEnabled( false ); this.viewer = viewer; } /** * {@inheritDoc} */ public void run() { // Getting the selection Schema selectedSchema = null; int presentation = Activator.getDefault().getPreferenceStore().getInt( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION ); if ( presentation == PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT ) { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { Object firstElement = selection.getFirstElement(); if ( firstElement instanceof SchemaWrapper ) { selectedSchema = ( ( SchemaWrapper ) firstElement ).getSchema(); } else if ( firstElement instanceof Folder ) { selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) firstElement ).getParent() ).getSchema(); } else if ( firstElement instanceof AttributeTypeWrapper ) { TreeNode parent = ( ( AttributeTypeWrapper ) firstElement ).getParent(); if ( parent instanceof Folder ) { selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) parent ).getParent() ).getSchema(); } else if ( parent instanceof SchemaWrapper ) { selectedSchema = ( ( SchemaWrapper ) parent ).getSchema(); } } else if ( firstElement instanceof ObjectClassWrapper ) { TreeNode parent = ( ( ObjectClassWrapper ) firstElement ).getParent(); if ( parent instanceof Folder ) { selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) parent ).getParent() ).getSchema(); } else if ( parent instanceof SchemaWrapper ) { selectedSchema = ( ( SchemaWrapper ) parent ).getSchema(); } } } } // Instantiates and initializes the wizard NewAttributeTypeWizard wizard = new NewAttributeTypeWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); wizard.setSelectedSchema( selectedSchema ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/MergeSchemasAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/MergeSchemasAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.MergeSchemasWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the {@link MergeSchemasWizard}. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MergeSchemasAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of MergeSchemasAction. */ public MergeSchemasAction() { super( Messages.getString( "MergeSchemasAction.MergeSchemas" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMAS_IMPORT ) ); setEnabled( true ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard MergeSchemasWizard wizard = new MergeSchemasWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSupertypeHierarchyAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSupertypeHierarchyAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.views.HierarchyView; import org.eclipse.jface.action.Action; /** * This class implements the Show Supertype Hierachy Action for the Hierarchy View. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowSupertypeHierarchyAction extends Action { /** The associated view */ private HierarchyView view; /** * Creates a new instance of ShowSubtypeHierarchyAction. */ public ShowSupertypeHierarchyAction( HierarchyView view ) { super( Messages.getString( "ShowSupertypeHierarchyAction.SupertypeAction" ), AS_RADIO_BUTTON ); //$NON-NLS-1$ setToolTipText( Messages.getString( "ShowSupertypeHierarchyAction.SupertypeToolTip" ) ); //$NON-NLS-1$ setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SHOW_SUPERTYPE_HIERARCHY ) ); setEnabled( true ); this.view = view; // Setting state from the dialog settings setChecked( Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE ) == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE ); } /** * {@inheritDoc} */ public void run() { Activator.getDefault().getDialogSettings().put( PluginConstants.PREFS_HIERARCHY_VIEW_MODE, PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE ); view.refresh(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportSchemasFromXmlAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportSchemasFromXmlAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.ImportSchemasFromXmlWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the ImportSchemasFromXmlWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportSchemasFromXmlAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of ImportSchemasFromXmlAction. */ public ImportSchemasFromXmlAction() { super( Messages.getString( "ImportSchemasFromXmlAction.SchemasFromXMLFilesAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMAS_IMPORT ) ); setEnabled( true ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard ImportSchemasFromXmlWizard wizard = new ImportSchemasFromXmlWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSearchViewPreferenceAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSearchViewPreferenceAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.view.preferences.SearchViewPreferencePage; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This action opens the Preference Page for the SearchView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenSearchViewPreferenceAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of OpenSearchViewPreferenceAction. */ public OpenSearchViewPreferenceAction() { super( Messages.getString( "OpenSearchViewPreferenceAction.PreferencesAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenSearchViewPreferenceAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); PreferencesUtil.createPreferenceDialogOn( shell, SearchViewPreferencePage.ID, new String[] { SearchViewPreferencePage.ID }, null ).open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CommitChangesAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CommitChangesAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.CommitChangesWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the NewProjectWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CommitChangesAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of NewProjectAction. */ public CommitChangesAction() { super( Messages.getString( "CommitChangesAction.CommitChangesAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_COMMIT_CHANGES ) ); setEnabled( false ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard CommitChangesWizard wizard = new CommitChangesWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowTypeHierarchyAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowTypeHierarchyAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.views.HierarchyView; import org.eclipse.jface.action.Action; /** * This class implements the Show Type Hierachy Action for the Hierarchy View. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowTypeHierarchyAction extends Action { /** The associated view */ private HierarchyView view; /** * Creates a new instance of ShowSubtypeHierarchyAction. */ public ShowTypeHierarchyAction( HierarchyView view ) { super( Messages.getString( "ShowTypeHierarchyAction.TypeAction" ), AS_RADIO_BUTTON ); //$NON-NLS-1$ setToolTipText( Messages.getString( "ShowTypeHierarchyAction.TypeToolTip" ) ); //$NON-NLS-1$ setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SHOW_TYPE_HIERARCHY ) ); setEnabled( true ); this.view = view; // Setting state from the dialog settings setChecked( Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE ) == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_TYPE ); } /** * {@inheritDoc} */ public void run() { Activator.getDefault().getDialogSettings().put( PluginConstants.PREFS_HIERARCHY_VIEW_MODE, PluginConstants.PREFS_HIERARCHY_VIEW_MODE_TYPE ); view.refresh(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CloseProjectAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CloseProjectAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler; import org.apache.directory.studio.schemaeditor.controller.ProjectsHandlerAdapter; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.model.Project.ProjectState; import org.apache.directory.studio.schemaeditor.view.wrappers.ProjectWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action opens a Project. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CloseProjectAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TableViewer viewer; /** The ProjectsHandler */ private ProjectsHandler projectsHandler; /** * Creates a new instance of RenameProjectAction. * * @param view * the associate view */ public CloseProjectAction( TableViewer viewer ) { super( Messages.getString( "CloseProjectAction.CloseProjectAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "CloseProjectAction.CloseProjectToolTip" ) ); //$NON-NLS-1$ setEnabled( false ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { enableDisable(); } } ); projectsHandler = Activator.getDefault().getProjectsHandler(); projectsHandler.addListener( new ProjectsHandlerAdapter() { public void openProjectChanged( Project oldProject, Project newProject ) { enableDisable(); } } ); } /** * Enables or disables the Action. */ private void enableDisable() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { setEnabled( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject().getState().equals( ProjectState.OPEN ) ); } else { setEnabled( false ); } } /** * {@inheritDoc} */ public void run() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { projectsHandler.closeProject( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject() ); } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportProjectsAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportProjectsAction.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.view.wizards.ExportProjectsWizard; import org.apache.directory.studio.schemaeditor.view.wrappers.ProjectWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the ExportProjectsWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportProjectsAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TableViewer viewer; /** * Creates a new instance of NewProjectAction. */ public ExportProjectsAction( TableViewer viewer ) { super( Messages.getString( "ExportProjectsAction.SchemaProjectsAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_PROJECT_EXPORT ) ); setEnabled( true ); this.viewer = viewer; } /** * {@inheritDoc} */ public void run() { List<Project> selectedProjects = new ArrayList<Project>(); // Getting the selection StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() > 0 ) ) { for ( Iterator<?> i = selection.iterator(); i.hasNext(); ) { selectedProjects.add( ( ( ProjectWrapper ) i.next() ).getProject() ); } } // Instantiates and initializes the wizard ExportProjectsWizard wizard = new ExportProjectsWizard(); wizard.setSelectedProjects( selectedProjects.toArray( new Project[0] ) ); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/Messages.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/Messages.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteProjectAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteProjectAction.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.Iterator; import org.apache.directory.studio.connection.core.ConnectionCoreConstants; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.model.Project.ProjectState; import org.apache.directory.studio.schemaeditor.view.wrappers.ProjectWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action deletes one or more Projects from the ProjectsView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DeleteProjectAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TableViewer viewer; /** * Creates a new instance of DeleteProjectAction. * * @param view * the associated view */ public DeleteProjectAction( TableViewer viewer ) { super( Messages.getString( "DeleteProjectAction.DeleteProjectAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "DeleteProjectAction.DeleteProjectToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_DELETE_PROJECT ); setActionDefinitionId( PluginConstants.CMD_DELETE_PROJECT ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_DELETE ) ); setEnabled( false ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { StructuredSelection selection = ( StructuredSelection ) event.getSelection(); if ( selection.size() == 1 ) { setText( Messages.getString( "DeleteProjectAction.DeleteProjectAction" ) ); //$NON-NLS-1$ setEnabled( true ); } else if ( selection.size() > 1 ) { setText( Messages.getString( "DeleteProjectAction.DeleteProjectsAction" ) ); //$NON-NLS-1$ setEnabled( true ); } else { setText( Messages.getString( "DeleteProjectAction.DeleteProjectAction" ) ); //$NON-NLS-1$ setEnabled( false ); } } } ); } /** * {@inheritDoc} */ public void run() { ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler(); StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( !selection.isEmpty() ) { StringBuilder title = new StringBuilder(); StringBuilder message = new StringBuilder(); int count = selection.size(); if ( count <= 5 ) { if ( count == 1 ) { // Only 1 project to delete title.append( Messages.getString( "DeleteProjectAction.DeleteProjectTitle" ) ); //$NON-NLS-1$ message.append( Messages.getString( "DeleteProjectAction.SureDeleteFollowingProject" ) ); //$NON-NLS-1$ } else { // Between 2 to 5 projects to delete title.append( Messages.getString( "DeleteProjectAction.DeleteProjectsTitle" ) ); //$NON-NLS-1$ message.append( Messages.getString( "DeleteProjectAction.SureDeleteFollowingProjects" ) ); //$NON-NLS-1$ } // Appending the projects names for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) { message.append( ConnectionCoreConstants.LINE_SEPARATOR ); message.append( " - " ); //$NON-NLS-1$ message.append( ( ( ProjectWrapper ) iterator.next() ).getProject().getName() ); } } else { // More than 5 projects to delete title.append( Messages.getString( "DeleteProjectAction.DeleteProjectsTitle" ) ); //$NON-NLS-1$ message.append( Messages.getString( "DeleteProjectAction.SureDeleteSelectedProjects" ) ); //$NON-NLS-1$ } // Showing the confirmation window if ( MessageDialog.openConfirm( viewer.getControl().getShell(), title.toString(), message.toString() ) ) { for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) { ProjectWrapper wrapper = ( ProjectWrapper ) iterator.next(); Project project = wrapper.getProject(); if ( project.getState() == ProjectState.OPEN ) { // Closing the project before removing it. projectsHandler.closeProject( project ); } projectsHandler.removeProject( project ); } } } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenElementAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenElementAction.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.Iterator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.PluginUtils; import org.apache.directory.studio.schemaeditor.view.ViewUtils; import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditor; import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditorInput; import org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditor; import org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditorInput; import org.apache.directory.studio.schemaeditor.view.editors.schema.SchemaEditor; import org.apache.directory.studio.schemaeditor.view.editors.schema.SchemaEditorInput; import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.Folder; import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; /** * This action opens the selected element in the SchemaView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenElementAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of DeleteSchemaElementAction. */ public OpenElementAction( TreeViewer viewer ) { super( Messages.getString( "OpenElementAction.OpenAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenElementAction.OpenToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_OPEN_ELEMENT ); setActionDefinitionId( PluginConstants.CMD_OPEN_ELEMENT ); setEnabled( false ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { StructuredSelection selection = ( StructuredSelection ) event.getSelection(); if ( selection.size() > 0 ) { boolean enabled = true; for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) { Object selectedItem = iterator.next(); if ( !( selectedItem instanceof SchemaWrapper ) && !( selectedItem instanceof AttributeTypeWrapper ) && !( selectedItem instanceof ObjectClassWrapper ) ) { enabled = false; break; } } setEnabled( enabled ); } else { setEnabled( false ); } } } ); } /** * {@inheritDoc} */ public void run() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) { Object selectedItem = iterator.next(); if ( selectedItem instanceof AttributeTypeWrapper ) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor( new AttributeTypeEditorInput( ( ( AttributeTypeWrapper ) selectedItem ).getAttributeType() ), AttributeTypeEditor.ID ); } catch ( PartInitException e ) { PluginUtils.logError( Messages.getString( "OpenElementAction.ErrorOpeningEditor" ), e ); //$NON-NLS-1$ ViewUtils .displayErrorMessageDialog( Messages.getString( "OpenElementAction.Error" ), Messages.getString( "OpenElementAction.ErrorOpeningEditor" ) ); //$NON-NLS-1$ //$NON-NLS-2$ } } else if ( selectedItem instanceof ObjectClassWrapper ) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor( new ObjectClassEditorInput( ( ( ObjectClassWrapper ) selectedItem ).getObjectClass() ), ObjectClassEditor.ID ); } catch ( PartInitException e ) { PluginUtils.logError( Messages.getString( "OpenElementAction.ErrorOpeningEditor" ), e ); //$NON-NLS-1$ ViewUtils .displayErrorMessageDialog( Messages.getString( "OpenElementAction.Error" ), Messages.getString( "OpenElementAction.ErrorOpeningEditor" ) ); //$NON-NLS-1$ //$NON-NLS-2$ } } else if ( selectedItem instanceof SchemaWrapper ) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor( new SchemaEditorInput( ( ( SchemaWrapper ) selectedItem ).getSchema() ), SchemaEditor.ID ); } catch ( PartInitException e ) { PluginUtils.logError( Messages.getString( "OpenElementAction.ErrorOpeningEditor" ), e ); //$NON-NLS-1$ ViewUtils .displayErrorMessageDialog( Messages.getString( "OpenElementAction.Error" ), Messages.getString( "OpenElementAction.ErrorOpeningEditor" ) ); //$NON-NLS-1$ //$NON-NLS-2$ } } else if ( selectedItem instanceof Folder ) { viewer.setExpandedState( selectedItem, true ); } } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSearchFieldAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSearchFieldAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.views.SearchView; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action is used to show/hide the search field in the SearchView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowSearchFieldAction extends Action implements IWorkbenchWindowActionDelegate { /** The String for storing the checked state of the action */ private static final String SHOW_SEARCH_FIELD_DS_KEY = ShowSearchFieldAction.class.getName() + ".dialogsettingkey"; //$NON-NLS-1$ /** The associated view */ private SearchView view; /** * Creates a new instance of ShowSearchFieldAction. */ public ShowSearchFieldAction( SearchView view ) { super( Messages.getString( "ShowSearchFieldAction.ShowSearchFieldAction" ), AS_CHECK_BOX ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SHOW_SEARCH_FIELD ) ); setEnabled( true ); this.view = view; // Setting up the default key value (if needed) if ( Activator.getDefault().getDialogSettings().get( SHOW_SEARCH_FIELD_DS_KEY ) == null ) { Activator.getDefault().getDialogSettings().put( SHOW_SEARCH_FIELD_DS_KEY, false ); } // Setting state from the dialog settings setChecked( Activator.getDefault().getDialogSettings().getBoolean( SHOW_SEARCH_FIELD_DS_KEY ) ); if ( isChecked() ) { view.showSearchFieldSection(); } else { view.hideSearchFieldSection(); } } /** * {@inheritDoc} */ public void run() { setChecked( isChecked() ); Activator.getDefault().getDialogSettings().put( SHOW_SEARCH_FIELD_DS_KEY, isChecked() ); if ( isChecked() ) { view.showSearchFieldSection(); } else { view.hideSearchFieldSection(); } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportProjectsAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportProjectsAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.ImportProjectsWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the ImportProjectsWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportProjectsAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of ImportProjectsAction. */ public ImportProjectsAction() { super( Messages.getString( "ImportProjectsAction.SchemaProjectsAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_PROJECT_IMPORT ) ); setEnabled( true ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard ImportProjectsWizard wizard = new ImportProjectsWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSubtypeHierarchyAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSubtypeHierarchyAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.views.HierarchyView; import org.eclipse.jface.action.Action; /** * This class implements the Show Subtype Hierachy Action for the Hierarchy View. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowSubtypeHierarchyAction extends Action { /** The associated view */ private HierarchyView view; /** * Creates a new instance of ShowSubtypeHierarchyAction. */ public ShowSubtypeHierarchyAction( HierarchyView view ) { super( Messages.getString( "ShowSubtypeHierarchyAction.SubtypeAction" ), AS_RADIO_BUTTON ); //$NON-NLS-1$ setToolTipText( Messages.getString( "ShowSubtypeHierarchyAction.SubtypeToolTip" ) ); //$NON-NLS-1$ setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SHOW_SUBTYPE_HIERARCHY ) ); setEnabled( true ); this.view = view; // Setting state from the dialog settings setChecked( Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE ) == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE ); } /** * {@inheritDoc} */ public void run() { Activator.getDefault().getDialogSettings().put( PluginConstants.PREFS_HIERARCHY_VIEW_MODE, PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE ); view.refresh(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/SwitchSchemaPresentationToHierarchicalAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/SwitchSchemaPresentationToHierarchicalAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action launches the SwitchSchemaPresentationToHierarchicalAction. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SwitchSchemaPresentationToHierarchicalAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of SwitchSchemaPresentationToHierarchicalAction. */ public SwitchSchemaPresentationToHierarchicalAction() { super( Messages.getString( "SwitchSchemaPresentationToHierarchicalAction.HierarchicalAction" ), AS_RADIO_BUTTON ); //$NON-NLS-1$ setToolTipText( Messages.getString( "SwitchSchemaPresentationToHierarchicalAction.HierarchicalToolTip" ) ); //$NON-NLS-1$ setEnabled( false ); // Setting up the state of the action if ( Activator.getDefault().getPreferenceStore().getInt( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION ) == PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_HIERARCHICAL ) { setChecked( true ); } } /** * {@inheritDoc} */ public void run() { Activator.getDefault().getPreferenceStore().setValue( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION, PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_HIERARCHICAL ); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewObjectClassAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewObjectClassAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.view.wizards.NewObjectClassWizard; import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.Folder; import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.TreeNode; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the NewObjectClassWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewObjectClassAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of NewObjectClassAction. */ public NewObjectClassAction( TreeViewer viewer ) { super( Messages.getString( "NewObjectClassAction.NewObjectClassAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "NewObjectClassAction.NewObjectClassToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_NEW_OBJECT_CLASS ); setActionDefinitionId( PluginConstants.CMD_NEW_OBJECT_CLASS ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OBJECT_CLASS_NEW ) ); setEnabled( false ); this.viewer = viewer; } /** * {@inheritDoc} */ public void run() { // Getting the selection Schema selectedSchema = null; int presentation = Activator.getDefault().getPreferenceStore().getInt( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION ); if ( presentation == PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT ) { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { Object firstElement = selection.getFirstElement(); if ( firstElement instanceof SchemaWrapper ) { selectedSchema = ( ( SchemaWrapper ) firstElement ).getSchema(); } else if ( firstElement instanceof Folder ) { selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) firstElement ).getParent() ).getSchema(); } else if ( firstElement instanceof AttributeTypeWrapper ) { TreeNode parent = ( ( AttributeTypeWrapper ) firstElement ).getParent(); if ( parent instanceof Folder ) { selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) parent ).getParent() ).getSchema(); } else if ( parent instanceof SchemaWrapper ) { selectedSchema = ( ( SchemaWrapper ) parent ).getSchema(); } } else if ( firstElement instanceof ObjectClassWrapper ) { TreeNode parent = ( ( ObjectClassWrapper ) firstElement ).getParent(); if ( parent instanceof Folder ) { selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) parent ).getParent() ).getSchema(); } else if ( parent instanceof SchemaWrapper ) { selectedSchema = ( ( SchemaWrapper ) parent ).getSchema(); } } } } // Instantiates and initializes the wizard NewObjectClassWizard wizard = new NewObjectClassWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); wizard.setSelectedSchema( selectedSchema ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSchemaViewSortingDialogAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenSchemaViewSortingDialogAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.views.SchemaViewSortingDialog; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action opens the Sorting Dialog for the SchemaView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenSchemaViewSortingDialogAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of OpenSchemaViewPreferenceAction. */ public OpenSchemaViewSortingDialogAction() { super( Messages.getString( "OpenSchemaViewSortingDialogAction.SortingAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenSchemaViewSortingDialogAction.SortingToolTip" ) ); //$NON-NLS-1$ setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SORTING ) ); setEnabled( false ); } /** * {@inheritDoc} */ public void run() { SchemaViewSortingDialog svsd = new SchemaViewSortingDialog( PlatformUI.getWorkbench().getDisplay() .getActiveShell() ); svsd.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportSchemasAsOpenLdapAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ExportSchemasAsOpenLdapAction.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.view.wizards.ExportSchemasAsOpenLdapWizard; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the ExportSchemasAsOpenLdapWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportSchemasAsOpenLdapAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of ExportSchemasAsOpenLdapAction. */ public ExportSchemasAsOpenLdapAction( TreeViewer viewer ) { super( Messages.getString( "ExportSchemasAsOpenLdapAction.SchemaAsOpenLDAPFilesAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMAS_EXPORT ) ); setEnabled( true ); this.viewer = viewer; } /** * {@inheritDoc} */ public void run() { List<Schema> selectedSchemas = new ArrayList<Schema>(); // Getting the selection StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() > 0 ) ) { for ( Iterator<?> i = selection.iterator(); i.hasNext(); ) { Object o = i.next(); if ( o instanceof SchemaWrapper ) { selectedSchemas.add( ( ( SchemaWrapper ) o ).getSchema() ); } } } // Instantiates and initializes the wizard ExportSchemasAsOpenLdapWizard wizard = new ExportSchemasAsOpenLdapWizard(); wizard.setSelectedSchemas( selectedSchemas.toArray( new Schema[0] ) ); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSearchHistoryAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowSearchHistoryAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.dialogs.PreviousSearchesDialog; import org.apache.directory.studio.schemaeditor.view.search.SearchPage; import org.apache.directory.studio.schemaeditor.view.search.SearchPage.SearchInEnum; import org.apache.directory.studio.schemaeditor.view.views.SearchView; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action is show the search History. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowSearchHistoryAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated view */ private SearchView view; /** * Creates a new instance of ShowSearchFieldAction. */ public ShowSearchHistoryAction( SearchView view ) { super( Messages.getString( "ShowSearchHistoryAction.SearchHistoryAction" ), AS_DROP_DOWN_MENU ); //$NON-NLS-1$ this.view = view; setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SHOW_SEARCH_HISTORY ) ); setEnabled( true ); setMenuCreator( new MenuCreator( view ) ); } /** * {@inheritDoc} */ public void run() { PreviousSearchesDialog dialog = new PreviousSearchesDialog( view ); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } } class MenuCreator implements IMenuCreator { /** The menu */ private Menu menu; /** The associated view */ private SearchView view; /** * Creates a new instance of MenuCreator. * * @param view * the associated view */ public MenuCreator( SearchView view ) { this.view = view; } /** * {@inheritDoc} */ public void dispose() { if ( menu != null ) { menu.dispose(); menu = null; } } /** * {@inheritDoc} */ public Menu getMenu( Control parent ) { menu = new Menu( parent ); // Previous searches String[] previousSearches = SearchPage.loadSearchStringHistory(); for ( final String search : previousSearches ) { MenuItem item = new MenuItem( menu, SWT.RADIO ); item.setText( search ); item.setImage( Activator.getDefault().getImage( PluginConstants.IMG_SEARCH_HISTORY_ITEM ) ); item.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { view.setSearchInput( search, SearchPage.loadSearchIn().toArray( new SearchInEnum[0] ), SearchPage .loadScope() ); } } ); if ( search.equals( view.getSearchString() ) ) { item.setSelection( true ); } } // No search history if ( previousSearches.length == 0 ) { MenuItem item = new MenuItem( menu, SWT.RADIO ); item.setText( Messages.getString( "ShowSearchHistoryAction.None" ) ); //$NON-NLS-1$ item.setEnabled( false ); item.setSelection( true ); } // Menu Separator new MenuItem( menu, SWT.SEPARATOR ); MenuItem item = new MenuItem( menu, SWT.PUSH ); item.setText( Messages.getString( "ShowSearchHistoryAction.History" ) ); //$NON-NLS-1$ item.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { PreviousSearchesDialog dialog = new PreviousSearchesDialog( view ); dialog.open(); } } ); item = new MenuItem( menu, SWT.PUSH ); item.setText( Messages.getString( "ShowSearchHistoryAction.ClearHistory" ) ); //$NON-NLS-1$ item.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { SearchPage.clearSearchHistory(); } } ); return menu; } /** * {@inheritDoc} */ public Menu getMenu( Menu parent ) { return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenHierarchyViewPreferencesAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenHierarchyViewPreferencesAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.view.preferences.HierarchyViewPreferencePage; import org.eclipse.jface.action.Action; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This action opens the Preference Page for the Hierarchy View. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenHierarchyViewPreferencesAction extends Action { /** * Creates a new instance of OpenHierarchyViewPreferencesAction. */ public OpenHierarchyViewPreferencesAction() { super( Messages.getString( "OpenHierarchyViewPreferencesAction.PreferencesAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenHierarchyViewPreferencesAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); PreferencesUtil.createPreferenceDialogOn( shell, HierarchyViewPreferencePage.ID, new String[] { HierarchyViewPreferencePage.ID }, null ).open(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewSchemaAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewSchemaAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.NewSchemaWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the NewSchemaWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewSchemaAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of NewSchemaAction. */ public NewSchemaAction() { super( Messages.getString( "NewSchemaAction.NewSchemaAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "NewSchemaAction.NewSchemaToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_NEW_SCHEMA ); setActionDefinitionId( PluginConstants.CMD_NEW_SCHEMA ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_SCHEMA_NEW ) ); setEnabled( false ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard NewSchemaWizard wizard = new NewSchemaWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenProjectAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenProjectAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler; import org.apache.directory.studio.schemaeditor.controller.ProjectsHandlerAdapter; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.model.Project.ProjectState; import org.apache.directory.studio.schemaeditor.view.wrappers.ProjectWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action opens a Project. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenProjectAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TableViewer viewer; /** The ProjectsHandler */ private ProjectsHandler projectsHandler; /** * Creates a new instance of RenameProjectAction. * * @param view * the associate view */ public OpenProjectAction( TableViewer viewer ) { super( Messages.getString( "OpenProjectAction.OpenProjectAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenProjectAction.OpenProjectToolTip" ) ); //$NON-NLS-1$ setEnabled( false ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { enableDisable(); } } ); projectsHandler = Activator.getDefault().getProjectsHandler(); projectsHandler.addListener( new ProjectsHandlerAdapter() { public void openProjectChanged( Project oldProject, Project newProject ) { enableDisable(); } } ); } /** * Enables or disables the Action. */ private void enableDisable() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { setEnabled( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject().getState().equals( ProjectState.CLOSED ) ); } else { setEnabled( false ); } } /** * {@inheritDoc} */ public void run() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) ) { projectsHandler.openProject( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject() ); } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/SwitchSchemaPresentationToFlatAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/SwitchSchemaPresentationToFlatAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action launches the SwitchSchemaPresentationToFlatAction. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SwitchSchemaPresentationToFlatAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of SwitchSchemaPresentationToFlatAction. */ public SwitchSchemaPresentationToFlatAction() { super( Messages.getString( "SwitchSchemaPresentationToFlatAction.FlatAction" ), AS_RADIO_BUTTON ); //$NON-NLS-1$ setToolTipText( Messages.getString( "SwitchSchemaPresentationToFlatAction.FlatToolTip" ) ); //$NON-NLS-1$ setEnabled( false ); // Setting up the state of the action if ( Activator.getDefault().getPreferenceStore().getInt( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION ) == PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT ) { setChecked( true ); } } /** * {@inheritDoc} */ public void run() { Activator.getDefault().getPreferenceStore().setValue( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION, PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT ); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
/* * 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.studio.schemaeditor.controller.actions; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.controller.SchemaHandler; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action deletes one or more Schema Elements from the SchemaView. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DeleteSchemaElementAction extends Action implements IWorkbenchWindowActionDelegate { /** The associated viewer */ private TreeViewer viewer; /** * Creates a new instance of DeleteSchemaElementAction. */ public DeleteSchemaElementAction( TreeViewer viewer ) { super( Messages.getString( "DeleteSchemaElementAction.DeleteAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "DeleteSchemaElementAction.DeleteToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_DELETE_SCHEMA_ELEMENT ); setActionDefinitionId( PluginConstants.CMD_DELETE_SCHEMA_ELEMENT ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_DELETE ) ); setEnabled( true ); this.viewer = viewer; this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { StructuredSelection selection = ( StructuredSelection ) event.getSelection(); if ( selection.size() > 0 ) { boolean enabled = true; for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) { Object selectedItem = iterator.next(); if ( !( selectedItem instanceof SchemaWrapper ) && !( selectedItem instanceof AttributeTypeWrapper ) && !( selectedItem instanceof ObjectClassWrapper ) ) { enabled = false; break; } } setEnabled( enabled ); } else { setEnabled( false ); } } } ); } /** * {@inheritDoc} */ public void run() { StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); if ( !selection.isEmpty() ) { StringBuilder message = new StringBuilder(); int count = selection.size(); if ( count == 1 ) { Object firstElement = selection.getFirstElement(); if ( firstElement instanceof AttributeTypeWrapper ) { message.append( Messages.getString( "DeleteSchemaElementAction.SureDeleteAttributeType" ) ); //$NON-NLS-1$ } else if ( firstElement instanceof ObjectClassWrapper ) { message.append( Messages.getString( "DeleteSchemaElementAction.SureDeleteObjectClass" ) ); //$NON-NLS-1$ } else if ( firstElement instanceof SchemaWrapper ) { message.append( Messages.getString( "DeleteSchemaElementAction.SureDeleteSchema" ) ); //$NON-NLS-1$ } else { message.append( Messages.getString( "DeleteSchemaElementAction.SureDeleteItem" ) ); //$NON-NLS-1$ } } else { message.append( NLS.bind( Messages.getString( "DeleteSchemaElementAction.SureDeleteItems" ), new Object[] { count } ) ); //$NON-NLS-1$ } // Showing the confirmation window if ( MessageDialog.openConfirm( viewer.getControl().getShell(), Messages.getString( "DeleteSchemaElementAction.DeleteTitle" ), message.toString() ) ) //$NON-NLS-1$ { Map<String, Schema> schemasMap = new HashMap<String, Schema>(); List<SchemaObject> schemaObjectsList = new ArrayList<SchemaObject>(); for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) { Object selectedItem = iterator.next(); if ( selectedItem instanceof SchemaWrapper ) { Schema schema = ( ( SchemaWrapper ) selectedItem ).getSchema(); schemasMap.put( Strings.toLowerCase( schema.getSchemaName() ), schema ); } else if ( selectedItem instanceof AttributeTypeWrapper ) { AttributeType at = ( ( AttributeTypeWrapper ) selectedItem ).getAttributeType(); schemaObjectsList.add( at ); } else if ( selectedItem instanceof ObjectClassWrapper ) { ObjectClass oc = ( ( ObjectClassWrapper ) selectedItem ).getObjectClass(); schemaObjectsList.add( oc ); } } SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler(); // Removing schema objects for ( SchemaObject schemaObject : schemaObjectsList ) { if ( !schemasMap.containsKey( Strings.toLowerCase( schemaObject.getSchemaName() ) ) ) { // If the schema object is not part of deleted schema, we need to delete it. // But, we don't delete schema objects that are part of a deleted schema, since // deleting the schema will also delete this schema object. if ( schemaObject instanceof AttributeType ) { schemaHandler.removeAttributeType( ( AttributeType ) schemaObject ); } else if ( schemaObject instanceof ObjectClass ) { schemaHandler.removeObjectClass( ( ObjectClass ) schemaObject ); } } } // Removing schemas for ( Schema schema : schemasMap.values() ) { schemaHandler.removeSchema( schema ); } } } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewProjectAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/NewProjectAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.wizards.NewProjectWizard; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action launches the NewProjectWizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewProjectAction extends Action implements IWorkbenchWindowActionDelegate { /** * Creates a new instance of NewProjectAction. */ public NewProjectAction() { super( Messages.getString( "NewProjectAction.NewSchemaProjectAction" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "NewProjectAction.NewSchemaProjectToolTip" ) ); //$NON-NLS-1$ setId( PluginConstants.CMD_NEW_PROJECT ); setActionDefinitionId( PluginConstants.CMD_NEW_PROJECT ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_PROJECT_NEW ) ); setEnabled( true ); } /** * {@inheritDoc} */ public void run() { // Instantiates and initializes the wizard NewProjectWizard wizard = new NewProjectWizard(); wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/LinkWithEditorSchemaViewAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/LinkWithEditorSchemaViewAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditor; import org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditor; import org.apache.directory.studio.schemaeditor.view.editors.schema.SchemaEditor; import org.apache.directory.studio.schemaeditor.view.views.SchemaView; import org.apache.directory.studio.schemaeditor.view.views.SchemaViewContentProvider; import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper; import org.apache.directory.studio.schemaeditor.view.wrappers.TreeNode; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; /** * This action is used to link the with the view with the frontmost editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LinkWithEditorSchemaViewAction extends Action implements IWorkbenchWindowActionDelegate { /** The String for storing the checked state of the action */ private static final String LINK_WITH_EDITOR_SCHEMAS_VIEW_DS_KEY = LinkWithEditorSchemaViewAction.class.getName() + ".dialogsettingkey"; //$NON-NLS-1$ /** The associated view */ private SchemaView view; /** The listener listening on changes on editors */ private IPartListener2 editorListener = new IPartListener2() { /** * {@inheritDoc} */ public void partVisible( IWorkbenchPartReference partRef ) { IWorkbenchPart part = partRef.getPart( true ); if ( part instanceof ObjectClassEditor ) { view.getSite().getPage().removePostSelectionListener( viewListener ); linkViewWithEditor( ( ( ObjectClassEditor ) part ).getOriginalObjectClass() ); view.getSite().getPage().addPostSelectionListener( viewListener ); } else if ( part instanceof AttributeTypeEditor ) { view.getSite().getPage().removePostSelectionListener( viewListener ); linkViewWithEditor( ( ( AttributeTypeEditor ) part ).getOriginalAttributeType() ); view.getSite().getPage().addPostSelectionListener( viewListener ); } else if ( part instanceof SchemaEditor ) { view.getSite().getPage().removePostSelectionListener( viewListener ); linkViewWithEditor( ( ( SchemaEditor ) part ).getSchema() ); view.getSite().getPage().addPostSelectionListener( viewListener ); } } /** * {@inheritDoc} */ public void partActivated( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partClosed( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partDeactivated( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partHidden( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partInputChanged( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partOpened( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partBroughtToTop( IWorkbenchPartReference partRef ) { } }; /** The listener listening on changes on the view */ private ISelectionListener viewListener = new ISelectionListener() { /** * {@inheritDoc} */ public void selectionChanged( IWorkbenchPart part, ISelection selection ) { IStructuredSelection iSelection = ( IStructuredSelection ) selection; Object selectedObject = iSelection.getFirstElement(); if ( ( selectedObject instanceof SchemaWrapper ) || ( selectedObject instanceof ObjectClassWrapper ) || ( selectedObject instanceof AttributeTypeWrapper ) ) { linkEditorWithView( ( TreeNode ) selectedObject ); } } }; /** * Creates a new instance of ExportSchemasAsXmlAction. */ public LinkWithEditorSchemaViewAction( SchemaView view ) { super( Messages.getString( "LinkWithEditorSchemaViewAction.LinkEditorAction" ), AS_CHECK_BOX ); //$NON-NLS-1$ setToolTipText( Messages.getString( "LinkWithEditorSchemaViewAction.LinkEditorToolTip" ) ); //$NON-NLS-1$ setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_LINK_WITH_EDITOR ) ); setEnabled( false ); this.view = view; // Setting up the default key value (if needed) if ( Activator.getDefault().getDialogSettings().get( LINK_WITH_EDITOR_SCHEMAS_VIEW_DS_KEY ) == null ) { Activator.getDefault().getDialogSettings().put( LINK_WITH_EDITOR_SCHEMAS_VIEW_DS_KEY, false ); } // Setting state from the dialog settings setChecked( Activator.getDefault().getDialogSettings().getBoolean( LINK_WITH_EDITOR_SCHEMAS_VIEW_DS_KEY ) ); // Enabling the listeners if ( isChecked() ) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener ); view.getSite().getPage().addPostSelectionListener( viewListener ); } } /** * {@inheritDoc} */ public void run() { setChecked( isChecked() ); Activator.getDefault().getDialogSettings().put( LINK_WITH_EDITOR_SCHEMAS_VIEW_DS_KEY, isChecked() ); if ( isChecked() ) // Enabling the listeners { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener ); IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); if ( activeEditor instanceof ObjectClassEditor ) { view.getSite().getPage().removePostSelectionListener( viewListener ); linkViewWithEditor( ( ( ObjectClassEditor ) activeEditor ).getOriginalObjectClass() ); view.getSite().getPage().addPostSelectionListener( viewListener ); } else if ( activeEditor instanceof AttributeTypeEditor ) { view.getSite().getPage().removePostSelectionListener( viewListener ); linkViewWithEditor( ( ( AttributeTypeEditor ) activeEditor ).getOriginalAttributeType() ); view.getSite().getPage().addPostSelectionListener( viewListener ); } else if ( activeEditor instanceof SchemaEditor ) { view.getSite().getPage().removePostSelectionListener( viewListener ); linkViewWithEditor( ( ( SchemaEditor ) activeEditor ).getSchema() ); view.getSite().getPage().addPostSelectionListener( viewListener ); } view.getSite().getPage().addPostSelectionListener( viewListener ); } else // Disabling the listeners { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener( editorListener ); view.getSite().getPage().removePostSelectionListener( viewListener ); } } /** * Links the view with the right editor * * @param o * the object */ private void linkViewWithEditor( Object o ) { TreeNode wrapper = ( ( SchemaViewContentProvider ) view.getViewer().getContentProvider() ).getWrapper( o ); if ( wrapper != null ) { view.getViewer().setSelection( new StructuredSelection( wrapper ) ); } } /** * Links the editor to the view * * @param wrapper * the selected element in the view */ private void linkEditorWithView( TreeNode wrapper ) { IEditorReference[] references = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for ( IEditorReference reference : references ) { IWorkbenchPart workbenchPart = reference.getPart( true ); if ( ( workbenchPart instanceof ObjectClassEditor ) && ( wrapper instanceof ObjectClassWrapper ) ) { ObjectClassEditor editor = ( ObjectClassEditor ) workbenchPart; ObjectClassWrapper ocw = ( ObjectClassWrapper ) wrapper; if ( editor.getOriginalObjectClass().equals( ocw.getObjectClass() ) ) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( workbenchPart ); return; } } else if ( ( workbenchPart instanceof AttributeTypeEditor ) && ( wrapper instanceof AttributeTypeWrapper ) ) { AttributeTypeEditor editor = ( AttributeTypeEditor ) workbenchPart; AttributeTypeWrapper atw = ( AttributeTypeWrapper ) wrapper; if ( editor.getOriginalAttributeType().equals( atw.getAttributeType() ) ) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( workbenchPart ); return; } } else if ( ( workbenchPart instanceof SchemaEditor ) && ( wrapper instanceof SchemaWrapper ) ) { SchemaEditor editor = ( SchemaEditor ) workbenchPart; SchemaWrapper sw = ( SchemaWrapper ) wrapper; if ( editor.getSchema().equals( sw.getSchema() ) ) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( workbenchPart ); return; } } } } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CollapseAllAction.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CollapseAllAction.java
/* * 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.studio.schemaeditor.controller.actions; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.PluginConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action collapse all the of the given TreeViewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CollapseAllAction extends Action implements IWorkbenchWindowActionDelegate { /** The TreeViewer */ private TreeViewer viewer; /** * Creates a new instance of CollapseAllAction. * * @param viewer * the associate viewer */ public CollapseAllAction( TreeViewer viewer ) { super( Messages.getString( "CollapseAllAction.CollapseAllAction" ) ); //$NON-NLS-1$ setToolTipText( getText() ); setImageDescriptor( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_COLLAPSE_ALL ) ); setEnabled( false ); this.viewer = viewer; } /** * {@inheritDoc} */ public void run() { viewer.collapseAll(); } /** * {@inheritDoc} */ public void run( IAction action ) { run(); } /** * {@inheritDoc} */ public void dispose() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { // Nothing to do } /** * {@inheritDoc} */ public void selectionChanged( IAction action, ISelection selection ) { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
/* * 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.studio.schemaeditor.model; import java.util.List; import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.schemaeditor.controller.SchemaHandler; import org.apache.directory.studio.schemaeditor.model.io.SchemaConnector; import org.apache.directory.studio.schemaeditor.model.io.SchemaConnectorException; /** * This class implements a Project. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Project { /** * This enum represents the different states of Project. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum ProjectState { /** An Open project*/ OPEN, /** A Closed project*/ CLOSED } /** The type of the project */ private ProjectType type; /** The name of the project */ private String name; /** The connection of the project */ private Connection connection; /** The state of the project */ private ProjectState state; /** The SchemaConnector of the project */ private SchemaConnector schemaConnector; /** The SchemaHandler */ private SchemaHandler schemaHandler; /** The initial schema of the Online Schema */ private List<Schema> initialSchema; /** The flag for Online Schema Fetch */ private boolean hasOnlineSchemaBeenFetched = false; /** * Creates a new instance of Project. * * @param type * the type of project * @param name * the name of project */ public Project( ProjectType type, String name ) { init( type, name, ProjectState.CLOSED ); } /** * Creates a new instance of Project. * The default type is used : OFFLINE. */ public Project() { init( ProjectType.OFFLINE, null, ProjectState.CLOSED ); } /** * Creates a new instance of Project. * * @param type * the type of project */ public Project( ProjectType type ) { init( type, null, ProjectState.CLOSED ); } /** * Inits the project. * * @param type * the type of the project * @param name * the name of the project * @param state * the state of the project */ private void init( ProjectType type, String name, ProjectState state ) { this.type = type; this.name = name; this.state = state; schemaHandler = new SchemaHandler(); } /** * Gets the type of the project. * * @return * the type of the project */ public ProjectType getType() { return type; } /** * Sets the type of the project. * * @param type * the type of the project */ public void setType( ProjectType type ) { this.type = type; } /** * Gets the name of the project. * * @return * the name of the project */ public String getName() { return name; } /** * Sets the name of the project * * @param name * the name */ public void setName( String name ) { this.name = name; } /** * Gets the state of the project. * * @return * the state of the project */ public ProjectState getState() { return state; } /** * Sets the state of the project * * @param state * the state */ public void setState( ProjectState state ) { this.state = state; } /** * Gets the SchemaHandler * * @return * the SchemaHandler */ public SchemaHandler getSchemaHandler() { return schemaHandler; } /** * Gets the Connection. * * @return * the connection */ public Connection getConnection() { return connection; } /** * Sets the Connection. * * @param connection * the connection */ public void setConnection( Connection connection ) { this.connection = connection; } /** * Fetches the Online Schema. * * @param monitor * a StudioProgressMonitor */ public void fetchOnlineSchema( StudioProgressMonitor monitor ) { if ( ( !hasOnlineSchemaBeenFetched ) && ( connection != null ) && ( schemaConnector != null ) ) { try { schemaConnector.importSchema( this, monitor ); } catch ( SchemaConnectorException e ) { monitor.reportError( e ); } // Adding each schema to the schema handler if ( initialSchema != null ) { monitor.beginTask( Messages.getString( "Project.AddingSchemaToProject" ), initialSchema.size() ); //$NON-NLS-1$ for ( Schema schema : initialSchema ) { getSchemaHandler().addSchema( schema ); } } hasOnlineSchemaBeenFetched = true; monitor.done(); } } /** * Returns whether the online schema has been fetched. * * @return * true if the online schema has bee fetched */ public boolean hasOnlineSchemaBeenFetched() { return hasOnlineSchemaBeenFetched; } /** * Gets the initial schema. * * @return the initial schema */ public List<Schema> getInitialSchema() { return initialSchema; } /** * Sets the initial schema. * * @param initialSchema the initial schema */ public void setInitialSchema( List<Schema> initialSchema ) { this.initialSchema = initialSchema; } /** * Gets the SchemaConnector. * * @return * the SchemaConnector */ public SchemaConnector getSchemaConnector() { return schemaConnector; } /** * Sets the SchemaConnector. * * @param schemaConnector * the SchemaConnector */ public void setSchemaConnector( SchemaConnector schemaConnector ) { this.schemaConnector = schemaConnector; } /** * {@inheritDoc} */ public boolean equals( Object obj ) { if ( obj instanceof Project ) { Project project = ( Project ) obj; if ( !getName().equals( project.getName() ) ) { return false; } else if ( !getType().equals( project.getType() ) ) { return false; } else if ( !getState().equals( project.getState() ) ) { return false; } return true; } // Default return super.equals( obj ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/ProjectType.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/ProjectType.java
/* * 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.studio.schemaeditor.model; /** * This enum represents the different types of Project. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum ProjectType { /** A schema project not linked to any LDAP Server */ OFFLINE, /** A schema project linked to a Directory Server */ ONLINE }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Schema.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Schema.java
/* * 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.studio.schemaeditor.model; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.registries.DefaultSchema; /** * This class represents a schema. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Schema extends DefaultSchema { /** The project */ private Project project; /** The AttributeType List */ private List<AttributeType> attributeTypes = new ArrayList<AttributeType>(); /** The ObjectClass List */ private List<ObjectClass> objectClasses = new ArrayList<ObjectClass>(); /** The MatchingRule List */ private List<MatchingRule> matchingRules = new ArrayList<MatchingRule>(); /** The Syntax List */ private List<LdapSyntax> syntaxes = new ArrayList<LdapSyntax>(); /** * Creates a new instance of Schema. * * @param name * the name of the schema */ public Schema( String name ) { super( null, name ); } /** * Adds an AttributeType to the Schema. * * @param at * the AttributeType */ public boolean addAttributeType( AttributeType at ) { return attributeTypes.add( at ); } /** * Adds a MatchingRule from the Schema. * * @param mr * the MatchingRule */ public boolean addMatchingRule( MatchingRule mr ) { return matchingRules.add( mr ); } /** * Adds an ObjectClass to the Schema. * * @param oc * the ObjectClass */ public boolean addObjectClass( ObjectClass oc ) { return objectClasses.add( oc ); } /** * Adds a Syntax from the Schema. * * @param syntax * the Syntax */ public boolean addSyntax( LdapSyntax syntax ) { return syntaxes.add( syntax ); } /** * Gets the AttributeType identified by the given id. * * @param id * the name or the oid of the AttributeType * @return * the AttributeType identified by the given id, or null if the * AttributeType has not been found */ public AttributeType getAttributeType( String id ) { for ( AttributeType at : attributeTypes ) { List<String> aliases = at.getNames(); if ( aliases != null ) { for ( String alias : aliases ) { if ( alias.equalsIgnoreCase( id ) ) { return at; } } } if ( at.getOid().equalsIgnoreCase( id ) ) { return at; } } return null; } /** * Gets all the AttributeType objects contained in the Schema. * * @return * all the AttributeType objects contained in the Schema */ public List<AttributeType> getAttributeTypes() { return attributeTypes; } /** * Gets the MatchingRule identified by the given id. * * @param id * the name or the oid of the MatchingRule * @return * the MatchingRule identified by the given id, or null if the * MatchingRule has not been found */ public MatchingRule getMatchingRule( String id ) { for ( MatchingRule mr : matchingRules ) { List<String> aliases = mr.getNames(); if ( aliases != null ) { for ( String alias : aliases ) { if ( alias.equalsIgnoreCase( id ) ) { return mr; } } } if ( mr.getOid().equalsIgnoreCase( id ) ) { return mr; } } return null; } /** * Gets all the MatchingRule objects contained in the Schema. * * @return * all the MatchingRule objects contained in the Schema */ public List<MatchingRule> getMatchingRules() { return matchingRules; } /** * Gets the project of the Schema. * * @return * the project of the Schema */ public Project getProject() { return project; } /** * Gets the ObjectClass identified by the given id. * * @param id * the name or the oid of the ObjectClass * @return * the ObjectClass identified by the given id, or null if the * ObjectClass has not been found */ public ObjectClass getObjectClass( String id ) { for ( ObjectClass oc : objectClasses ) { List<String> aliases = oc.getNames(); if ( aliases != null ) { for ( String alias : aliases ) { if ( alias.equalsIgnoreCase( id ) ) { return oc; } } } if ( oc.getOid().equalsIgnoreCase( id ) ) { return oc; } } return null; } /** * Gets all the ObjectClass objects contained in the Schema. * * @return * all the ObjectClass objects contained in the Schema */ public List<ObjectClass> getObjectClasses() { return objectClasses; } /** * Gets the Syntax identified by the given id. * * @param id * the name or the oid of the Syntax * @return * the Syntax identified by the given id, or null if the * Syntax has not been found */ public LdapSyntax getSyntax( String id ) { for ( LdapSyntax syntax : syntaxes ) { List<String> aliases = syntax.getNames(); if ( aliases != null ) { for ( String alias : aliases ) { if ( alias.equalsIgnoreCase( id ) ) { return syntax; } } } if ( syntax.getOid().equalsIgnoreCase( id ) ) { return syntax; } } return null; } /** * Gets all the Syntax objects contained in the Schema. * * @return * all the Syntax objects contained in the Schema */ public List<LdapSyntax> getSyntaxes() { return syntaxes; } /** * Removes an AttributeType from the Schema. * * @param at * the AttributeType */ public boolean removeAttributeType( AttributeType at ) { return attributeTypes.remove( at ); } /** * Removes a MatchingRule from the Schema. * * @param mr * the MatchingRule */ public boolean removeMatchingRule( MatchingRule mr ) { return matchingRules.remove( mr ); } /** * Removes an ObjectClass from the Schema. * * @param oc * the ObjectClass */ public boolean removeObjectClass( ObjectClass oc ) { return objectClasses.remove( oc ); } /** * Removes a Syntax from the Schema. * * @param syntax * the Syntax */ public boolean removeSyntax( LdapSyntax syntax ) { return syntaxes.remove( syntax ); } /** * Sets the name of the schema. * * @param schemaName * the name of the schema */ public void setSchemaName( String schemaName ) { this.name = schemaName; } /** * Sets the project of the Schema. * * @param name * the project of the schema */ public void setProject( Project project ) { this.project = project; } /** * {@inheritDoc} */ public String toString() { return getSchemaName(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/DependenciesComputer.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/DependenciesComputer.java
/* * 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.studio.schemaeditor.model; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.studio.schemaeditor.controller.SchemaHandler; import org.eclipse.osgi.util.NLS; /** * This class represents the DependenciesComputer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DependenciesComputer { /** The schemas List */ private List<Schema> schemasList; /** The dependency ordered schemas List */ private List<Schema> dependencyOrderedSchemasList; /** The SchemaHandler */ private SchemaHandler schemaHandler; // The dependencies MultiMaps private MultiValuedMap schemasDependencies; private MultiValuedMap attributeTypesDependencies; private MultiValuedMap objectClassesDependencies; /** * Creates a new instance of DependenciesComputer. * * @param schemasList * the schemasList * @throws DependencyComputerException */ public DependenciesComputer( List<Schema> schemas ) throws DependencyComputerException { this.schemasList = schemas; // Creating the SchemaHandler schemaHandler = new SchemaHandler(); // Creating the dependencies MultiMaps schemasDependencies = new ArrayListValuedHashMap<>(); attributeTypesDependencies = new ArrayListValuedHashMap<>(); objectClassesDependencies = new ArrayListValuedHashMap<>(); if ( schemas != null ) { // Adding the schemasList in the SchemaHandler for ( Schema schema : this.schemasList ) { schemaHandler.addSchema( schema ); } // Computing dependencies for ( Schema schema : this.schemasList ) { List<AttributeType> attributeTypes = schema.getAttributeTypes(); if ( attributeTypes != null ) { for ( AttributeType attributeType : attributeTypes ) { computeDependencies( schema, attributeType ); } } List<ObjectClass> objectClasses = schema.getObjectClasses(); if ( objectClasses != null ) { for ( ObjectClass objectClass : objectClasses ) { computeDependencies( schema, objectClass ); } } } // Ordering the schemas orderSchemasBasedOnDependencies(); } } /** * Computes the dependencies for the given attribute type. * * @param schema * the schema * @param attributeType * the attribute type * @throws DependencyComputerException */ private void computeDependencies( Schema schema, AttributeType attributeType ) throws DependencyComputerException { // Superior String superior = attributeType.getSuperiorOid(); if ( superior != null ) { AttributeType superiorAT = schemaHandler.getAttributeType( superior ); if ( superiorAT == null ) { throw new DependencyComputerException( NLS.bind( Messages .getString( "DependenciesComputer.SuperiorAttribute" ), new String[] { superior } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the superior attribute type attributeTypesDependencies.put( attributeType, superiorAT ); // Computing the schema dependency computeSchemaDependency( schema, superiorAT ); } } // Syntax OID String syntaxOID = attributeType.getSyntaxOid(); if ( syntaxOID != null ) { LdapSyntax syntax = schemaHandler.getSyntax( syntaxOID ); if ( syntax == null ) { throw new DependencyComputerException( NLS.bind( Messages.getString( "DependenciesComputer.SyntaxOID" ), new String[] { syntaxOID } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the syntax attributeTypesDependencies.put( attributeType, syntax ); // Computing the schema dependency computeSchemaDependency( schema, syntax ); } } // Equality Matching Rule String equalityName = attributeType.getEqualityOid(); if ( equalityName != null ) { MatchingRule equalityMatchingRule = schemaHandler.getMatchingRule( equalityName ); if ( equalityMatchingRule == null ) { throw new DependencyComputerException( NLS.bind( Messages.getString( "DependenciesComputer.Equality" ), new String[] { equalityName } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the syntax attributeTypesDependencies.put( attributeType, equalityMatchingRule ); // Computing the schema dependency computeSchemaDependency( schema, equalityMatchingRule ); } } // Ordering Matching Rule String orderingName = attributeType.getOrderingOid(); if ( orderingName != null ) { MatchingRule orderingMatchingRule = schemaHandler.getMatchingRule( orderingName ); if ( orderingMatchingRule == null ) { throw new DependencyComputerException( NLS.bind( Messages.getString( "DependenciesComputer.Ordering" ), new String[] { orderingName } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the syntax attributeTypesDependencies.put( attributeType, orderingMatchingRule ); // Computing the schema dependency computeSchemaDependency( schema, orderingMatchingRule ); } } // Substring Matching Rule String substringName = attributeType.getSubstringOid(); if ( substringName != null ) { MatchingRule substringMatchingRule = schemaHandler.getMatchingRule( substringName ); if ( substringMatchingRule == null ) { throw new DependencyComputerException( NLS.bind( Messages.getString( "DependenciesComputer.Substring" ), new String[] { substringName } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the syntax attributeTypesDependencies.put( attributeType, substringMatchingRule ); // Computing the schema dependency computeSchemaDependency( schema, substringMatchingRule ); } } } /** * Computes the dependencies for the given object Class. * * @param schema * the schema * @param objectClass * the object class * @throws DependencyComputerException */ private void computeDependencies( Schema schema, ObjectClass objectClass ) throws DependencyComputerException { // Super Classes List<String> superClassesNames = objectClass.getSuperiorOids(); if ( superClassesNames != null ) { for ( String superClassName : superClassesNames ) { ObjectClass superObjectClass = schemaHandler.getObjectClass( superClassName ); if ( superObjectClass == null ) { throw new DependencyComputerException( NLS.bind( Messages .getString( "DependenciesComputer.SuperiorObject" ), new String[] { superClassName } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the syntax objectClassesDependencies.put( objectClass, superObjectClass ); // Computing the schema dependency computeSchemaDependency( schema, superObjectClass ); } } } // Optional attribute types List<String> optionalAttributeTypes = objectClass.getMayAttributeTypeOids(); if ( optionalAttributeTypes != null ) { for ( String optionalAttributeTypeName : optionalAttributeTypes ) { AttributeType optionalAttributeType = schemaHandler.getAttributeType( optionalAttributeTypeName ); if ( optionalAttributeType == null ) { throw new DependencyComputerException( NLS.bind( Messages .getString( "DependenciesComputer.Optional" ), new Object[] { optionalAttributeType } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the syntax objectClassesDependencies.put( objectClass, optionalAttributeType ); // Computing the schema dependency computeSchemaDependency( schema, optionalAttributeType ); } } } // Mandatory attribute types List<String> mandatoryAttributeTypes = objectClass.getMustAttributeTypeOids(); if ( mandatoryAttributeTypes != null ) { for ( String mandatoryAttributeTypeName : mandatoryAttributeTypes ) { AttributeType mandatoryAttributeType = schemaHandler.getAttributeType( mandatoryAttributeTypeName ); if ( mandatoryAttributeType == null ) { throw new DependencyComputerException( NLS.bind( Messages .getString( "DependenciesComputer.Mandatory" ), new String[] //$NON-NLS-1$ { mandatoryAttributeTypeName } ) ); } else { // Adding a dependency on the syntax objectClassesDependencies.put( objectClass, mandatoryAttributeType ); // Computing the schema dependency computeSchemaDependency( schema, mandatoryAttributeType ); } } } } /** * Computes the Schema Dependency. * * @param schema * the schema * @param object * the SchemaObject * @throws DependencyComputerException */ private void computeSchemaDependency( Schema schema, SchemaObject object ) throws DependencyComputerException { String schemaName = object.getSchemaName(); if ( !schemaName.equalsIgnoreCase( schema.getSchemaName() ) ) { Schema schemaFromSuperiorAT = schemaHandler.getSchema( schemaName ); if ( schemaFromSuperiorAT == null ) { throw new DependencyComputerException( NLS.bind( Messages.getString( "DependenciesComputer.Schema" ), new String[] { schemaName } ) ); //$NON-NLS-1$ } else { // Adding a dependency on the schema of schema object schemasDependencies.put( schema, schemaFromSuperiorAT ); } } } /** * Orders the schemas based on their dependencies. */ private void orderSchemasBasedOnDependencies() { dependencyOrderedSchemasList = new ArrayList<Schema>(); int counter = 0; schemasLoop: while ( dependencyOrderedSchemasList.size() != schemasList.size() ) { Schema schema = schemasList.get( counter ); if ( !dependencyOrderedSchemasList.contains( schema ) ) { List<Schema> dependencies = getDependencies( schema ); if ( dependencies == null ) { dependencyOrderedSchemasList.add( schema ); } else { for ( Schema dependency : dependencies ) { if ( !dependencyOrderedSchemasList.contains( dependency ) ) { counter = ++counter % schemasList.size(); continue schemasLoop; } } dependencyOrderedSchemasList.add( schema ); } } counter = ++counter % schemasList.size(); } } /** * Gets the dependencies of the given schema. * * @param schema * the schema * @return * the dependencies of the schema */ @SuppressWarnings("unchecked") public List<Schema> getDependencies( Schema schema ) { List<Schema> dependencies = ( List<Schema> ) schemasDependencies.get( schema ); HashSet<Schema> set = new HashSet<Schema>(); if ( dependencies != null ) { set.addAll( dependencies ); } return Arrays.asList( set.toArray( new Schema[0] ) ); } /** * Gets the List of the schemas ordered according to their * dependencies. * * @return * the List of the schemas ordered according to their * dependencies */ public List<Schema> getDependencyOrderedSchemasList() { return dependencyOrderedSchemasList; } /** * Gets the schemasList dependencies MultiMap. * * @return * the schemasList dependencies MultiMap */ public MultiValuedMap getSchemasDependencies() { return schemasDependencies; } /** * Get the attribute types dependencies MultiMap. * * @return * the attribute types dependencies MultiMap */ public MultiValuedMap getAttributeTypesDependencies() { return attributeTypesDependencies; } /** * Gets the object classes dependencies MultiMap. * * @return * the object classes dependencies MultiMap */ public MultiValuedMap getObjectClassesDependencies() { return objectClassesDependencies; } /** * This class represents the DependencyComputerException. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DependencyComputerException extends Exception { private static final long serialVersionUID = 1L; /** * Creates a new instance of DependencyComputerException. * * @param message * the message */ public DependencyComputerException( String message ) { super( message ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Messages.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Messages.java
/* * 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.studio.schemaeditor.model; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SingleValueDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SingleValueDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of single value value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SingleValueDifference extends AbstractPropertyDifference { /** * Creates a new instance of SingleValueDifference. * * @param source * the source Object * @param destination * the destination Object */ public SingleValueDifference( Object source, Object destination ) { super( source, destination, DifferenceType.MODIFIED ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/CollectiveDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/CollectiveDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of collective value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CollectiveDifference extends AbstractPropertyDifference { /** * Creates a new instance of CollectiveDifference. * * @param source * the source Object * @param destination * the destination Object */ public CollectiveDifference( Object source, Object destination ) { super( source, destination, DifferenceType.MODIFIED ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/MandatoryATDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/MandatoryATDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of mandatory attribute type. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MandatoryATDifference extends AbstractPropertyDifference { /** * Creates a new instance of MandatoryATDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public MandatoryATDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of MandatoryATDifference. * * @param source * the source Object * @param destination * the destination Object */ public MandatoryATDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/OrderingDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/OrderingDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of ordering. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OrderingDifference extends AbstractPropertyDifference { /** * Creates a new instance of OrderingDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public OrderingDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of OrderingDifference. * * @param source * the source Object * @param destination * the destination Object */ public OrderingDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/ClassTypeDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/ClassTypeDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of class type. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ClassTypeDifference extends AbstractPropertyDifference { /** * Creates a new instance of ClassTypeDifference. * * @param source * the source Object * @param destination * the destination Object */ public ClassTypeDifference( Object source, Object destination ) { super( source, destination, DifferenceType.MODIFIED ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/DescriptionDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/DescriptionDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of description. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DescriptionDifference extends AbstractPropertyDifference { /** * Creates a new instance of DescriptionDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public DescriptionDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of DescriptionDifference. * * @param source * the source Object * @param destination * the destination Object */ public DescriptionDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SyntaxLengthDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SyntaxLengthDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of syntax length. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SyntaxLengthDifference extends AbstractPropertyDifference { /** * Creates a new instance of SyntaxLengthDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public SyntaxLengthDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of SyntaxLengthDifference. * * @param source * the source Object * @param destination * the destination Object */ public SyntaxLengthDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/DifferenceType.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/DifferenceType.java
/* * 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.studio.schemaeditor.model.difference; /** * This enum represents the type of Difference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum DifferenceType { IDENTICAL, ADDED, MODIFIED, REMOVED }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/ObjectClassDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/ObjectClassDifference.java
/* * 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.studio.schemaeditor.model.difference; import java.util.ArrayList; import java.util.List; /** * This interface represents an object class difference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ObjectClassDifference extends AbstractDifference { /** The differences */ private List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); /** * Creates a new instance of AttributeTypeDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public ObjectClassDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of AttributeTypeDifference. * * @param source * the source Object * @param destination * the destination Object */ public ObjectClassDifference( Object source, Object destination ) { super( source, destination ); } /** * Gets the property differences. * * @return * the property differences */ public List<PropertyDifference> getDifferences() { return differences; } /** * Adds a difference. * * @param difference * the difference */ public void addDifference( PropertyDifference difference ) { differences.add( difference ); } /** * Adds differences. * * @param differences * the differences */ public void addDifferences( List<PropertyDifference> differences ) { this.differences.addAll( differences ); } /** * Removes a difference. * * @param difference * the difference */ public void removeDifference( PropertyDifference difference ) { differences.remove( difference ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AliasDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AliasDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of alias. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AliasDifference extends AbstractPropertyDifference { /** * Creates a new instance of AliasDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public AliasDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of AliasDifference. * * @param source * the source Object * @param destination * the destination Object */ public AliasDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/NoUserModificationDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/NoUserModificationDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of no user modification value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NoUserModificationDifference extends AbstractPropertyDifference { /** * Creates a new instance of NoUserModificationDifference. * * @param source * the source Object * @param destination * the destination Object */ public NoUserModificationDifference( Object source, Object destination ) { super( source, destination, DifferenceType.MODIFIED ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/DifferenceEngine.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/DifferenceEngine.java
/* * 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.studio.schemaeditor.model.difference; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.api.ldap.model.schema.UsageEnum; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.schemaeditor.model.Schema; /** * This class represents the difference engine. * It is used to generate the difference between two Objects. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DifferenceEngine { /** * Gets the differences between two Lists of Schemas. * * @param l1 * the first list * @param l2 * the second list * @return * the differences between the two schema Lists */ public static List<SchemaDifference> getDifferences( List<Schema> l1, List<Schema> l2 ) { List<SchemaDifference> differences = new ArrayList<SchemaDifference>(); // Building Maps for schemas Map<String, Schema> mapL1 = new HashMap<String, Schema>(); for ( Schema schema : l1 ) { mapL1.put( Strings.toLowerCase( schema.getSchemaName() ), schema ); } Map<String, Schema> mapL2 = new HashMap<String, Schema>(); for ( Schema schema : l2 ) { mapL2.put( Strings.toLowerCase( schema.getSchemaName() ), schema ); } // Looping on schemas from the first list for ( Schema schemaFromL1 : l1 ) { Schema schemaFromL2 = mapL2.get( Strings.toLowerCase( schemaFromL1.getSchemaName() ) ); if ( schemaFromL2 == null ) { SchemaDifference schemaDifference = new SchemaDifference( schemaFromL1, null, DifferenceType.REMOVED ); differences.add( schemaDifference ); // Adding attribute types for ( AttributeType at : schemaFromL1.getAttributeTypes() ) { schemaDifference.addAttributeTypeDifference( new AttributeTypeDifference( null, at, DifferenceType.REMOVED ) ); } // Adding object classes for ( ObjectClass oc : schemaFromL1.getObjectClasses() ) { schemaDifference.addObjectClassDifference( new ObjectClassDifference( null, oc, DifferenceType.REMOVED ) ); } } else { SchemaDifference schemaDifference = new SchemaDifference( schemaFromL1, schemaFromL2, DifferenceType.IDENTICAL ); differences.add( schemaDifference ); // Building Maps for attribute types Map<String, AttributeType> atMapL1 = new HashMap<String, AttributeType>(); for ( AttributeType at : schemaFromL1.getAttributeTypes() ) { atMapL1.put( at.getOid(), at ); } Map<String, AttributeType> atMapL2 = new HashMap<String, AttributeType>(); for ( AttributeType at : schemaFromL2.getAttributeTypes() ) { atMapL2.put( at.getOid(), at ); } // Looping on the attribute types from the Schema from the first list for ( AttributeType atFromL1 : schemaFromL1.getAttributeTypes() ) { AttributeType atFromL2 = atMapL2.get( atFromL1.getOid() ); if ( atFromL2 == null ) { AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( atFromL1, null, DifferenceType.REMOVED ); schemaDifference.addAttributeTypeDifference( attributeTypeDifference ); schemaDifference.setType( DifferenceType.MODIFIED ); } else { AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( atFromL1, atFromL2, DifferenceType.IDENTICAL ); schemaDifference.addAttributeTypeDifference( attributeTypeDifference ); List<PropertyDifference> atDifferences = getDifferences( atFromL1, atFromL2 ); if ( atDifferences.size() > 0 ) { attributeTypeDifference.setType( DifferenceType.MODIFIED ); attributeTypeDifference.addDifferences( atDifferences ); schemaDifference.setType( DifferenceType.MODIFIED ); } } } // Looping on the attribute types from the Schema from the second list for ( AttributeType atFromL2 : schemaFromL2.getAttributeTypes() ) { AttributeType atFromL1 = atMapL1.get( atFromL2.getOid() ); if ( atFromL1 == null ) { AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( null, atFromL2, DifferenceType.ADDED ); schemaDifference.addAttributeTypeDifference( attributeTypeDifference ); schemaDifference.setType( DifferenceType.MODIFIED ); } // If atFromL1 exists, then it has already been processed when looping on the first list. } // Building Maps for object classes Map<String, ObjectClass> ocMapL1 = new HashMap<String, ObjectClass>(); for ( ObjectClass oc : schemaFromL1.getObjectClasses() ) { ocMapL1.put( oc.getOid(), oc ); } Map<String, ObjectClass> ocMapL2 = new HashMap<String, ObjectClass>(); for ( ObjectClass oc : schemaFromL2.getObjectClasses() ) { ocMapL2.put( oc.getOid(), oc ); } // Looping on the object classes from the Schema from the first list for ( ObjectClass ocFromL1 : schemaFromL1.getObjectClasses() ) { ObjectClass ocFromL2 = ocMapL2.get( ocFromL1.getOid() ); if ( ocFromL2 == null ) { ObjectClassDifference objectClassDifference = new ObjectClassDifference( ocFromL1, null, DifferenceType.REMOVED ); schemaDifference.addObjectClassDifference( objectClassDifference ); schemaDifference.setType( DifferenceType.MODIFIED ); } else { ObjectClassDifference objectClassDifference = new ObjectClassDifference( ocFromL1, ocFromL2, DifferenceType.IDENTICAL ); schemaDifference.addObjectClassDifference( objectClassDifference ); List<PropertyDifference> ocDifferences = getDifferences( ocFromL1, ocFromL2 ); if ( ocDifferences.size() > 0 ) { objectClassDifference.setType( DifferenceType.MODIFIED ); objectClassDifference.addDifferences( ocDifferences ); schemaDifference.setType( DifferenceType.MODIFIED ); } } } // Looping on the object classes from the Schema from the second list for ( ObjectClass ocFromL2 : schemaFromL2.getObjectClasses() ) { ObjectClass ocFromL1 = ocMapL1.get( ocFromL2.getOid() ); if ( ocFromL1 == null ) { ObjectClassDifference objectClassDifference = new ObjectClassDifference( null, ocFromL2, DifferenceType.ADDED ); schemaDifference.addObjectClassDifference( objectClassDifference ); schemaDifference.setType( DifferenceType.MODIFIED ); } // If ocFromL1 exists, then it has already been processed when looping on the first list. } } } // Looping on schemas from the second list for ( Schema schemaFromL2 : l2 ) { Schema schemaFromL1 = mapL1.get( Strings.toLowerCase( schemaFromL2.getSchemaName() ) ); if ( schemaFromL1 == null ) { SchemaDifference schemaDifference = new SchemaDifference( null, schemaFromL2, DifferenceType.ADDED ); differences.add( schemaDifference ); // Adding attribute types for ( AttributeType at : schemaFromL2.getAttributeTypes() ) { schemaDifference.addAttributeTypeDifference( new AttributeTypeDifference( null, at, DifferenceType.ADDED ) ); } // Adding object classes for ( ObjectClass oc : schemaFromL2.getObjectClasses() ) { schemaDifference.addObjectClassDifference( new ObjectClassDifference( null, oc, DifferenceType.ADDED ) ); } } } return differences; } /** * Gets the differences between two ObjectClassImpl Objects. * * @param oc1 * the source ObjectClassImpl Object * @param oc2 * the destination ObjectClassImpl Object * @return * the differences between two ObjectClassImpl Objects. */ public static List<PropertyDifference> getDifferences( ObjectClass oc1, ObjectClass oc2 ) { List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); // Aliases differences.addAll( getAliasesDifferences( oc1, oc2 ) ); // Description PropertyDifference descriptionDifference = getDescriptionDifference( oc1, oc2 ); if ( descriptionDifference != null ) { differences.add( descriptionDifference ); } // Obsolete PropertyDifference obsoleteDifference = getObsoleteDifference( oc1, oc2 ); if ( obsoleteDifference != null ) { differences.add( obsoleteDifference ); } // Class type PropertyDifference classTypeDifference = getClassTypeDifference( oc1, oc2 ); if ( classTypeDifference != null ) { differences.add( classTypeDifference ); } // Superior classes differences.addAll( getSuperiorClassesDifferences( oc1, oc2 ) ); // Mandatory attribute types differences.addAll( getMandatoryAttributeTypesDifferences( oc1, oc2 ) ); // Optional attribute types differences.addAll( getOptionalAttributeTypesDifferences( oc1, oc2 ) ); return differences; } /** * Gets the differences between two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the differences between two AttributeType Objects. */ public static List<PropertyDifference> getDifferences( AttributeType at1, AttributeType at2 ) { List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); // Aliases differences.addAll( getAliasesDifferences( at1, at2 ) ); // Description PropertyDifference descriptionDifference = getDescriptionDifference( at1, at2 ); if ( descriptionDifference != null ) { differences.add( descriptionDifference ); } // Obsolete PropertyDifference obsoleteDifference = getObsoleteDifference( at1, at2 ); if ( obsoleteDifference != null ) { differences.add( obsoleteDifference ); } // Usage PropertyDifference usageDifference = getUsageDifference( at1, at2 ); if ( usageDifference != null ) { differences.add( usageDifference ); } // Superior PropertyDifference superiorDifference = getSuperiorDifference( at1, at2 ); if ( superiorDifference != null ) { differences.add( superiorDifference ); } // Syntax PropertyDifference syntaxDifference = getSyntaxDifference( at1, at2 ); if ( syntaxDifference != null ) { differences.add( syntaxDifference ); } // Syntax length PropertyDifference syntaxLengthDifference = getSyntaxLengthDifference( at1, at2 ); if ( syntaxLengthDifference != null ) { differences.add( syntaxLengthDifference ); } // Single value PropertyDifference singleValueDifference = getSingleValueDifference( at1, at2 ); if ( singleValueDifference != null ) { differences.add( singleValueDifference ); } // Collective PropertyDifference collectiveDifference = getCollectiveDifference( at1, at2 ); if ( collectiveDifference != null ) { differences.add( collectiveDifference ); } // No user modification PropertyDifference noUserModificationDifference = getNoUserModificationDifference( at1, at2 ); if ( noUserModificationDifference != null ) { differences.add( noUserModificationDifference ); } // Equality PropertyDifference equalityDifference = getEqualityDifference( at1, at2 ); if ( equalityDifference != null ) { differences.add( equalityDifference ); } // Ordering PropertyDifference orderingDifference = getOrderingDifference( at1, at2 ); if ( orderingDifference != null ) { differences.add( orderingDifference ); } // Substring PropertyDifference substringDifference = getSubstringDifference( at1, at2 ); if ( substringDifference != null ) { differences.add( substringDifference ); } return differences; } /** * Gets the 'Aliases' differences between the two SchemaObject Objects. * * @param so1 * the source SchemaObject Object * @param so2 * the destination SchemaObject Object * @return * the 'Aliases' differences between the two SchemaObject Objects */ private static List<PropertyDifference> getAliasesDifferences( SchemaObject so1, SchemaObject so2 ) { List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); List<String> so1Names = so1.getNames(); List<String> so2Names = so2.getNames(); for ( String name : so1Names ) { if ( !so2Names.contains( name ) ) { PropertyDifference diff = new AliasDifference( so1, so2, DifferenceType.REMOVED ); diff.setOldValue( name ); differences.add( diff ); } } for ( String name : so2Names ) { if ( !so1Names.contains( name ) ) { PropertyDifference diff = new AliasDifference( so1, so2, DifferenceType.ADDED ); diff.setNewValue( name ); differences.add( diff ); } } return differences; } /** * Gets the 'Description' difference between the two SchemaObject Objects. * * @param so1 * the source SchemaObject Object * @param so2 * the destination SchemaObject Object * @return * the 'Description' difference between the two SchemaObject Objects */ private static PropertyDifference getDescriptionDifference( SchemaObject so1, SchemaObject so2 ) { String so1Description = so1.getDescription(); String so2Description = so2.getDescription(); if ( ( so1Description == null ) && ( so2Description != null ) ) { PropertyDifference diff = new DescriptionDifference( so1, so2, DifferenceType.ADDED ); diff.setNewValue( so2Description ); return diff; } else if ( ( so1Description != null ) && ( so2Description == null ) ) { PropertyDifference diff = new DescriptionDifference( so1, so2, DifferenceType.REMOVED ); diff.setOldValue( so1Description ); return diff; } else if ( ( so1Description != null ) && ( so2Description != null ) ) { if ( !so1Description.equals( so2Description ) ) { PropertyDifference diff = new DescriptionDifference( so1, so2, DifferenceType.MODIFIED ); diff.setOldValue( so1Description ); diff.setNewValue( so2Description ); return diff; } } return null; } /** * Gets the 'Obsolete' difference between the two SchemaObject Objects. * * @param so1 * the source SchemaObject Object * @param so2 * the destination SchemaObject Object * @return * the 'Obsolete' difference between the two SchemaObject Objects */ private static PropertyDifference getObsoleteDifference( SchemaObject so1, SchemaObject so2 ) { boolean so1Obsolete = so1.isObsolete(); boolean so2Obsolete = so2.isObsolete(); if ( so1Obsolete != so2Obsolete ) { PropertyDifference diff = new ObsoleteDifference( so1, so2 ); diff.setOldValue( so1Obsolete ); diff.setNewValue( so2Obsolete ); return diff; } return null; } /** * Gets the 'Class type' difference between the two ObjectClassImpl Objects. * * @param oc1 * the source ObjectClassImpl Object * @param oc2 * the destination ObjectClassImpl Object * @return * the 'Class type' difference between the two ObjectClassImpl Objects */ private static PropertyDifference getClassTypeDifference( ObjectClass oc1, ObjectClass oc2 ) { ObjectClassTypeEnum oc1ClassType = oc1.getType(); ObjectClassTypeEnum oc2ClassType = oc2.getType(); if ( oc1ClassType != oc2ClassType ) { PropertyDifference diff = new ClassTypeDifference( oc1, oc2 ); diff.setOldValue( oc1ClassType ); diff.setNewValue( oc2ClassType ); return diff; } return null; } /** * Gets the 'Superior Classes' differences between the two ObjectClassImpl Objects. * * @param oc1 * the source ObjectClassImpl Object * @param oc2 * the destination ObjectClassImpl Object * @return * the 'Superior Classes' differences between the two ObjectClassImpl Objects */ private static List<PropertyDifference> getSuperiorClassesDifferences( ObjectClass oc1, ObjectClass oc2 ) { List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); List<String> oc1Sups = oc1.getSuperiorOids(); List<String> oc2Sups = oc2.getSuperiorOids(); for ( String name : oc1Sups ) { if ( !oc2Sups.contains( name ) ) { PropertyDifference diff = new SuperiorOCDifference( oc1, oc2, DifferenceType.REMOVED ); diff.setOldValue( name ); differences.add( diff ); } } for ( String name : oc2Sups ) { if ( !oc1Sups.contains( name ) ) { PropertyDifference diff = new SuperiorOCDifference( oc1, oc2, DifferenceType.ADDED ); diff.setNewValue( name ); differences.add( diff ); } } return differences; } /** * Gets the 'Mandatory attribute types' differences between the two ObjectClassImpl Objects. * * @param oc1 * the source ObjectClassImpl Object * @param oc2 * the destination ObjectClassImpl Object * @return * the 'Mandatory attribute types' differences between the two ObjectClassImpl Objects */ private static List<PropertyDifference> getMandatoryAttributeTypesDifferences( ObjectClass oc1, ObjectClass oc2 ) { List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); List<String> oc1Musts = oc1.getMustAttributeTypeOids(); List<String> oc2Musts = oc2.getMustAttributeTypeOids(); for ( String name : oc1Musts ) { if ( !oc2Musts.contains( name ) ) { PropertyDifference diff = new MandatoryATDifference( oc1, oc2, DifferenceType.REMOVED ); diff.setOldValue( name ); differences.add( diff ); } } for ( String name : oc2Musts ) { if ( !oc1Musts.contains( name ) ) { PropertyDifference diff = new MandatoryATDifference( oc1, oc2, DifferenceType.ADDED ); diff.setNewValue( name ); differences.add( diff ); } } return differences; } /** * Gets the 'Optional attribute types' differences between the two ObjectClassImpl Objects. * * @param oc1 * the source ObjectClassImpl Object * @param oc2 * the destination ObjectClassImpl Object * @return * the 'Optional attribute types' differences between the two ObjectClassImpl Objects */ private static List<PropertyDifference> getOptionalAttributeTypesDifferences( ObjectClass oc1, ObjectClass oc2 ) { List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); List<String> oc1Mays = oc1.getMayAttributeTypeOids(); List<String> oc2Mays = oc2.getMayAttributeTypeOids(); for ( String name : oc1Mays ) { if ( !oc2Mays.contains( name ) ) { PropertyDifference diff = new OptionalATDifference( oc1, oc2, DifferenceType.REMOVED ); diff.setOldValue( name ); differences.add( diff ); } } for ( String name : oc2Mays ) { if ( !oc1Mays.contains( name ) ) { PropertyDifference diff = new OptionalATDifference( oc1, oc2, DifferenceType.ADDED ); diff.setNewValue( name ); differences.add( diff ); } } return differences; } /** * Gets the 'Usage' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'Usage' difference between the two AttributeType Objects */ private static PropertyDifference getUsageDifference( AttributeType at1, AttributeType at2 ) { UsageEnum at1Usage = at1.getUsage(); UsageEnum at2Usage = at2.getUsage(); if ( at1Usage != at2Usage ) { PropertyDifference diff = new UsageDifference( at1, at2 ); diff.setOldValue( at1Usage ); diff.setNewValue( at2Usage ); return diff; } return null; } /** * Gets the 'Superior' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'Superior' difference between the two AttributeType Objects */ private static PropertyDifference getSuperiorDifference( AttributeType at1, AttributeType at2 ) { String at1Superior = at1.getSuperiorOid(); String at2Superior = at2.getSuperiorOid(); if ( ( at1Superior == null ) && ( at2Superior != null ) ) { PropertyDifference diff = new SuperiorATDifference( at1, at2, DifferenceType.ADDED ); diff.setNewValue( at2Superior ); return diff; } else if ( ( at1Superior != null ) && ( at2Superior == null ) ) { PropertyDifference diff = new SuperiorATDifference( at1, at2, DifferenceType.REMOVED ); diff.setOldValue( at1Superior ); return diff; } else if ( ( at1Superior != null ) && ( at2Superior != null ) ) { if ( !at1Superior.equals( at2Superior ) ) { PropertyDifference diff = new SuperiorATDifference( at1, at2, DifferenceType.MODIFIED ); diff.setOldValue( at1Superior ); diff.setNewValue( at2Superior ); return diff; } } return null; } /** * Gets the 'Syntax' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'Syntax' difference between the two AttributeType Objects */ private static PropertyDifference getSyntaxDifference( AttributeType at1, AttributeType at2 ) { String at1Syntax = at1.getSyntaxOid(); String at2Syntax = at2.getSyntaxOid(); if ( ( at1Syntax == null ) && ( at2Syntax != null ) ) { PropertyDifference diff = new SyntaxDifference( at1, at2, DifferenceType.ADDED ); diff.setNewValue( at2Syntax ); return diff; } else if ( ( at1Syntax != null ) && ( at2Syntax == null ) ) { PropertyDifference diff = new SyntaxDifference( at1, at2, DifferenceType.REMOVED ); diff.setOldValue( at1Syntax ); return diff; } else if ( ( at1Syntax != null ) && ( at2Syntax != null ) ) { if ( !at1Syntax.equals( at2Syntax ) ) { PropertyDifference diff = new SyntaxDifference( at1, at2, DifferenceType.MODIFIED ); diff.setOldValue( at1Syntax ); diff.setNewValue( at2Syntax ); return diff; } } return null; } /** * Gets the 'Syntax length' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'Syntax length' difference between the two AttributeType Objects */ private static PropertyDifference getSyntaxLengthDifference( AttributeType at1, AttributeType at2 ) { long at1SyntaxLength = at1.getSyntaxLength(); long at2SyntaxLength = at2.getSyntaxLength(); if ( ( at1SyntaxLength == 0 ) && ( at2SyntaxLength != 0 ) ) { PropertyDifference diff = new SyntaxLengthDifference( at1, at2, DifferenceType.ADDED ); diff.setNewValue( at2SyntaxLength ); return diff; } else if ( ( at1SyntaxLength != 0 ) && ( at2SyntaxLength == 0 ) ) { PropertyDifference diff = new SyntaxLengthDifference( at1, at2, DifferenceType.REMOVED ); diff.setOldValue( at1SyntaxLength ); return diff; } else if ( ( at1SyntaxLength != 0 ) && ( at2SyntaxLength != 0 ) ) { if ( at1SyntaxLength != at2SyntaxLength ) { PropertyDifference diff = new SyntaxLengthDifference( at1, at2, DifferenceType.MODIFIED ); diff.setOldValue( at1SyntaxLength ); diff.setNewValue( at2SyntaxLength ); return diff; } } return null; } /** * Gets the 'Single value' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'Single value' difference between the two AttributeType Objects */ private static PropertyDifference getSingleValueDifference( AttributeType at1, AttributeType at2 ) { boolean at1SingleValued = at1.isSingleValued(); boolean at2SingleValued = at2.isSingleValued(); if ( at1SingleValued != at2SingleValued ) { PropertyDifference diff = new SingleValueDifference( at1, at2 ); diff.setOldValue( at1SingleValued ); diff.setNewValue( at2SingleValued ); return diff; } return null; } /** * Gets the 'Collective' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'Collective' difference between the two AttributeType Objects */ private static PropertyDifference getCollectiveDifference( AttributeType at1, AttributeType at2 ) { boolean at1Collective = at1.isCollective(); boolean at2Collective = at2.isCollective(); if ( at1Collective != at2Collective ) { PropertyDifference diff = new CollectiveDifference( at1, at2 ); diff.setOldValue( at1Collective ); diff.setNewValue( at2Collective ); return diff; } return null; } /** * Gets the 'No user modification' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'No user modification' difference between the two AttributeType Objects */ private static PropertyDifference getNoUserModificationDifference( AttributeType at1, AttributeType at2 ) { boolean at1IsUserModifiable = at1.isUserModifiable(); boolean at2IsUserModifiable = at2.isUserModifiable(); if ( at1IsUserModifiable != at2IsUserModifiable ) { PropertyDifference diff = new NoUserModificationDifference( at1, at2 ); diff.setOldValue( at1IsUserModifiable ); diff.setNewValue( at2IsUserModifiable ); return diff; } return null; } /** * Gets the 'Equality' difference between the two AttributeType Objects. * * @param at1 * the source AttributeType Object * @param at2 * the destination AttributeType Object * @return * the 'Equality' difference between the two AttributeType Objects */ private static PropertyDifference getEqualityDifference( AttributeType at1, AttributeType at2 ) { String at1Equality = at1.getEqualityOid(); String at2Equality = at2.getEqualityOid(); if ( ( at1Equality == null ) && ( at2Equality != null ) ) { PropertyDifference diff = new EqualityDifference( at1, at2, DifferenceType.ADDED ); diff.setNewValue( at2Equality ); return diff; }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SubstringDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SubstringDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of substring. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SubstringDifference extends AbstractPropertyDifference { /** * Creates a new instance of SubstringDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public SubstringDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of SubstringDifference. * * @param source * the source Object * @param destination * the destination Object */ public SubstringDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/EqualityDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/EqualityDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents the difference of a added equality. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EqualityDifference extends AbstractPropertyDifference { /** * Creates a new instance of EqualityDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public EqualityDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of EqualityDifference. * * @param source * the source Object * @param destination * the destination Object */ public EqualityDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AbstractDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AbstractDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents the AbstractDifference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AbstractDifference implements Difference { /** The source Object */ private Object source; /** The destination Object */ private Object destination; /** The type of difference */ private DifferenceType type; /** * Creates a new instance of AbstractDifference. * * @param source * the source Object * @param destination * the destination Object */ public AbstractDifference( Object source, Object destination ) { this.source = source; this.destination = destination; } /** * Creates a new instance of AbstractDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public AbstractDifference( Object source, Object destination, DifferenceType type ) { this.source = source; this.destination = destination; this.type = type; } /** * {@inheritDoc} */ public Object getDestination() { return destination; } /** * {@inheritDoc} */ public void setDestination( Object destination ) { this.destination = destination; } /** * {@inheritDoc} */ public Object getSource() { return source; } /** * {@inheritDoc} */ public void setSource( Object source ) { this.source = source; } /** * {@inheritDoc} */ public DifferenceType getType() { return type; } /** * {@inheritDoc} */ public void setType( DifferenceType type ) { this.type = type; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/OptionalATDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/OptionalATDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of optional attribute type. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OptionalATDifference extends AbstractPropertyDifference { /** * Creates a new instance of OptionalATDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public OptionalATDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of OptionalATDifference. * * @param source * the source Object * @param destination * the destination Object */ public OptionalATDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SuperiorOCDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SuperiorOCDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of added superior object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SuperiorOCDifference extends AbstractPropertyDifference { /** * Creates a new instance of SuperiorOCDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public SuperiorOCDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of SuperiorOCDifference. * * @param source * the source Object * @param destination * the destination Object */ public SuperiorOCDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/Difference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/Difference.java
/* * 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.studio.schemaeditor.model.difference; /** * This interface defines a Difference between two objects. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface Difference { /** * Gets the source Object. * * @return * the source Object */ Object getSource(); /** * Sets the source Object. * * @param source * the source Object */ void setSource( Object source ); /** * Gets the destination Object. * * @return * the destination Object */ Object getDestination(); /** * Sets the destination Object. * * @param destination * the destination Object */ void setDestination( Object destination ); /** * Gets the type. * * @return * the type */ DifferenceType getType(); /** * Sets the type. * * @param type * the type */ void setType( DifferenceType type ); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/UsageDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/UsageDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of usage. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class UsageDifference extends AbstractPropertyDifference { /** * Creates a new instance of UsageDifference. * * @param source * the source Object * @param destination * the destination Object */ public UsageDifference( Object source, Object destination ) { super( source, destination, DifferenceType.MODIFIED ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AbstractPropertyDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AbstractPropertyDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This abstract class represents an Abstract Property Difference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractPropertyDifference extends AbstractDifference implements PropertyDifference { /** The old value*/ private Object oldValue; /** The new value */ private Object newValue; /** * Creates a new instance of AbstractPropertyDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public AbstractPropertyDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of AbstractPropertyDifference. * * @param source * the source Object * @param destination * the destination Object */ public AbstractPropertyDifference( Object source, Object destination ) { super( source, destination ); } /** * {@inheritDoc} */ public Object getNewValue() { return newValue; } /** * {@inheritDoc} */ public void setNewValue( Object newValue ) { this.newValue = newValue; } /** * {@inheritDoc} */ public Object getOldValue() { return oldValue; } /** * {@inheritDoc} */ public void setOldValue( Object oldValue ) { this.oldValue = oldValue; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/PropertyDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/PropertyDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This interface represents a property difference * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface PropertyDifference extends Difference { /** * Gets the old value. * * @return * the old value */ Object getOldValue(); /** * Sets the old value. * * @param oldValue * the old value */ void setOldValue( Object oldValue ); /** * Gets the new value. * * @return * the new value */ Object getNewValue(); /** * Sets the new value. * * @param newValue * the new value */ void setNewValue( Object newValue ); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SyntaxDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SyntaxDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of syntax. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SyntaxDifference extends AbstractPropertyDifference { /** * Creates a new instance of SyntaxDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public SyntaxDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of SyntaxDifference. * * @param source * the source Object * @param destination * the destination Object */ public SyntaxDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SuperiorATDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SuperiorATDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of superior attribute type. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SuperiorATDifference extends AbstractPropertyDifference { /** * Creates a new instance of SuperiorATDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public SuperiorATDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of SuperiorATDifference. * * @param source * the source Object * @param destination * the destination Object */ public SuperiorATDifference( Object source, Object destination ) { super( source, destination ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SchemaDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/SchemaDifference.java
/* * 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.studio.schemaeditor.model.difference; import java.util.ArrayList; import java.util.List; /** * This class represents a schema difference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaDifference extends AbstractDifference { /** The attribute types differences*/ private List<AttributeTypeDifference> attributeTypesDifferences = new ArrayList<AttributeTypeDifference>(); /** The object classes differences */ private List<ObjectClassDifference> objectClassesDifferences = new ArrayList<ObjectClassDifference>(); /** * Creates a new instance of AbstractSchemaDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public SchemaDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of AbstractSchemaDifference. * * @param source * the source Object * @param destination * the destination Object */ public SchemaDifference( Object source, Object destination ) { super( source, destination ); } /** * Gets the attribute types differences. * * @return * the attribute types differences */ public List<AttributeTypeDifference> getAttributeTypesDifferences() { return attributeTypesDifferences; } /** * Adds an attribute type difference. * * @param difference * the attribute type difference */ public void addAttributeTypeDifference( AttributeTypeDifference difference ) { attributeTypesDifferences.add( difference ); } /** * Removes an attribute type difference. * * @param difference * the attribute type difference */ public void removeAttributeTypeDifference( AttributeTypeDifference difference ) { attributeTypesDifferences.remove( difference ); } /** * Gets the object classes differences. * * @return * the object classes differences */ public List<ObjectClassDifference> getObjectClassesDifferences() { return objectClassesDifferences; } /** * Adds an object class difference. * * @param difference * the object class difference */ public void addObjectClassDifference( ObjectClassDifference difference ) { objectClassesDifferences.add( difference ); } /** * Removes an object class difference. * * @param difference * the object class difference */ public void removeObjectClassDifference( ObjectClassDifference difference ) { objectClassesDifferences.remove( difference ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AttributeTypeDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/AttributeTypeDifference.java
/* * 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.studio.schemaeditor.model.difference; import java.util.ArrayList; import java.util.List; /** * This class represents an attribute type difference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AttributeTypeDifference extends AbstractDifference { /** The differences */ private List<PropertyDifference> differences = new ArrayList<PropertyDifference>(); /** * Creates a new instance of AttributeTypeDifference. * * @param source * the source Object * @param destination * the destination Object * @param type * the type */ public AttributeTypeDifference( Object source, Object destination, DifferenceType type ) { super( source, destination, type ); } /** * Creates a new instance of AttributeTypeDifference. * * @param source * the source Object * @param destination * the destination Object */ public AttributeTypeDifference( Object source, Object destination ) { super( source, destination ); } /** * Gets the property differences. * * @return * the property differences */ public List<PropertyDifference> getDifferences() { return differences; } /** * Adds a difference. * * @param difference * the difference */ public void addDifference( PropertyDifference difference ) { differences.add( difference ); } /** * Adds differences. * * @param differences * the differences */ public void addDifferences( List<PropertyDifference> differences ) { this.differences.addAll( differences ); } /** * Removes a difference. * * @param difference * the difference */ public void removeDifference( PropertyDifference difference ) { differences.remove( difference ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/ObsoleteDifference.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/difference/ObsoleteDifference.java
/* * 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.studio.schemaeditor.model.difference; /** * This class represents a difference of obsolete value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ObsoleteDifference extends AbstractPropertyDifference { /** * Creates a new instance of ObsoleteDifference. * * @param source * the source Object * @param destination * the destination Object */ public ObsoleteDifference( Object source, Object destination ) { super( source, destination, DifferenceType.MODIFIED ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/NoAliasWarning.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/NoAliasWarning.java
/* * 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.studio.schemaeditor.model.schemachecker; import org.apache.directory.api.ldap.model.schema.SchemaObject; /** * This class represents the NoAliasWarning. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NoAliasWarning implements SchemaWarning { /** The source object */ private SchemaObject source; /** * Creates a new instance of NoAliasWarning. * * @param source * the source object */ public NoAliasWarning( SchemaObject source ) { this.source = source; } /** * {@inheritDoc} */ public SchemaObject getSource() { return source; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaWarning.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaWarning.java
/* * 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.studio.schemaeditor.model.schemachecker; import org.apache.directory.api.ldap.model.schema.SchemaObject; /** * This interface defines a schema warning. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface SchemaWarning { /** * Gets the source object. * * @return the source object */ SchemaObject getSource(); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerListener.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerListener.java
/* * 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.studio.schemaeditor.model.schemachecker; /** * Classes which implement this interface provide methods that deal with the * events that are generated when an event occurrs on the SchemaChecker. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface SchemaCheckerListener { /** * This methods is called when the SchemaChecker is updated. */ void schemaCheckerUpdated(); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java
/* * 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.studio.schemaeditor.model.schemachecker; import java.util.ArrayList; import java.util.List; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.directory.api.ldap.model.exception.LdapSchemaException; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaManager; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.controller.ProjectsHandlerAdapter; import org.apache.directory.studio.schemaeditor.controller.SchemaHandler; import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerAdapter; import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.model.Schema; import org.apache.directory.studio.schemaeditor.model.schemamanager.SchemaEditorSchemaLoader; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; /** * This class represents the SchemaChecker. * <p> * It is used to check the schema integrity. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaChecker { /** The SchemaChecker instance */ private static SchemaChecker instance; /** The schema manager */ private SchemaManager schemaManager; /** The errors map */ private MultiValuedMap<Object, Object> errorsMap = new ArrayListValuedHashMap<>(); /** The warnings list */ private List<SchemaWarning> warningsList = new ArrayList<SchemaWarning>(); /** The warnings map */ private MultiValuedMap<Object, Object> warningsMap = new ArrayListValuedHashMap<>(); /** The lock object used to synchronize accesses to the errors and warnings maps*/ private static Object lock = new Object(); /** The 'listening to modifications' flag*/ private boolean listeningToModifications = false; /** The listeners List */ private List<SchemaCheckerListener> listeners = new ArrayList<SchemaCheckerListener>(); /** The SchemaHandlerListener */ private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter() { public void attributeTypeAdded( AttributeType at ) { synchronized ( this ) { recheckWholeSchema(); } } public void attributeTypeModified( AttributeType at ) { synchronized ( this ) { recheckWholeSchema(); } } public void attributeTypeRemoved( AttributeType at ) { synchronized ( this ) { recheckWholeSchema(); } } public void objectClassAdded( ObjectClass oc ) { synchronized ( this ) { recheckWholeSchema(); } } public void objectClassModified( ObjectClass oc ) { synchronized ( this ) { recheckWholeSchema(); } } public void objectClassRemoved( ObjectClass oc ) { synchronized ( this ) { recheckWholeSchema(); } } public void schemaAdded( Schema schema ) { synchronized ( this ) { recheckWholeSchema(); } } public void schemaRemoved( Schema schema ) { synchronized ( this ) { recheckWholeSchema(); } } public void schemaRenamed( Schema schema ) { // Nothing to do, this is a simple renaming } }; /** * Creates a new instance of SchemaChecker. */ private SchemaChecker() { Activator.getDefault().getProjectsHandler().addListener( new ProjectsHandlerAdapter() { public void openProjectChanged( Project oldProject, Project newProject ) { if ( oldProject != null ) { oldProject.getSchemaHandler().removeListener( schemaHandlerListener ); } if ( newProject != null ) { newProject.getSchemaHandler().addListener( schemaHandlerListener ); } } } ); } /** * Gets the singleton instance of the ProjectsHandler. * * @return * the singleton instance of the ProjectsHandler */ public static SchemaChecker getInstance() { if ( instance == null ) { instance = new SchemaChecker(); } return instance; } /** * Enables modifications listening. */ public void enableModificationsListening() { synchronized ( this ) { if ( !listeningToModifications ) { Activator.getDefault().getSchemaHandler().addListener( schemaHandlerListener ); listeningToModifications = true; recheckWholeSchema(); } } } /** * Disables modifications listening. */ public void disableModificationsListening() { synchronized ( this ) { if ( listeningToModifications ) { Activator.getDefault().getSchemaHandler().removeListener( schemaHandlerListener ); listeningToModifications = false; } } } /** * Reloads the content of the schema checker */ public void reload() { synchronized ( this ) { recheckWholeSchema(); } } /** * Returns true if the SchemaChecker is listening to modifications, * false if not. * * @return * true if the SchemaChecker is listening to modifications, * false if not */ public boolean isListeningToModifications() { return listeningToModifications; } /** * Checks the whole schema. */ private void recheckWholeSchema() { Job job = new Job( "Checking Schema" ) { protected IStatus run( IProgressMonitor monitor ) { // Checks the whole schema via the schema manager try { schemaManager = new DefaultSchemaManager( new SchemaEditorSchemaLoader() ); schemaManager.loadAllEnabled(); } catch ( Exception e ) { // TODO Auto-generated catch block e.printStackTrace(); } // Updates errors and warnings updateErrorsAndWarnings(); // Notify listeners notifyListeners(); monitor.done(); return Status.OK_STATUS; } }; job.schedule(); } /** * Updates the errors and warnings. */ private synchronized void updateErrorsAndWarnings() { synchronized ( lock ) { // Errors errorsMap.clear(); indexErrors(); // Warnings createWarnings(); warningsMap.clear(); indexWarnings(); } } /** * Indexes the errors. */ private void indexErrors() { for ( Throwable error : schemaManager.getErrors() ) { if ( error instanceof LdapSchemaException ) { LdapSchemaException ldapSchemaException = ( LdapSchemaException ) error; SchemaObject source = ldapSchemaException.getSourceObject(); if ( source != null ) { SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler(); if ( source instanceof AttributeType ) { source = schemaHandler.getAttributeType( source.getOid() ); } else if ( source instanceof LdapSyntax ) { source = schemaHandler.getSyntax( source.getOid() ); } else if ( source instanceof MatchingRule ) { source = schemaHandler.getMatchingRule( source.getOid() ); } else if ( source instanceof ObjectClass ) { source = schemaHandler.getObjectClass( source.getOid() ); } errorsMap.put( source, ldapSchemaException ); } } } } /** * Creates the warnings. */ private void createWarnings() { // Clearing previous warnings warningsList.clear(); // Getting the schema handler to check for schema objects without names (aliases) SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler(); if ( schemaHandler != null ) { // Checking attribute types for ( AttributeType attributeType : schemaHandler.getAttributeTypes() ) { checkSchemaObjectNames( attributeType ); } // Checking object classes for ( ObjectClass objectClass : schemaHandler.getObjectClasses() ) { checkSchemaObjectNames( objectClass ); } } } /** * Checks the names of the given schema object. * * @param schemaObject the schema object to check */ private void checkSchemaObjectNames( SchemaObject schemaObject ) { if ( ( schemaObject.getNames() == null ) || ( schemaObject.getNames().size() == 0 ) ) { warningsList.add( new NoAliasWarning( schemaObject ) ); } } /** * Indexes the warnings. */ private void indexWarnings() { for ( SchemaWarning warning : warningsList ) { warningsMap.put( warning.getSource(), warning ); } } /** * Gets the errors. * * @return * the errors */ public List<Throwable> getErrors() { if ( schemaManager != null ) { return schemaManager.getErrors(); } else { return new ArrayList<Throwable>(); } } /** * Gets the warnings. * * @return * the warnings */ public List<SchemaWarning> getWarnings() { synchronized ( lock ) { return warningsList; } } /** * Adds a SchemaCheckerListener. * * @param listener * the listener */ public void addListener( SchemaCheckerListener listener ) { if ( !listeners.contains( listener ) ) { listeners.add( listener ); } } /** * Removes a SchemaCheckerListener. * * @param listener * the listener */ public void removeListener( SchemaCheckerListener listener ) { listeners.remove( listener ); } /** * Notifies the listeners. */ private void notifyListeners() { for ( SchemaCheckerListener listener : listeners ) { listener.schemaCheckerUpdated(); } } /** * Gets the errors associated with the given Schema Object * * @param so * the Schema Object * @return * the associated errors */ public List<?> getErrors( SchemaObject so ) { synchronized ( lock ) { return ( List<?> ) errorsMap.get( so ); } } /** * Returns whether the given Schema Object has errors. * * @param so * the Schema Object * @return * true if the given Schema Object has errors. */ public boolean hasErrors( SchemaObject so ) { List<?> errors = getErrors( so ); if ( errors == null ) { return false; } else { return errors.size() > 0; } } /** * Gets the warnings associated with the given Schema Object * * @param so * the Schema Object * @return * the associated warnings */ @SuppressWarnings("unchecked") public List<Object> getWarnings( SchemaObject so ) { return ( List<Object> ) warningsMap.get( so ); } /** * Returns whether the given Schema Object has warnings. * * @param so * the Schema Object * @return * true if the given Schema Object has errors. */ public boolean hasWarnings( SchemaObject so ) { List<?> warnings = getWarnings( so ); if ( warnings == null ) { return false; } else { return warnings.size() > 0; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasesStringToken.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasesStringToken.java
/* * 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.studio.schemaeditor.model.alias; public class AliasesStringToken implements Comparable<AliasesStringToken> { /** The token identifier for the start */ public static final int START = Integer.MIN_VALUE; /** The token identifier for end of file */ public static final int EOF = -1; /** The token identifier for a whitespace */ public static final int WHITESPACE = 0; /** The token identifier for a comma ',' */ public static final int COMMA = 1; /** The token identifier for an alias */ public static final int ALIAS = 2; /** The token identifier for an error at the start of an alias */ public static final int ERROR_ALIAS_START = 3; /** The token identifier for an error in a part (not the first character) of an alias */ public static final int ERROR_ALIAS_PART = 4; /** The token identifier for the substring following an error in an alias */ public static final int ERROR_ALIAS_SUBSTRING = 5; /** The offset. */ private int offset; /** The type. */ private int type; /** The value. */ private String value; /** * Creates a new instance of LdapFilterToken. * * @param type the type * @param value the value * @param offset the offset */ public AliasesStringToken( int type, String value, int offset ) { this.type = type; this.value = value; this.offset = offset; } /** * Returns the start position of the token in the original filter * * @return the start positon of the token */ public int getOffset() { return offset; } /** * Returns the length of the token in the original filter * * @return the length of the token */ public int getLength() { return value.length(); } /** * Gets the token type. * * @return the token type */ public int getType() { return type; } /** * Gets the value of the token in the original filter. * * @return the value of the token */ public String getValue() { return value; } /** * @see java.lang.Object#toString() */ public String toString() { return "(" + offset + ") " + "(" + type + ") " + value; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } /** * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo( AliasesStringToken o ) { if ( o instanceof AliasesStringToken ) { AliasesStringToken token = ( AliasesStringToken ) o; return this.offset - token.offset; } else { throw new ClassCastException( "Not instanceof AliasesToken: " + o.getClass().getName() ); //$NON-NLS-1$ } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/DefaultAlias.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/DefaultAlias.java
/* * 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.studio.schemaeditor.model.alias; /** * This class defines an {@link Alias}. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DefaultAlias extends AbstractAlias { /** * Creates a new instance of DefaultAlias. * * @param alias * the alias */ public DefaultAlias( String alias ) { super( alias ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasWithError.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasWithError.java
/* * 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.studio.schemaeditor.model.alias; /** * This interface defines an {@link Alias} with error. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface AliasWithError extends Alias { /** * Gets the error character. * * @return * the error character */ char getErrorChar(); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasesStringScanner.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasesStringScanner.java
/* * 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.studio.schemaeditor.model.alias; public class AliasesStringScanner { private static final char CHAR_COMMA = ','; private static final char CHAR_EOF = '\u0000'; /** The aliases to scan */ private String aliases; /** The current position */ private int pos; /** The last token type. */ private int lastTokenType; /** * Creates a new instance of LdapFilterScanner. */ public AliasesStringScanner() { super(); aliases = ""; //$NON-NLS-1$ } /** * Resets this scanner. * * @param aliases the new aliases to scan */ public void reset( String aliases ) { this.aliases = aliases; pos = -1; lastTokenType = AliasesStringToken.START; } /** * Gets the character at the current position. * * @return the character at the current position */ private char currentChar() { return 0 <= pos && pos < aliases.length() ? aliases.charAt( pos ) : CHAR_EOF; } /** * Increments the position counter and gets * the character at that positon. * * @return the character at the next position */ private char nextChar() { pos++; return currentChar(); } /** * Decrements the position counter and gets * the character at that positon. * * @return the character at the previous position */ private char prevChar() { pos--; return currentChar(); } /** * Gets the next token. * * @return the next token */ public AliasesStringToken nextToken() { char c; // check for EOF c = nextChar(); if ( c == CHAR_EOF ) { lastTokenType = AliasesStringToken.EOF; return new AliasesStringToken( lastTokenType, "", pos ); //$NON-NLS-1$ } prevChar(); // check the substring if there was an error c = nextChar(); if ( lastTokenType == AliasesStringToken.ERROR_ALIAS_PART || lastTokenType == AliasesStringToken.ERROR_ALIAS_START ) { StringBuffer sb = new StringBuffer(); while ( c != CHAR_COMMA && c != CHAR_EOF ) { sb.append( c ); c = nextChar(); } lastTokenType = AliasesStringToken.ERROR_ALIAS_SUBSTRING; return new AliasesStringToken( lastTokenType, sb.toString(), pos - sb.length() + 1 ); } prevChar(); // check for ignorable whitespaces c = nextChar(); if ( Character.isWhitespace( c ) ) { StringBuffer sb = new StringBuffer(); while ( Character.isWhitespace( c ) ) { sb.append( c ); c = nextChar(); } prevChar(); lastTokenType = AliasesStringToken.WHITESPACE; return new AliasesStringToken( lastTokenType, sb.toString(), pos - sb.length() + 1 ); } prevChar(); // check special characters c = nextChar(); if ( c == CHAR_COMMA ) { lastTokenType = AliasesStringToken.COMMA; return new AliasesStringToken( lastTokenType, ",", pos ); //$NON-NLS-1$ } prevChar(); // check Alias c = nextChar(); if ( isAliasSafeCharStart( c ) ) { StringBuffer sb = new StringBuffer(); boolean hasError = false; sb.append( c ); c = nextChar(); while ( c != CHAR_COMMA && c != CHAR_EOF ) { sb.append( c ); if ( !isAliasSafeCharPart( c ) ) { hasError = true; break; } c = nextChar(); } if ( hasError ) { lastTokenType = AliasesStringToken.ERROR_ALIAS_PART; return new AliasesStringToken( lastTokenType, sb.toString(), pos - sb.length() + 1 ); } else { prevChar(); lastTokenType = AliasesStringToken.ALIAS; return new AliasesStringToken( lastTokenType, sb.toString(), pos - sb.length() + 1 ); } } else { lastTokenType = AliasesStringToken.ERROR_ALIAS_START; return new AliasesStringToken( lastTokenType, c + "", pos ); //$NON-NLS-1$ } } /** * Determines if the specified character is * permissible as the first character in an attribute type or object class * alias. * <p> * A character may start an attribute type or object class alias if and * only if one of the following conditions is true: * <ul> * <li> it is a letter between 'a' to 'z' and between 'A' to 'Z' * </ul> * * <p><b>Note:</b> This method cannot handle <a * href="#supplementary"> supplementary characters</a>. To support * all Unicode characters, including supplementary characters, use * the {@link #isJavaIdentifierStart(int)} method. * * @param c the character to be tested. * @return <code>true</code> if the character may start an attribute type * or object class alias.; <code>false</code> otherwise. */ private boolean isAliasSafeCharStart( char c ) { return ( c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || c == 'y' || c == 'z' || c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == 'K' || c == 'L' || c == 'M' || c == 'N' || c == 'O' || c == 'P' || c == 'Q' || c == 'R' || c == 'S' || c == 'T' || c == 'U' || c == 'V' || c == 'W' || c == 'X' || c == 'Y' || c == 'Z' ); } /** * Determines if the specified character may be part of an attribute type or * object class alias as other than the first character. * <p> * A character may be part of an attribute type or object class alias if any * of the following are true: * <ul> * <li> it is a letter between 'a' to 'z' and between 'A' to 'Z' * <li> it is a digit * <li> it is a hyphen ('-') * <li> it is a semi-colon (';') * </ul> * * @param c the character to be tested. * @return <code>true</code> if the character may be part of an attribute * type or object class alias; <code>false</code> otherwise. */ private boolean isAliasSafeCharPart( char c ) { return ( c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || c == 'y' || c == 'z' || c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == 'K' || c == 'L' || c == 'M' || c == 'N' || c == 'O' || c == 'P' || c == 'Q' || c == 'R' || c == 'S' || c == 'T' || c == 'U' || c == 'V' || c == 'W' || c == 'X' || c == 'Y' || c == 'Z' || c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '-' ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasWithPartError.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasWithPartError.java
/* * 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.studio.schemaeditor.model.alias; /** * This class defines an {@link AliasWithError} with an error on the non first * character of the alias. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AliasWithPartError extends AbstractAliasWithError { /** * Creates a new instance of AliasWithPartError. * * @param alias * the alias * @param errorChar * the error character */ public AliasWithPartError( String alias, char errorChar ) { super( alias, errorChar ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasWithStartError.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasWithStartError.java
/* * 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.studio.schemaeditor.model.alias; /** * This class defines an {@link AliasWithError} with an error on the first * character of the alias. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AliasWithStartError extends AbstractAliasWithError { /** * Creates a new instance of AliasWithStartError. * * @param alias * the alias * @param errorChar * the error character */ public AliasWithStartError( String alias, char errorChar ) { super( alias, errorChar ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/Alias.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/Alias.java
/* * 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.studio.schemaeditor.model.alias; /** * This interface defines an {@link Alias}. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface Alias { /** * Gets the alias. * * @return * the alias */ String getAlias(); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AbstractAlias.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AbstractAlias.java
/* * 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.studio.schemaeditor.model.alias; /** * Abstract class for the {@link Alias} interface. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractAlias implements Alias { /** The alias */ private String alias; /** * Creates a new instance of AbstractAlias. * * @param alias * the alias */ public AbstractAlias( String alias ) { this.alias = alias; } /** * {@inheritDoc} */ public String getAlias() { return alias; } /** * {@inheritDoc} */ public String toString() { return alias; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AbstractAliasWithError.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AbstractAliasWithError.java
/* * 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.studio.schemaeditor.model.alias; /** * Abstract class for the {@link AliasWithError} interface. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractAliasWithError extends AbstractAlias implements AliasWithError { /** The error character */ private char errorChar; /** * Creates a new instance of AbstractAliasWithError. * * @param alias * the alias * @param errorChar * the error character */ public AbstractAliasWithError( String alias, char errorChar ) { super( alias ); this.errorChar = errorChar; } /** * {@inheritDoc} */ public char getErrorChar() { return errorChar; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasesStringParser.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/alias/AliasesStringParser.java
/* * 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.studio.schemaeditor.model.alias; import java.util.ArrayList; import java.util.List; /** * The AliasesParser implements a parser for Aliases {@link String}. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AliasesStringParser { /** The scanner */ private AliasesStringScanner scanner; /** The parsed aliases */ private List<Alias> aliases; /** * Creates a new instance of LdapFilterParser. */ public AliasesStringParser() { this.scanner = new AliasesStringScanner(); this.aliases = new ArrayList<Alias>(); } /** * Gets the parsed aliases. * * @return the parsed aliases */ public List<Alias> getAliases() { return aliases; } /** * Parses the given aliases String. * * @param str the aliases String */ public void parse( String str ) { // reset state aliases.clear(); scanner.reset( str ); // handle error tokens before filter AliasesStringToken token = scanner.nextToken(); // loop till aliases end or EOF do { switch ( token.getType() ) { case AliasesStringToken.ALIAS: { aliases.add( new DefaultAlias( token.getValue() ) ); break; } case AliasesStringToken.ERROR_ALIAS_START: { String previousTokenValue = token.getValue(); token = scanner.nextToken(); if ( token.getType() == AliasesStringToken.ERROR_ALIAS_SUBSTRING ) { aliases.add( new AliasWithStartError( previousTokenValue + token.getValue(), previousTokenValue .charAt( 0 ) ) ); break; } else { aliases.add( new AliasWithStartError( previousTokenValue, previousTokenValue.charAt( 0 ) ) ); continue; } } case AliasesStringToken.ERROR_ALIAS_PART: { String previousTokenValue = token.getValue(); token = scanner.nextToken(); if ( token.getType() == AliasesStringToken.ERROR_ALIAS_SUBSTRING ) { aliases.add( new AliasWithPartError( previousTokenValue + token.getValue(), previousTokenValue .charAt( previousTokenValue.length() - 1 ) ) ); break; } else { aliases.add( new AliasWithPartError( previousTokenValue, previousTokenValue .charAt( previousTokenValue.length() - 1 ) ) ); continue; } } default: { break; } } // next token token = scanner.nextToken(); } while ( token.getType() != AliasesStringToken.EOF ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/hierarchy/RootObject.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/hierarchy/RootObject.java
/* * 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.studio.schemaeditor.model.hierarchy; class RootObject { }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/hierarchy/HierarchyManager.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/hierarchy/HierarchyManager.java
/* * 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.studio.schemaeditor.model.hierarchy; import java.util.List; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.controller.SchemaHandler; import org.apache.directory.studio.schemaeditor.model.Schema; /** * This class represents the HierarchyManager. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class HierarchyManager { /** The parents map is used to store for each element its parents */ private MultiValuedMap<Object, Object> parentsMap; /** The parents map is used to store for each element its children */ private MultiValuedMap<Object, Object> childrenMap; /** The SchemaHandler */ private SchemaHandler schemaHandler; /** The RootObject of the Hierarchy */ private RootObject root; /** * Creates a new instance of HierarchyManager. */ public HierarchyManager() { // Initializing the maps parentsMap = new ArrayListValuedHashMap<>(); childrenMap = new ArrayListValuedHashMap<>(); // Getting the SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler(); // Loading the complete Schema loadSchema(); } /** * Adds an attribute type. * * @param at * the attribute type */ private void addAttributeType( AttributeType at ) { // Checking Aliases and OID checkAliasesAndOID( at ); String superiorName = at.getSuperiorOid(); if ( superiorName != null ) // The attribute type has a superior { AttributeType superior = schemaHandler.getAttributeType( superiorName ); if ( superior != null ) // The superior attribute type object exists { parentsMap.put( at, superior ); childrenMap.put( superior, at ); } else // The superior attribute type object does not exist { // Then, its parent is the name of its superior and // it becomes the children of it and the RootObject parentsMap.put( at, Strings.toLowerCase( superiorName ) ); childrenMap.put( Strings.toLowerCase( superiorName ), at ); childrenMap.put( root, at ); } } else // The attribute type does not have a superior { // Then, its parent is the RootObject parentsMap.put( at, root ); childrenMap.put( root, at ); } } /** * Adds an object class. * * @param oc * the object class */ private void addObjectClass( ObjectClass oc ) { // Checking Aliases and OID checkAliasesAndOID( oc ); List<String> superClasseNames = oc.getSuperiorOids(); if ( ( superClasseNames != null ) && ( superClasseNames.size() > 0 ) ) // The object class has one or more superiors { for ( String superClassName : superClasseNames ) { ObjectClass superClass = schemaHandler.getObjectClass( superClassName ); if ( superClass == null ) { parentsMap.put( oc, Strings.toLowerCase( superClassName ) ); childrenMap.put( Strings.toLowerCase( superClassName ), oc ); childrenMap.put( root, oc ); } else { parentsMap.put( oc, superClass ); childrenMap.put( superClass, oc ); } } } else // The object class does not have any declared superior // Then, it is a child of the "top (2.5.6.0)" object class // (Unless it is the "top (2.5.6.0)" object class itself) { ObjectClass topOC = schemaHandler.getObjectClass( "2.5.6.0" ); //$NON-NLS-1$ if ( oc.equals( topOC ) ) // The given object class is the "top (2.5.6.0)" object class { parentsMap.put( oc, root ); childrenMap.put( root, oc ); } else { if ( topOC != null ) // The "top (2.5.6.0)" object class exists { parentsMap.put( oc, topOC ); childrenMap.put( topOC, oc ); } else // The "top (2.5.6.0)" object class does not exist { parentsMap.put( oc, "2.5.6.0" ); //$NON-NLS-1$ childrenMap.put( "2.5.6.0", oc ); //$NON-NLS-1$ childrenMap.put( root, oc ); } } } } /** * This method is called when an attribute type is added. * * @param at * the added attribute type */ public void attributeTypeAdded( AttributeType at ) { addAttributeType( at ); } /** * This method is called when an attribute type is modified. * * @param at * the modified attribute type */ public void attributeTypeModified( AttributeType at ) { // Removing the attribute type List<Object> parents = getParents( at ); if ( parents != null ) { for ( Object parent : parents ) { childrenMap.removeMapping( parent, at ); } parentsMap.remove( at ); } // Adding the attribute type again addAttributeType( at ); } /** * This method is called when an attribute type is removed. * * @param at * the removed attribute type */ public void attributeTypeRemoved( AttributeType at ) { removeAttributeType( at ); } /** * Checks the Aliases and OID of an attribute type or an object class. * * @param object * an attribute type or an object class. */ private void checkAliasesAndOID( SchemaObject object ) { // Aliases List<String> aliases = object.getNames(); if ( aliases != null ) { for ( String alias : aliases ) { // Looking for children objects for this alias value @SuppressWarnings("unchecked") List<Object> children = ( List<Object> ) childrenMap.get( Strings.toLowerCase( alias ) ); if ( children != null ) { for ( Object value : children ) { childrenMap.put( object, value ); parentsMap.removeMapping( value, Strings.toLowerCase( alias ) ); parentsMap.put( value, object ); } childrenMap.remove( Strings.toLowerCase( alias ) ); } } } // OID String oid = object.getOid(); if ( oid != null ) { // Looking for children objects for this OID value @SuppressWarnings("unchecked") List<Object> children = ( List<Object> ) childrenMap.get( Strings.toLowerCase( oid ) ); if ( children != null ) { for ( Object value : children ) { childrenMap.put( object, value ); if ( oid.equals( "2.5.6.0" ) ) //$NON-NLS-1$ { childrenMap.removeMapping( root, value ); } parentsMap.removeMapping( value, Strings.toLowerCase( oid ) ); parentsMap.put( value, object ); } childrenMap.remove( Strings.toLowerCase( oid ) ); } } } /** * Gets the children of the given object. * * @param o * the object * @return * the children of the given object */ @SuppressWarnings("unchecked") public List<Object> getChildren( Object o ) { return ( List<Object> ) childrenMap.get( o ); } /** * Gets the parents of the given object. * * @param o * the object * @return * the parents of the given object */ @SuppressWarnings("unchecked") public List<Object> getParents( Object o ) { return ( List<Object> ) parentsMap.get( o ); } /** * Gets the RootObject of the Hierarchy. * * @return * the RootObject of the Hierarchy */ public RootObject getRootObject() { return root; } /** * Loads the Schema. */ private void loadSchema() { if ( schemaHandler != null ) { // Creating the root element root = new RootObject(); // Looping on the schemas for ( Schema schema : schemaHandler.getSchemas() ) { // Looping on the attribute types for ( AttributeType at : schema.getAttributeTypes() ) { addAttributeType( at ); } // Looping on the object classes for ( ObjectClass oc : schema.getObjectClasses() ) { addObjectClass( oc ); } } } } /** * This method is called when an object class is added. * * @param oc * the added object class */ public void objectClassAdded( ObjectClass oc ) { addObjectClass( oc ); } /** * This method is called when an object class is modified. * * @param oc * the modified object class */ public void objectClassModified( ObjectClass oc ) { // Removing the object class type List<Object> parents = getParents( oc ); if ( parents != null ) { for ( Object parent : parents ) { childrenMap.removeMapping( parent, oc ); } parentsMap.remove( oc ); } // Adding the object class again addObjectClass( oc ); } /** * This method is called when an object class is removed. * * @param oc * the removed object class */ public void objectClassRemoved( ObjectClass oc ) { removeObjectClass( oc ); } /** * Removes an attribute type. * * @param at * the attribute type */ private void removeAttributeType( AttributeType at ) { // Removing the attribute type as child of its superior String superiorName = at.getSuperiorOid(); if ( ( superiorName != null ) && ( !"".equals( superiorName ) ) ) //$NON-NLS-1$ { AttributeType superiorAT = schemaHandler.getAttributeType( superiorName ); if ( superiorAT == null ) { childrenMap.removeMapping( Strings.toLowerCase( superiorName ), at ); } else { childrenMap.removeMapping( superiorAT, at ); } } else { childrenMap.removeMapping( root, at ); } // Attaching each child (if there are children) to the RootObject List<Object> children = getChildren( at ); if ( children != null ) { for ( Object child : children ) { AttributeType childAT = ( AttributeType ) child; parentsMap.removeMapping( child, at ); parentsMap.put( child, root ); childrenMap.put( root, child ); String childSuperiorName = childAT.getSuperiorOid(); if ( ( childSuperiorName != null ) && ( !"".equals( childSuperiorName ) ) ) //$NON-NLS-1$ { parentsMap.put( child, Strings.toLowerCase( childSuperiorName ) ); childrenMap.put( Strings.toLowerCase( childSuperiorName ), child ); } } } childrenMap.remove( at ); parentsMap.remove( at ); } private void removeObjectClass( ObjectClass oc ) { // Removing the object class as child of its superiors List<String> superClassesNames = oc.getSuperiorOids(); if ( ( superClassesNames != null ) && ( superClassesNames.size() > 0 ) ) { for ( String superClassName : superClassesNames ) { if ( !"".equals( superClassName ) ) //$NON-NLS-1$ { ObjectClass superClassOC = schemaHandler.getObjectClass( superClassName ); if ( superClassOC == null ) { childrenMap.removeMapping( Strings.toLowerCase( superClassName ), oc ); childrenMap.removeMapping( root, oc ); } else { childrenMap.removeMapping( superClassOC, oc ); } } } } else { if ( oc.getOid().equals( "2.5.6.0" ) ) //$NON-NLS-1$ // The given object class is the "top (2.5.6.0)" object class { childrenMap.removeMapping( root, oc ); } else { ObjectClass topOC = schemaHandler.getObjectClass( "2.5.6.0" ); //$NON-NLS-1$ if ( topOC != null ) // The "top (2.5.6.0)" object class exists { childrenMap.removeMapping( topOC, oc ); } else // The "top (2.5.6.0)" object class does not exist { childrenMap.removeMapping( "2.5.6.0", oc ); //$NON-NLS-1$ } } } // Attaching each child (if there are children) to the RootObject List<Object> children = getChildren( oc ); if ( children != null ) { for ( Object child : children ) { ObjectClass childOC = ( ObjectClass ) child; parentsMap.removeMapping( child, oc ); parentsMap.put( child, root ); childrenMap.put( root, child ); List<String> childSuperClassesNames = childOC.getSuperiorOids(); if ( ( childSuperClassesNames != null ) && ( childSuperClassesNames.size() > 0 ) ) { String correctSuperClassName = getCorrectSuperClassName( oc, childSuperClassesNames ); if ( correctSuperClassName != null ) { parentsMap.put( child, Strings.toLowerCase( correctSuperClassName ) ); childrenMap.put( Strings.toLowerCase( correctSuperClassName ), child ); } } else { parentsMap.put( child, "2.5.6.0" ); //$NON-NLS-1$ childrenMap.put( "2.5.6.0", child ); //$NON-NLS-1$ } } } childrenMap.remove( oc ); parentsMap.remove( oc ); } private String getCorrectSuperClassName( ObjectClass oc, List<String> childSuperClassesNames ) { if ( childSuperClassesNames != null ) { List<String> aliases = oc.getNames(); if ( aliases != null ) { for ( String childSuperClassName : childSuperClassesNames ) { if ( aliases.contains( childSuperClassName ) ) { return childSuperClassName; } } } } // Default return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/hierarchy/HierarchyWrapper.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/hierarchy/HierarchyWrapper.java
/* * 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.studio.schemaeditor.model.hierarchy; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** * This class represents the HierarchyWrapper. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class HierarchyWrapper { /** The wrapped object */ private Object wrappedObject; /** The parent */ private Object parent; /** The children */ private List<HierarchyWrapper> children = new ArrayList<HierarchyWrapper>(); /** * Creates a new instance of HierarchyWrapper. * * @param obj * the wrapped object */ public HierarchyWrapper( Object obj ) { wrappedObject = obj; parent = null; } /** * Creates a new instance of HierarchyWrapper. * * @param obj * the wrapped object * @param parent * the parent */ public HierarchyWrapper( Object obj, Object parent ) { wrappedObject = obj; this.parent = parent; } /** * Adds a child. * * @param child * the child * @return * true (as per the general contract of the Collection.add method). */ public boolean addChild( HierarchyWrapper child ) { return children.add( child ); } /** * Appends all of the elements in the specified collection to the end * of the children, in the order that they are returned by the specified * collection's iterator (optional operation). * * @param collection * the collection * @return * true if the children changed as a result of the call. */ public boolean addChildren( Collection<? extends HierarchyWrapper> children ) { return this.children.addAll( children ); } /** * Indicates whether some other object is "equal to" this wrapped object. * * @param o * the reference object with which to compare. * @return * true if this object is the same as the obj argument; false otherwise. */ public boolean equalsWrappedObject( Object obj ) { if ( obj != null ) { return obj.equals( wrappedObject ); } return false; } /** * Gets the children. * * @return * the children */ public List<HierarchyWrapper> getChildren() { return children; } /** * Gets the parent. * * @return * the parent */ public Object getParent() { return parent; } /** * Gets the wrapped object. * * @return * the wrapped object */ public Object getWrappedObject() { return wrappedObject; } /** * Removes a child. * * @param child * the child * @return * true if the children contained the specified element. */ public boolean removeChild( HierarchyWrapper child ) { return children.remove( child ); } /** * Removes from the children all the elements that are contained in * the specified collection (optional operation). * * @param collection * the collection * @return * true if the children changed as a result of the call. */ public boolean removeChildren( Collection<? extends HierarchyWrapper> children ) { return this.children.removeAll( children ); } /** * Sets the children. * * @param children * the children */ public void setChildren( List<HierarchyWrapper> children ) { this.children = children; } /** * Sets the parent. * * @param parent * the parent */ public void setParent( Object parent ) { this.parent = parent; } /** * Sets the wrapped object. * * @param wrappedObject * the wrapped object */ public void setWrappedObject( Object wrappedObject ) { this.wrappedObject = wrappedObject; } /** * {@inheritDoc} */ public String toString() { return "{|" + wrappedObject + "|" + children + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java
/* * 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.studio.schemaeditor.model.schemamanager; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.registries.AbstractSchemaLoader; import org.apache.directory.api.ldap.model.schema.registries.Schema; import org.apache.directory.studio.schemaeditor.Activator; import org.apache.directory.studio.schemaeditor.model.Project; /** * Loads schema data from schema files (OpenLDAP and XML formats). * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaEditorSchemaLoader extends AbstractSchemaLoader { /** The currently open project */ private Project project; /** * Creates a new instance of SchemaEditorSchemaLoader. * * @throws Exception */ public SchemaEditorSchemaLoader() { initializeSchemas(); } /** * Initialize schemas. */ private void initializeSchemas() { project = Activator.getDefault().getProjectsHandler().getOpenProject(); if ( project != null ) { List<org.apache.directory.studio.schemaeditor.model.Schema> schemaObjects = project.getSchemaHandler() .getSchemas(); for ( org.apache.directory.studio.schemaeditor.model.Schema schemaObject : schemaObjects ) { schemaMap.put( schemaObject.getSchemaName(), schemaObject ); } } } /** * {@inheritDoc} */ public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException { return new ArrayList<Entry>(); } /** * {@inheritDoc} */ public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException { return new ArrayList<Entry>(); } /** * {@inheritDoc} */ public List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException { return new ArrayList<Entry>(); } /** * {@inheritDoc} */ public List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException { List<Entry> matchingRuleList = new ArrayList<Entry>(); if ( project != null ) { for ( Schema schema : schemas ) { org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler() .getSchema( schema.getSchemaName() ); if ( schemaHandlerSchema != null ) { List<MatchingRule> matchingRules = schemaHandlerSchema.getMatchingRules(); for ( MatchingRule matchingRule : matchingRules ) { matchingRuleList.add( SchemaEditorSchemaLoaderUtils.toEntry( matchingRule ) ); } } } } return matchingRuleList; } /** * {@inheritDoc} */ public List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException { List<Entry> syntaxList = new ArrayList<Entry>(); if ( project != null ) { for ( Schema schema : schemas ) { org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler() .getSchema( schema.getSchemaName() ); if ( schemaHandlerSchema != null ) { List<LdapSyntax> syntaxes = schemaHandlerSchema.getSyntaxes(); for ( LdapSyntax syntax : syntaxes ) { syntaxList.add( SchemaEditorSchemaLoaderUtils.toEntry( syntax ) ); } } } } return syntaxList; } /** * {@inheritDoc} */ public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException { List<Entry> attributeTypeList = new ArrayList<Entry>(); if ( project != null ) { for ( Schema schema : schemas ) { org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler() .getSchema( schema.getSchemaName() ); if ( schemaHandlerSchema != null ) { List<AttributeType> attributeTypes = schemaHandlerSchema.getAttributeTypes(); for ( AttributeType attributeType : attributeTypes ) { attributeTypeList.add( SchemaEditorSchemaLoaderUtils.toEntry( attributeType ) ); } } } } return attributeTypeList; } /** * {@inheritDoc} */ public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException { return new ArrayList<Entry>(); } /** * {@inheritDoc} */ public List<Entry> loadNameForms( Schema... schemas ) throws LdapException, IOException { return new ArrayList<Entry>(); } /** * {@inheritDoc} */ public List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException { return new ArrayList<Entry>(); } /** * {@inheritDoc} */ public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException { return new ArrayList<Entry>(); } /** * {@inheritDoc} */ public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException { List<Entry> objectClassList = new ArrayList<Entry>(); if ( project != null ) { for ( Schema schema : schemas ) { org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler() .getSchema( schema.getSchemaName() ); if ( schemaHandlerSchema != null ) { List<ObjectClass> objectClasses = schemaHandlerSchema.getObjectClasses(); for ( ObjectClass objectClass : objectClasses ) { objectClassList.add( SchemaEditorSchemaLoaderUtils.toEntry( objectClass ) ); } } } } return objectClassList; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
/* * 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.studio.schemaeditor.model.schemamanager; import java.util.List; import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.api.ldap.model.entry.Attribute; import org.apache.directory.api.ldap.model.entry.DefaultAttribute; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.name.Rdn; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum; import org.apache.directory.api.ldap.model.schema.SchemaObject; import org.apache.directory.api.ldap.model.schema.UsageEnum; import org.apache.directory.api.util.Strings; /** * This class is a helper class for the {@link SchemaEditorSchemaLoader} class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaEditorSchemaLoaderUtils { private static final String M_COLLECTIVE = "m-collective"; //$NON-NLS-1$ private static final String M_DESCRIPTION = "m-description"; //$NON-NLS-1$ private static final String M_EQUALITY = "m-equality"; //$NON-NLS-1$ private static final String M_LENGTH = "m-length"; //$NON-NLS-1$ private static final String M_MAY = "m-may"; //$NON-NLS-1$ private static final String M_MUST = "m-must"; //$NON-NLS-1$ private static final String M_NAME = "m-name"; //$NON-NLS-1$ private static final String M_NO_USER_MODIFICATION = "m-noUserModification"; //$NON-NLS-1$ private static final String M_OBSOLETE = "m-obsolete"; //$NON-NLS-1$ private static final String M_OID = "m-oid"; //$NON-NLS-1$ private static final String M_ORDERING = "m-ordering"; //$NON-NLS-1$ private static final String M_SINGLE_VALUE = "m-singleValue"; //$NON-NLS-1$ private static final String M_SUBSTR = "m-substr"; //$NON-NLS-1$ private static final String M_SUP_ATTRIBUTE_TYPE = "m-supAttributeType"; //$NON-NLS-1$ private static final String M_SUP_OBJECT_CLASS = "m-supObjectClass"; //$NON-NLS-1$ private static final String M_SYNTAX = "m-syntax"; //$NON-NLS-1$ private static final String M_TYPE_OBJECT_CLASS = "m-typeObjectClass"; //$NON-NLS-1$ private static final String M_USAGE = "m-usage"; //$NON-NLS-1$ private static final String TRUE = "TRUE"; //$NON-NLS-1$ /** * Converts the given attribute type to an equivalent entry representation. * * @param attributeType * the attribute type * @return * the attribute type converted to an equivalent entry representation * @throws LdapException */ public static Entry toEntry( AttributeType attributeType ) throws LdapException { // Creating a blank entry Entry entry = new DefaultEntry(); // Setting calculated DN entry.setDn( getDn( attributeType, SchemaConstants.ATTRIBUTE_TYPES_PATH ) ); // Values common to all schema objects addSchemaObjectValues( attributeType, SchemaConstants.META_ATTRIBUTE_TYPE_OC, entry ); // Superior value addSuperiorValue( attributeType, entry ); // Equality matching rule value addEqualityValue( attributeType, entry ); // Ordering matching rule value addOrderingValue( attributeType, entry ); // Substrings matching rule value addSubstrValue( attributeType, entry ); // Syntax value addSyntaxValue( attributeType, entry ); // Single value value addSingleValueValue( attributeType, entry ); // Collective value addCollectiveValue( attributeType, entry ); // No user modification value addNoUserModificationValue( attributeType, entry ); // Usage value addUsageValue( attributeType, entry ); return entry; } /** * Converts the given object class to an equivalent entry representation. * * @param matchingRule * the matching rule * @return * the object class converted to an equivalent entry representation * @throws LdapException */ public static Entry toEntry( MatchingRule matchingRule ) throws LdapException { // Creating a blank entry Entry entry = new DefaultEntry(); // Setting calculated DN entry.setDn( getDn( matchingRule, SchemaConstants.MATCHING_RULES_PATH ) ); // Values common to all schema objects addSchemaObjectValues( matchingRule, SchemaConstants.META_MATCHING_RULE_OC, entry ); String syntax = matchingRule.getSyntaxOid(); if ( !Strings.isEmpty( syntax ) ) { Attribute attribute = new DefaultAttribute( M_SYNTAX, syntax ); entry.add( attribute ); } return entry; } /** * Converts the given object class to an equivalent entry representation. * * @param objectClass * the object class * @return * the object class converted to an equivalent entry representation * @throws LdapException */ public static Entry toEntry( ObjectClass objectClass ) throws LdapException { // Creating a blank entry Entry entry = new DefaultEntry(); // Setting calculated DN entry.setDn( getDn( objectClass, SchemaConstants.OBJECT_CLASSES_PATH ) ); // Values common to all schema objects addSchemaObjectValues( objectClass, SchemaConstants.META_OBJECT_CLASS_OC, entry ); // Superiors value addSuperiorsValue( objectClass, entry ); // Class type value addClassTypeValue( objectClass, entry ); // Musts value addMustsValue( objectClass, entry ); // Mays value addMaysValue( objectClass, entry ); return entry; } /** * Converts the given object class to an equivalent entry representation. * * @param syntax * the syntax * @return * the object class converted to an equivalent entry representation * @throws LdapException */ public static Entry toEntry( LdapSyntax syntax ) throws LdapException { // Creating a blank entry Entry entry = new DefaultEntry(); // Setting calculated DN entry.setDn( getDn( syntax, SchemaConstants.MATCHING_RULES_PATH ) ); // Values common to all schema objects addSchemaObjectValues( syntax, SchemaConstants.META_MATCHING_RULE_OC, entry ); return entry; } /** * Returns the DN for the given schema object in the given object path. * * @param schemaObject * the schema object * @param objectPath * the object path * @return * the DN for the given schema object in the given object path * @throws LdapInvalidDnException */ private static Dn getDn( SchemaObject schemaObject, String objectPath ) throws LdapInvalidDnException { try { return Dn.EMPTY_DN .add( new Rdn( SchemaConstants.OU_SCHEMA ) ) .add( new Rdn( SchemaConstants.CN_AT, Rdn.escapeValue( schemaObject.getSchemaName() ) ) ) .add( new Rdn( objectPath ) ) .add( new Rdn( M_OID, schemaObject.getOid() ) ); } catch ( LdapInvalidAttributeValueException liave ) { throw new LdapInvalidDnException( liave.getLocalizedMessage(), liave ); } } /** * Adds the values common to all {@link SchemaObject}(s) to the entry. * * @param schemaObject * the schema object * @param objectClassValue * the value for the objectClass attribute * @param entry * the entry * @throws LdapException */ private static void addSchemaObjectValues( SchemaObject schemaObject, String objectClassValue, Entry entry ) throws LdapException { // ObjectClass addObjectClassValue( schemaObject, objectClassValue, entry ); // OID addOidValue( schemaObject, entry ); // Names addNamesValue( schemaObject, entry ); // Description addDescriptionValue( schemaObject, entry ); // Obsolete addObsoleteValue( schemaObject, entry ); } /** * Adds the objectClass value to the entry. * * @param schemaObject * the schema object * @param objectClassValue * the value for the objectClass attribute * @param entry * the entry * @throws LdapException */ private static void addObjectClassValue( SchemaObject schemaObject, String objectClassValue, Entry entry ) throws LdapException { Attribute objectClassAttribute = new DefaultAttribute( SchemaConstants.OBJECT_CLASS_AT ); entry.add( objectClassAttribute ); objectClassAttribute.add( SchemaConstants.TOP_OC ); objectClassAttribute.add( SchemaConstants.META_TOP_OC ); objectClassAttribute.add( objectClassValue ); } /** * Adds the OID value to the entry. * * @param schemaObject * the schema object * @param entry * the entry * @throws LdapException */ private static void addOidValue( SchemaObject schemaObject, Entry entry ) throws LdapException { String oid = schemaObject.getOid(); if ( !Strings.isEmpty( oid ) ) { Attribute attribute = new DefaultAttribute( M_OID, oid ); entry.add( attribute ); } } /** * Adds the names value to the entry. * * @param schemaObject * the schema object * @param entry * the entry * @throws LdapException */ private static void addNamesValue( SchemaObject schemaObject, Entry entry ) throws LdapException { List<String> names = schemaObject.getNames(); if ( ( names != null ) && !names.isEmpty() ) { Attribute attribute = new DefaultAttribute( M_NAME ); entry.add( attribute ); for ( String name : names ) { attribute.add( name ); } } } /** * Adds the description value to the entry. * * @param schemaObject * the schema object * @param entry * the entry * @throws LdapException */ private static void addDescriptionValue( SchemaObject schemaObject, Entry entry ) throws LdapException { String description = schemaObject.getDescription(); if ( !Strings.isEmpty( description ) ) { Attribute attribute = new DefaultAttribute( M_DESCRIPTION, description ); entry.add( attribute ); } } /** * Adds the obsolete value to the entry. * * @param schemaObject * the schema object * @param entry * the entry * @throws LdapException */ private static void addObsoleteValue( SchemaObject schemaObject, Entry entry ) throws LdapException { if ( schemaObject.isObsolete() ) { Attribute attribute = new DefaultAttribute( M_OBSOLETE, TRUE ); entry.add( attribute ); } } /** * Adds the superior value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addSuperiorValue( AttributeType attributeType, Entry entry ) throws LdapException { String superior = attributeType.getSuperiorName(); if ( !Strings.isEmpty( superior ) ) { Attribute attribute = new DefaultAttribute( M_SUP_ATTRIBUTE_TYPE, superior ); entry.add( attribute ); } } /** * Adds the equality matching rule value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addEqualityValue( AttributeType attributeType, Entry entry ) throws LdapException { String equality = attributeType.getEqualityName(); if ( !Strings.isEmpty( equality ) ) { Attribute attribute = new DefaultAttribute( M_EQUALITY, equality ); entry.add( attribute ); } } /** * Adds the ordering matching rule value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addOrderingValue( AttributeType attributeType, Entry entry ) throws LdapException { String ordering = attributeType.getOrderingName(); if ( !Strings.isEmpty( ordering ) ) { Attribute attribute = new DefaultAttribute( M_ORDERING, ordering ); entry.add( attribute ); } } /** * Adds the substring matching rule value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addSubstrValue( AttributeType attributeType, Entry entry ) throws LdapException { String substr = attributeType.getSubstringName(); if ( !Strings.isEmpty( substr ) ) { Attribute attribute = new DefaultAttribute( M_SUBSTR, substr ); entry.add( attribute ); } } /** * Adds the syntax value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addSyntaxValue( AttributeType attributeType, Entry entry ) throws LdapException { String syntax = attributeType.getSyntaxName(); if ( !Strings.isEmpty( syntax ) ) { Attribute attribute = new DefaultAttribute( M_SYNTAX, syntax ); entry.add( attribute ); long syntaxLength = attributeType.getSyntaxLength(); if ( syntaxLength != -1 ) { attribute = new DefaultAttribute( M_LENGTH, Long.toString( syntaxLength) ); //$NON-NLS-1$ entry.add( attribute ); } } } /** * Adds the single value value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addSingleValueValue( AttributeType attributeType, Entry entry ) throws LdapException { if ( attributeType.isSingleValued() ) { Attribute attribute = new DefaultAttribute( M_SINGLE_VALUE, TRUE ); entry.add( attribute ); } } /** * Adds the collective value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addCollectiveValue( AttributeType attributeType, Entry entry ) throws LdapException { if ( attributeType.isCollective() ) { Attribute attribute = new DefaultAttribute( M_COLLECTIVE, TRUE ); entry.add( attribute ); } } /** * Adds the no user modification value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addNoUserModificationValue( AttributeType attributeType, Entry entry ) throws LdapException { if ( !attributeType.isUserModifiable() ) { Attribute attribute = new DefaultAttribute( M_NO_USER_MODIFICATION, TRUE ); entry.add( attribute ); } } /** * Adds the usage value. * * @param attributeType * the attribute type * @param entry * the entry * @throws LdapException */ private static void addUsageValue( AttributeType attributeType, Entry entry ) throws LdapException { UsageEnum usage = attributeType.getUsage(); if ( usage != UsageEnum.USER_APPLICATIONS ) { Attribute attribute = new DefaultAttribute( M_USAGE, usage.render() ); entry.add( attribute ); } } /** * Adds the superiors value. * * @param objectClass * the object class * @param entry * the entry * @throws LdapException */ private static void addSuperiorsValue( ObjectClass objectClass, Entry entry ) throws LdapException { List<String> superiors = objectClass.getSuperiorOids(); if ( ( superiors != null ) && !superiors.isEmpty() ) { Attribute attribute = new DefaultAttribute( M_SUP_OBJECT_CLASS ); entry.add( attribute ); for ( String superior : superiors ) { attribute.add( superior ); } } } /** * Adds class type value. * * @param objectClass * the object class * @param entry * the entry * @throws LdapException */ private static void addClassTypeValue( ObjectClass objectClass, Entry entry ) throws LdapException { ObjectClassTypeEnum classType = objectClass.getType(); if ( classType != ObjectClassTypeEnum.STRUCTURAL ) { Attribute attribute = new DefaultAttribute( M_TYPE_OBJECT_CLASS, classType.toString() ); entry.add( attribute ); } } /** * Adds musts value. * * @param objectClass * the object class * @param entry * the entry * @throws LdapException */ private static void addMustsValue( ObjectClass objectClass, Entry entry ) throws LdapException { List<String> musts = objectClass.getMustAttributeTypeOids(); if ( ( musts != null ) && !musts.isEmpty() ) { Attribute attribute = new DefaultAttribute( M_MUST ); entry.add( attribute ); for ( String must : musts ) { attribute.add( must ); } } } /** * Adds mays value. * * @param objectClass * the object class * @param entry * the entry * @throws LdapException */ private static void addMaysValue( ObjectClass objectClass, Entry entry ) throws LdapException { List<String> mays = objectClass.getMayAttributeTypeOids(); if ( ( mays != null ) && !mays.isEmpty() ) { Attribute attribute = new DefaultAttribute( M_MAY ); entry.add( attribute ); for ( String may : mays ) { attribute.add( may ); } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
/* * 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.studio.schemaeditor.model.io; import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.schemaeditor.model.Project; /** * This interface defines a SchemaConnector. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface SchemaConnector { /** * Indicates whether the SchemaConnector is suitable for use with the * given connection. * * @param connection * the connection * @param monitor * the progress monitor * @return * true if the SchemaConnector is suitable for the given connection, * false if not */ boolean isSuitableConnector( Connection connection, StudioProgressMonitor monitor ); /** * Imports the Schema of the LDAP Server using the given project and * progress monitor. * * @param project * the project * @param monitor * the progress monitor * @throws SchemaConnectorException */ void importSchema( Project project, StudioProgressMonitor monitor ) throws SchemaConnectorException; /** * Exports the Schema to the LDAP Server using the given connection and * progress monitor. * * @param project * the project * @param monitor * the progress monitor * @throws SchemaConnectorException */ void exportSchema( Project project, StudioProgressMonitor monitor ) throws SchemaConnectorException; /** * Gets the name. * * @return * the name */ String getName(); /** * Sets the name. * * @param name * the name */ void setName( String name ); /** * Gets the ID. * * @return * the ID */ String getId(); /** * Sets the ID. * * @param id * the ID */ void setId( String id ); /** * Gets the description. * * @return * the description */ String getDescription(); /** * Sets the description. * * @param description * the description */ void setDescription( String description ); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
/* * 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.studio.schemaeditor.model.io; import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum; import org.apache.directory.api.ldap.model.schema.UsageEnum; import org.apache.directory.studio.schemaeditor.model.Schema; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; import org.eclipse.osgi.util.NLS; /** * This class is used to import a Schema file from the XML Format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class XMLSchemaFileImporter { // The Tags private static final String ALIAS_TAG = "alias"; //$NON-NLS-1$ private static final String ALIASES_TAG = "aliases"; //$NON-NLS-1$ private static final String ATTRIBUTE_TYPE_TAG = "attributetype"; //$NON-NLS-1$ private static final String ATTRIBUTE_TYPES_TAG = "attributetypes"; //$NON-NLS-1$ private static final String BOOLEAN_FALSE = "false"; //$NON-NLS-1$ private static final String BOOLEAN_TRUE = "true"; //$NON-NLS-1$ private static final String COLLECTIVE_TAG = "collective"; //$NON-NLS-1$ private static final String DESCRIPTION_TAG = "description"; //$NON-NLS-1$ private static final String EQUALITY_TAG = "equality"; //$NON-NLS-1$ private static final String HUMAN_READABLE_TAG = "humanreadable"; //$NON-NLS-1$ private static final String MANDATORY_TAG = "mandatory"; //$NON-NLS-1$ private static final String MATCHING_RULE_TAG = "matchingrule"; //$NON-NLS-1$ private static final String MATCHING_RULES_TAG = "matchingrules"; //$NON-NLS-1$ private static final String NAME_TAG = "name"; //$NON-NLS-1$ private static final String NO_USER_MODIFICATION_TAG = "nousermodification"; //$NON-NLS-1$ private static final String OBJECT_CLASS_TAG = "objectclass"; //$NON-NLS-1$ private static final String OBJECT_CLASSES_TAG = "objectclasses"; //$NON-NLS-1$ private static final String OBSOLETE_TAG = "obsolete"; //$NON-NLS-1$ private static final String OID_TAG = "oid"; //$NON-NLS-1$ private static final String OPTIONAL_TAG = "optional"; //$NON-NLS-1$ private static final String ORDERING_TAG = "ordering"; //$NON-NLS-1$ private static final String SCHEMA_TAG = "schema"; //$NON-NLS-1$ private static final String SCHEMAS_TAG = "schemas"; //$NON-NLS-1$ private static final String SINGLE_VALUE_TAG = "singlevalue"; //$NON-NLS-1$ private static final String SUBSTRING_TAG = "substring"; //$NON-NLS-1$ private static final String SUPERIOR_TAG = "superior"; //$NON-NLS-1$ private static final String SUPERIORS_TAG = "superiors"; //$NON-NLS-1$ private static final String SYNTAX_LENGTH_TAG = "syntaxlength"; //$NON-NLS-1$ private static final String SYNTAX_OID_TAG = "syntaxoid"; //$NON-NLS-1$ private static final String SYNTAX_TAG = "syntax"; //$NON-NLS-1$ private static final String SYNTAXES_TAG = "syntaxes"; //$NON-NLS-1$ private static final String TYPE_TAG = "type"; //$NON-NLS-1$ private static final String USAGE_TAG = "usage"; //$NON-NLS-1$ /** * Extracts the Schemas from the given path. * * @param inputStream * the {@link InputStream} of the file * @param path * the path of the file. * @return * the corresponding schema * @throws XMLSchemaFileImportException * if an error occurs when importing the schema */ public static Schema[] getSchemas( InputStream inputStream, String path ) throws XMLSchemaFileImportException { SAXReader reader = new SAXReader(); Document document = null; try { document = reader.read( inputStream ); } catch ( DocumentException e ) { throw new XMLSchemaFileImportException( NLS.bind( Messages .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$ } Element rootElement = document.getRootElement(); if ( !rootElement.getName().equals( SCHEMAS_TAG ) ) { throw new XMLSchemaFileImportException( NLS.bind( Messages .getString( "XMLSchemaFileImporter.NotValidSchema" ), new String[] { path } ) ); //$NON-NLS-1$ } return readSchemas( rootElement, path ); } /** * Extracts the Schema from the given path. * * @param inputStream * the {@link InputStream} of the file * @param path * the path of the file. * @return * the corresponding schema * @throws XMLSchemaFileImportException * if an error occurs when importing the schema */ public static Schema getSchema( InputStream inputStream, String path ) throws XMLSchemaFileImportException { SAXReader reader = new SAXReader(); Document document = null; try { document = reader.read( inputStream ); } catch ( DocumentException e ) { throw new XMLSchemaFileImportException( NLS.bind( Messages .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$ } Element rootElement = document.getRootElement(); return readSchema( rootElement, path ); } /** * Reads schemas. * * @param element * the element * @param path * the path of the file * @throws XMLSchemaFileImportException * if an error occurs when importing the schema * @return * the corresponding schemas */ public static Schema[] readSchemas( Element element, String path ) throws XMLSchemaFileImportException { List<Schema> schemas = new ArrayList<Schema>(); if ( !element.getName().equals( SCHEMAS_TAG ) ) { throw new XMLSchemaFileImportException( NLS.bind( Messages .getString( "XMLSchemaFileImporter.NotValidSchema" ), new String[] { path } ) ); //$NON-NLS-1$ } for ( Iterator<?> i = element.elementIterator( SCHEMA_TAG ); i.hasNext(); ) { Element schemaElement = ( Element ) i.next(); schemas.add( readSchema( schemaElement, path ) ); } return schemas.toArray( new Schema[0] ); } /** * Reads a schema. * * @param element * the element * @param path * the path of the file * @throws XMLSchemaFileImportException * if an error occurs when importing the schema * @return * the corresponding schema */ public static Schema readSchema( Element element, String path ) throws XMLSchemaFileImportException { // Creating the schema with an empty name Schema schema = new Schema( getSchemaName( element, path ) ); // Attribute Types readAttributeTypes( element, schema ); // Object Classes readObjectClasses( element, schema ); // Matching Rules readMatchingRules( element, schema ); // Syntaxes readSyntaxes( element, schema ); return schema; } /** * Gets the name of the schema. * * @param element * the element * @param path * the path * @return * the name of the schema * @throws XMLSchemaFileImportException * if an error occurs when reading the file */ private static String getSchemaName( Element element, String path ) throws XMLSchemaFileImportException { if ( !element.getName().equals( SCHEMA_TAG ) ) { throw new XMLSchemaFileImportException( NLS.bind( Messages .getString( "XMLSchemaFileImporter.NotValidSchema" ), new String[] { path } ) ); //$NON-NLS-1$ } Attribute nameAttribute = element.attribute( NAME_TAG ); if ( ( nameAttribute != null ) && ( !nameAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { return nameAttribute.getValue(); } else { return getNameFromPath( path ); } } /** * Gets the name of the file. * * @param path * the path * @return * the name of the file. */ private static String getNameFromPath( String path ) { File file = new File( path ); String fileName = file.getName(); if ( fileName.endsWith( ".xml" ) ) //$NON-NLS-1$ { String[] fileNameSplitted = fileName.split( "\\." ); //$NON-NLS-1$ return fileNameSplitted[0]; } return fileName; } /** * Reads the attribute types. * * @param element * the element * @param schema * the schema * @throws XMLSchemaFileImportException */ private static void readAttributeTypes( Element element, Schema schema ) throws XMLSchemaFileImportException { for ( Iterator<?> i = element.elementIterator( ATTRIBUTE_TYPES_TAG ); i.hasNext(); ) { Element attributesTypesElement = ( Element ) i.next(); for ( Iterator<?> i2 = attributesTypesElement.elementIterator( ATTRIBUTE_TYPE_TAG ); i2.hasNext(); ) { readAttributeType( ( Element ) i2.next(), schema ); } } } /** * Reads an attribute type. * * @param element * the element * @param schema * the schema */ private static void readAttributeType( Element element, Schema schema ) throws XMLSchemaFileImportException { AttributeType at = null; // OID Attribute oidAttribute = element.attribute( OID_TAG ); if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { at = new AttributeType( oidAttribute.getValue() ); } else { throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.NoOIDInAttribute" ) ); //$NON-NLS-1$ } // Schema at.setSchemaName( schema.getSchemaName() ); // Aliases Element aliasesElement = element.element( ALIASES_TAG ); if ( aliasesElement != null ) { List<String> aliases = new ArrayList<String>(); for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); ) { Element aliasElement = ( Element ) i.next(); aliases.add( aliasElement.getText() ); } if ( aliases.size() >= 1 ) { at.setNames( aliases.toArray( new String[0] ) ); } } // Description Element descriptionElement = element.element( DESCRIPTION_TAG ); if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { at.setDescription( descriptionElement.getText() ); } // Superior Element superiorElement = element.element( SUPERIOR_TAG ); if ( ( superiorElement != null ) && ( !superiorElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { at.setSuperiorOid( superiorElement.getText() ); } // Usage Element usageElement = element.element( USAGE_TAG ); if ( ( usageElement != null ) && ( !usageElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { try { at.setUsage( UsageEnum.valueOf( usageElement.getText() ) ); } catch ( IllegalArgumentException e ) { throw new XMLSchemaFileImportException( Messages .getString( "XMLSchemaFileImporter.UnceonvertableAttribute" ), e ); //$NON-NLS-1$ } } // Syntax Element syntaxElement = element.element( SYNTAX_TAG ); if ( ( syntaxElement != null ) && ( !syntaxElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { at.setSyntaxOid( syntaxElement.getText() ); } // Syntax Length Element syntaxLengthElement = element.element( SYNTAX_LENGTH_TAG ); if ( ( syntaxLengthElement != null ) && ( !syntaxLengthElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { try { at.setSyntaxLength( Long.parseLong( syntaxLengthElement.getText() ) ); } catch ( NumberFormatException e ) { throw new XMLSchemaFileImportException( Messages .getString( "XMLSchemaFileImporter.UnconvertableInteger" ), e ); //$NON-NLS-1$ } } // Obsolete Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG ); if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { at.setObsolete( readBoolean( obsoleteAttribute.getValue() ) ); } // Single Value Attribute singleValueAttribute = element.attribute( SINGLE_VALUE_TAG ); if ( ( singleValueAttribute != null ) && ( !singleValueAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { at.setSingleValued( readBoolean( singleValueAttribute.getValue() ) ); } // Collective Attribute collectiveAttribute = element.attribute( COLLECTIVE_TAG ); if ( ( collectiveAttribute != null ) && ( !collectiveAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { at.setCollective( readBoolean( collectiveAttribute.getValue() ) ); } // No User Modification Attribute noUserModificationAttribute = element.attribute( NO_USER_MODIFICATION_TAG ); if ( ( noUserModificationAttribute != null ) && ( !noUserModificationAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { at.setUserModifiable( !readBoolean( noUserModificationAttribute.getValue() ) ); } // Equality Element equalityElement = element.element( EQUALITY_TAG ); if ( ( equalityElement != null ) && ( !equalityElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { at.setEqualityOid( equalityElement.getText() ); } // Ordering Element orderingElement = element.element( ORDERING_TAG ); if ( ( orderingElement != null ) && ( !orderingElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { at.setOrderingOid( orderingElement.getText() ); } // Substring Element substringElement = element.element( SUBSTRING_TAG ); if ( ( substringElement != null ) && ( !substringElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { at.setSubstringOid( substringElement.getText() ); } // Adding the attribute type to the schema schema.addAttributeType( at ); } /** * Reads the object classes * * @param element * the element * @param schema * the schema * @throws XMLSchemaFileImportException */ private static void readObjectClasses( Element element, Schema schema ) throws XMLSchemaFileImportException { for ( Iterator<?> i = element.elementIterator( OBJECT_CLASSES_TAG ); i.hasNext(); ) { Element objectClassesElement = ( Element ) i.next(); for ( Iterator<?> i2 = objectClassesElement.elementIterator( OBJECT_CLASS_TAG ); i2.hasNext(); ) { readObjectClass( ( Element ) i2.next(), schema ); } } } /** * Reads an object class * * @param element * the element * @param schema * the schema * @throws XMLSchemaFileImportException */ private static void readObjectClass( Element element, Schema schema ) throws XMLSchemaFileImportException { ObjectClass oc = null; // OID Attribute oidAttribute = element.attribute( OID_TAG ); if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { oc = new ObjectClass( oidAttribute.getValue() ); } else { throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.NoOIDInClass" ) ); //$NON-NLS-1$ } // Schema oc.setSchemaName( schema.getSchemaName() ); // Aliases Element aliasesElement = element.element( ALIASES_TAG ); if ( aliasesElement != null ) { List<String> aliases = new ArrayList<String>(); for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); ) { Element aliasElement = ( Element ) i.next(); aliases.add( aliasElement.getText() ); } if ( aliases.size() >= 1 ) { oc.setNames( aliases.toArray( new String[0] ) ); } } // Description Element descriptionElement = element.element( DESCRIPTION_TAG ); if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { oc.setDescription( descriptionElement.getText() ); } // Superiors Element superiorsElement = element.element( SUPERIORS_TAG ); if ( superiorsElement != null ) { List<String> superiors = new ArrayList<String>(); for ( Iterator<?> i = superiorsElement.elementIterator( SUPERIOR_TAG ); i.hasNext(); ) { Element superiorElement = ( Element ) i.next(); superiors.add( superiorElement.getText() ); } if ( superiors.size() >= 1 ) { oc.setSuperiorOids( superiors ); } } // Class Type Element classTypeElement = element.element( TYPE_TAG ); if ( ( classTypeElement != null ) && ( !classTypeElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { try { oc.setType( ObjectClassTypeEnum.valueOf( classTypeElement.getText() ) ); } catch ( IllegalArgumentException e ) { throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.UnconvertableValue" ), e ); //$NON-NLS-1$ } } // Obsolete Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG ); if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { oc.setObsolete( readBoolean( obsoleteAttribute.getValue() ) ); } // Mandatory Attribute Types Element mandatoryElement = element.element( MANDATORY_TAG ); if ( mandatoryElement != null ) { List<String> mandatoryATs = new ArrayList<String>(); for ( Iterator<?> i = mandatoryElement.elementIterator( ATTRIBUTE_TYPE_TAG ); i.hasNext(); ) { Element attributeTypeElement = ( Element ) i.next(); mandatoryATs.add( attributeTypeElement.getText() ); } if ( mandatoryATs.size() >= 1 ) { oc.setMustAttributeTypeOids( mandatoryATs ); } } // Optional Attribute Types Element optionalElement = element.element( OPTIONAL_TAG ); if ( optionalElement != null ) { List<String> optionalATs = new ArrayList<String>(); for ( Iterator<?> i = optionalElement.elementIterator( ATTRIBUTE_TYPE_TAG ); i.hasNext(); ) { Element attributeTypeElement = ( Element ) i.next(); optionalATs.add( attributeTypeElement.getText() ); } if ( optionalATs.size() >= 1 ) { oc.setMayAttributeTypeOids( optionalATs ); } } // Adding the object class to the schema schema.addObjectClass( oc ); } /** * Reads the matching rules. * * @param element * the element * @param schema * the schema * @throws XMLSchemaFileImportException */ private static void readMatchingRules( Element element, Schema schema ) throws XMLSchemaFileImportException { for ( Iterator<?> i = element.elementIterator( MATCHING_RULES_TAG ); i.hasNext(); ) { Element matchingRulesElement = ( Element ) i.next(); for ( Iterator<?> i2 = matchingRulesElement.elementIterator( MATCHING_RULE_TAG ); i2.hasNext(); ) { readMatchingRule( ( Element ) i2.next(), schema ); } } } /** * Reads a matching rule. * * @param element * the element * @param schema * the schema * @throws XMLSchemaFileImportException */ private static void readMatchingRule( Element element, Schema schema ) throws XMLSchemaFileImportException { MatchingRule mr = null; // OID Attribute oidAttribute = element.attribute( OID_TAG ); if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { mr = new MatchingRule( oidAttribute.getValue() ); } else { throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.NoMatchingRuleForOID" ) ); //$NON-NLS-1$ } // Schema mr.setSchemaName( schema.getSchemaName() ); // Aliases Element aliasesElement = element.element( ALIASES_TAG ); if ( aliasesElement != null ) { List<String> aliases = new ArrayList<String>(); for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); ) { Element aliasElement = ( Element ) i.next(); aliases.add( aliasElement.getText() ); } if ( aliases.size() >= 1 ) { mr.setNames( aliases.toArray( new String[0] ) ); } } // Description Element descriptionElement = element.element( DESCRIPTION_TAG ); if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { mr.setDescription( descriptionElement.getText() ); } // Obsolete Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG ); if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { mr.setObsolete( readBoolean( obsoleteAttribute.getValue() ) ); } // Syntax OID Element syntaxOidElement = element.element( SYNTAX_OID_TAG ); if ( ( syntaxOidElement != null ) && ( !syntaxOidElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { mr.setSyntaxOid( syntaxOidElement.getText() ); } // Adding the matching rule to the schema schema.addMatchingRule( mr ); } /** * Reads the syntaxes * * @param element * the element * @param schema * the schema * @throws XMLSchemaFileImportException */ private static void readSyntaxes( Element element, Schema schema ) throws XMLSchemaFileImportException { for ( Iterator<?> i = element.elementIterator( SYNTAXES_TAG ); i.hasNext(); ) { Element syntaxElement = ( Element ) i.next(); for ( Iterator<?> i2 = syntaxElement.elementIterator( SYNTAX_TAG ); i2.hasNext(); ) { readSyntax( ( Element ) i2.next(), schema ); } } } /** * Reads a syntax. * * @param element * the element * @param schema * the schema * @throws XMLSchemaFileImportException */ private static void readSyntax( Element element, Schema schema ) throws XMLSchemaFileImportException { LdapSyntax syntax = null; // OID Attribute oidAttribute = element.attribute( OID_TAG ); if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { syntax = new LdapSyntax( oidAttribute.getValue() ); } else { throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.InvalidSyntaxForOID" ) ); //$NON-NLS-1$ } // Schema syntax.setSchemaName( schema.getSchemaName() ); // Aliases Element aliasesElement = element.element( ALIASES_TAG ); if ( aliasesElement != null ) { List<String> aliases = new ArrayList<String>(); for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); ) { Element aliasElement = ( Element ) i.next(); aliases.add( aliasElement.getText() ); } if ( aliases.size() >= 1 ) { syntax.setNames( aliases.toArray( new String[0] ) ); } } // Description Element descriptionElement = element.element( DESCRIPTION_TAG ); if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$ { syntax.setDescription( descriptionElement.getText() ); } // Obsolete Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG ); if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { syntax.setObsolete( readBoolean( obsoleteAttribute.getValue() ) ); } // Human Readible Attribute humanReadibleAttribute = element.attribute( HUMAN_READABLE_TAG ); if ( ( humanReadibleAttribute != null ) && ( !humanReadibleAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { syntax.setHumanReadable( readBoolean( humanReadibleAttribute.getValue() ) ); } // Adding the syntax to the schema schema.addSyntax( syntax ); } /** * Reads a boolean value * * @param value * the value * @return * the boolean value * @throws XMLSchemaFileImportException * if the boolean could not be read */ private static boolean readBoolean( String value ) throws XMLSchemaFileImportException { if ( value.equals( BOOLEAN_TRUE ) ) { return true; } else if ( value.equals( BOOLEAN_FALSE ) ) { return false; } else { throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.76" ) ); //$NON-NLS-1$ } } /** * This enum represents the different types of schema files. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum SchemaFileType { SINGLE, MULTIPLE }; /** * Gets the type of file. * * @param path * the path of the file * @return * the type of the file * @throws XMLSchemaFileImportException */ public static SchemaFileType getSchemaFileType( InputStream inputStream, String path ) throws XMLSchemaFileImportException { SAXReader reader = new SAXReader(); Document document = null; try { document = reader.read( inputStream ); } catch ( DocumentException e ) { throw new XMLSchemaFileImportException( NLS.bind( Messages .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$ } Element rootElement = document.getRootElement(); if ( rootElement.getName().equals( SCHEMA_TAG ) ) { return SchemaFileType.SINGLE; } else if ( rootElement.getName().equals( SCHEMAS_TAG ) ) { return SchemaFileType.MULTIPLE; } else { throw new XMLSchemaFileImportException( NLS.bind( Messages .getString( "XMLSchemaFileImporter.NotValidSchema" ), new String[] { path } ) ); //$NON-NLS-1$ } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImportException.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImportException.java
/* * 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.studio.schemaeditor.model.io; /** * This class represents the OpenLdapSchemaFileImportException. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenLdapSchemaFileImportException extends Exception { private static final long serialVersionUID = 1L; /** * Creates a new instance of OpenLdapSchemaFileImportException. * * @param message * the message * @param cause * the cause */ public OpenLdapSchemaFileImportException( String message, Exception cause ) { super( message, cause ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
/* * 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.studio.schemaeditor.model.io; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Collectors; import java.util.stream.StreamSupport; import javax.naming.directory.SearchControls; import org.apache.directory.api.ldap.model.constants.LdapConstants; import org.apache.directory.api.ldap.model.constants.MetaSchemaConstants; import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.api.ldap.model.entry.Attribute; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.entry.Value; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum; import org.apache.directory.api.ldap.model.schema.UsageEnum; import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.io.ConnectionWrapper; import org.apache.directory.studio.connection.core.io.api.StudioSearchResult; import org.apache.directory.studio.connection.core.io.api.StudioSearchResultEnumeration; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.model.Schema; /** * A Schema Connector for ApacheDS. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ApacheDsSchemaConnector extends AbstractSchemaConnector implements SchemaConnector { /** * This enum represents the different types of nodes that can be found while * reading the schema from the DIT. */ private enum SchemaNodeTypes { ATTRIBUTE_TYPE, OBJECT_CLASS, MATCHING_RULE, SYNTAX, UNKNOWN } /** * {@inheritDoc} */ public void importSchema( Project project, StudioProgressMonitor monitor ) throws SchemaConnectorException { monitor.beginTask( Messages.getString( "ApacheDsSchemaConnector.FetchingSchema" ), 1 ); //$NON-NLS-1$ List<Schema> schemas = new ArrayList<Schema>(); project.setInitialSchema( schemas ); ConnectionWrapper wrapper = project.getConnection().getConnectionWrapper(); // Looking for all the defined schemas SearchControls constraintSearch = new SearchControls(); constraintSearch.setSearchScope( SearchControls.ONELEVEL_SCOPE ); StudioSearchResultEnumeration answer = wrapper .search( SchemaConstants.OU_SCHEMA, "(objectclass=metaSchema)", constraintSearch, DEREF_ALIAS_METHOD, //$NON-NLS-1$ //$NON-NLS-2$ HANDLE_REFERALS_METHOD, null, monitor, null ); if ( answer != null ) { try { while ( answer.hasMore() ) { StudioSearchResult searchResult = answer.next(); // Getting the 'cn' Attribute Attribute cnAttribute = searchResult.getEntry() .get( SchemaConstants.CN_AT ); // Looping on the values if ( cnAttribute != null ) { for ( Value cnValue : cnAttribute ) { Schema schema = getSchema( wrapper, cnValue.getString(), monitor ); schema.setProject( project ); schemas.add( schema ); } } } } catch ( Exception e ) { throw new SchemaConnectorException( e ); } } monitor.worked( 1 ); } /** * {@inheritDoc} */ public boolean isSuitableConnector( Connection connection, StudioProgressMonitor monitor ) { ConnectionWrapper wrapper = connection.getConnectionWrapper(); SearchControls constraintSearch = new SearchControls(); constraintSearch.setSearchScope( SearchControls.OBJECT_SCOPE ); constraintSearch.setReturningAttributes( new String[] { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES } ); StudioSearchResultEnumeration answer = wrapper.search( "", LdapConstants.OBJECT_CLASS_STAR, constraintSearch, //$NON-NLS-1$ //$NON-NLS-2$ DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor, null ); if ( answer != null ) { try { if ( answer.hasMore() ) { Entry entry = answer.next().getEntry(); Attribute vendorNameAttribute = entry.get( SchemaConstants.VENDOR_NAME_AT ); if ( vendorNameAttribute == null ) { return false; } if ( vendorNameAttribute.size() != 1 ) { return false; } String vendorName = null; try { vendorName = vendorNameAttribute.getString(); } catch ( LdapInvalidAttributeValueException e ) { return false; } return ( ( vendorName != null ) && vendorName.equalsIgnoreCase( "Apache Software Foundation" ) ); //$NON-NLS-1$ } } catch ( LdapException e ) { monitor.reportError( e ); } } return false; } private static Schema getSchema( ConnectionWrapper wrapper, String name, StudioProgressMonitor monitor ) throws LdapException { monitor.subTask( name ); // Creating the schema Schema schema = new Schema( name ); // Looking for the nodes of the schema SearchControls constraintSearch = new SearchControls(); constraintSearch.setSearchScope( SearchControls.SUBTREE_SCOPE ); StudioSearchResultEnumeration answer = wrapper.search( "cn=" + name + ", ou=schema", LdapConstants.OBJECT_CLASS_STAR, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor, null ); if ( answer != null ) { try { while ( answer.hasMore() ) { Entry entry = answer.next().getEntry(); switch ( getNodeType( entry ) ) { case ATTRIBUTE_TYPE: AttributeType at = createAttributeType( entry ); at.setSchemaName( name ); schema.addAttributeType( at ); break; case OBJECT_CLASS: ObjectClass oc = createObjectClass( entry ); oc.setSchemaName( name ); schema.addObjectClass( oc ); break; case MATCHING_RULE: MatchingRule mr = createMatchingRule( entry ); mr.setSchemaName( name ); schema.addMatchingRule( mr ); break; case SYNTAX: LdapSyntax syntax = createSyntax( entry ); syntax.setSchemaName( name ); schema.addSyntax( syntax ); break; default: break; } } } catch ( LdapInvalidAttributeValueException e ) { monitor.reportError( e ); } } return schema; } /** * Gets the Type of node of the given SearchResult. * * @param entry the SearchResult to be identified * @return the Type of node */ private static SchemaNodeTypes getNodeType( Entry entry ) { if ( entry.hasObjectClass( SchemaConstants.META_ATTRIBUTE_TYPE_OC ) ) { return SchemaNodeTypes.ATTRIBUTE_TYPE; } else if ( entry.hasObjectClass( SchemaConstants.META_OBJECT_CLASS_OC ) ) { return SchemaNodeTypes.OBJECT_CLASS; } else if ( entry.hasObjectClass( SchemaConstants.META_MATCHING_RULE_OC ) ) { return SchemaNodeTypes.MATCHING_RULE; } else if ( entry.hasObjectClass( SchemaConstants.META_SYNTAX_OC ) ) { return SchemaNodeTypes.SYNTAX; } else { return SchemaNodeTypes.UNKNOWN; } } /** * Create the AttributeTypeImpl associated with the given SearchResult. * * @param entry the search result entry * @return the AttributeTypeImpl associated with the SearchResult, or null if no * AttributeTypeImpl could be created * @throws LdapInvalidAttributeValueException */ private static AttributeType createAttributeType( Entry entry ) throws LdapInvalidAttributeValueException { AttributeType at = new AttributeType( getStringValue( entry, MetaSchemaConstants.M_OID_AT ) ); at.setNames( getStringValues( entry, MetaSchemaConstants.M_NAME_AT ) ); at.setDescription( getStringValue( entry, MetaSchemaConstants.M_DESCRIPTION_AT ) ); at.setObsolete( getBooleanValue( entry, MetaSchemaConstants.M_OBSOLETE_AT ) ); at.setSuperiorOid( getStringValue( entry, MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT ) ); at.setUsage( getUsage( entry ) ); at.setSyntaxOid( getStringValue( entry, MetaSchemaConstants.M_SYNTAX_AT ) ); at.setSyntaxLength( getSyntaxLength( entry ) ); at.setCollective( getBooleanValue( entry, MetaSchemaConstants.M_COLLECTIVE_AT ) ); at.setSingleValued( getBooleanValue( entry, MetaSchemaConstants.M_SINGLE_VALUE_AT ) ); at.setUserModifiable( getBooleanValue( entry, MetaSchemaConstants.M_NO_USER_MODIFICATION_AT ) ); at.setEqualityOid( getStringValue( entry, MetaSchemaConstants.M_EQUALITY_AT ) ); at.setOrderingOid( getStringValue( entry, MetaSchemaConstants.M_ORDERING_AT ) ); at.setSubstringOid( getStringValue( entry, MetaSchemaConstants.M_SUBSTR_AT ) ); return at; } /** * Create the ObjectClassImpl associated with the given SearchResult. * * @param sr the SearchResult * @return the ObjectClassImpl associated with the SearchResult, or null if no * ObjectClassImpl could be created * @throws LdapInvalidAttributeValueException */ private static ObjectClass createObjectClass( Entry sr ) throws LdapInvalidAttributeValueException { ObjectClass oc = new ObjectClass( getStringValue( sr, MetaSchemaConstants.M_OID_AT ) ); oc.setNames( getStringValues( sr, MetaSchemaConstants.M_NAME_AT ) ); oc.setDescription( getStringValue( sr, MetaSchemaConstants.M_DESCRIPTION_AT ) ); oc.setObsolete( getBooleanValue( sr, MetaSchemaConstants.M_OBSOLETE_AT ) ); oc.setSuperiorOids( getStringValues( sr, MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT ) ); oc.setType( getType( sr ) ); oc.setMayAttributeTypeOids( getStringValues( sr, MetaSchemaConstants.M_MAY_AT ) ); oc.setMustAttributeTypeOids( getStringValues( sr, MetaSchemaConstants.M_MUST_AT ) ); return oc; } /** * Create the MatchingRule associated with the given SearchResult. * * @param entry the SearchResult * @return the MatchingRule associated with the SearchResult, or null if no * ObjectClass could be created * @throws LdapInvalidAttributeValueException */ private static MatchingRule createMatchingRule( Entry entry ) throws LdapInvalidAttributeValueException { MatchingRule mr = new MatchingRule( getStringValue( entry, MetaSchemaConstants.M_OID_AT ) ); mr.setNames( getStringValues( entry, MetaSchemaConstants.M_NAME_AT ) ); mr.setDescription( getStringValue( entry, MetaSchemaConstants.M_DESCRIPTION_AT ) ); mr.setObsolete( getBooleanValue( entry, MetaSchemaConstants.M_OBSOLETE_AT ) ); mr.setSyntaxOid( getStringValue( entry, MetaSchemaConstants.M_SYNTAX_AT ) ); return mr; } /** * Create the MatchingRule associated with the given SearchResult. * * @param entry the SearchResult * @return the MatchingRule associated with the SearchResult, or null if no * ObjectClass could be created * @throws LdapInvalidAttributeValueException */ private static LdapSyntax createSyntax( Entry entry ) throws LdapInvalidAttributeValueException { LdapSyntax syntax = new LdapSyntax( getStringValue( entry, MetaSchemaConstants.M_OID_AT ) ); syntax.setNames( getStringValues( entry, MetaSchemaConstants.M_NAME_AT ) ); syntax.setDescription( getStringValue( entry, MetaSchemaConstants.M_DESCRIPTION_AT ) ); syntax.setObsolete( getBooleanValue( entry, MetaSchemaConstants.M_OBSOLETE_AT ) ); syntax.setHumanReadable( isHumanReadable( entry ) ); return syntax; } /** * Gets the usage of the attribute type contained a SearchResult. * * @param sr the SearchResult * @return the usage of the attribute type */ private static UsageEnum getUsage( Entry entry ) throws LdapInvalidAttributeValueException { Attribute at = entry.get( MetaSchemaConstants.M_USAGE_AT ); if ( at == null ) { return UsageEnum.USER_APPLICATIONS; } else { try { return UsageEnum.getUsage( at.getString() ); } catch ( IllegalArgumentException e ) { return UsageEnum.USER_APPLICATIONS; } catch ( NullPointerException e ) { return UsageEnum.USER_APPLICATIONS; } } } /** * Gets the syntax length of the attribute type contained a SearchResult. * * @param entry the SearchResult * @return the syntax length of the attribute type, or -1 if no syntax length was found * @throws LdapInvalidAttributeValueException if an error occurs when searching in the SearchResult */ private static int getSyntaxLength( Entry entry ) throws LdapInvalidAttributeValueException { Attribute at = entry.get( MetaSchemaConstants.M_LENGTH_AT ); if ( at == null ) { return -1; } else { try { return Integer.parseInt( at.getString() ); } catch ( NumberFormatException e ) { return -1; } } } /** * Gets the String value of a Schema element of an attribute type contained in a SearchResult. * * @param sr the SearchResult * @param schemaElement The Schema Element we are looking for * @return The String value if found * @throws LdapInvalidAttributeValueException */ private static String getStringValue( Entry entry, String schemaElement ) throws LdapInvalidAttributeValueException { Attribute at = entry.get( schemaElement ); if ( at == null ) { return null; } else { return at.getString(); } } /** * Gets the Boolean value for a Schema element of an attribute type contained in a SearchResult. * * @param entry the SearchResult * @param schemaElement The Schema Element we are looking for * @return The boolean value if found * @throws LdapInvalidAttributeValueException */ private static boolean getBooleanValue( Entry entry, String schemaElement ) throws LdapInvalidAttributeValueException { Attribute at = entry.get( schemaElement ); if ( at == null ) { return false; } else { return Boolean.parseBoolean( at.getString() ); } } /** * Gets the list of values for a schema element of an object class contained in a SearchResult. * * @param entry the SearchResult * @param schemaElement The Schema Element we are looking for * @return the optional attribute types of the attribute type, or an empty array if no optional attribute type was found */ private static List<String> getStringValues( Entry entry, String schemaElement ) { Attribute at = entry.get( schemaElement ); Spliterator<Value> spliterator = Optional.ofNullable( at ).map( Attribute::spliterator ).orElseGet( Spliterators::emptySpliterator ); return StreamSupport.stream( spliterator, false ).map( Value::getString ).collect( Collectors.toList() ); } /** * Gets the type of the object class contained a SearchResult. * * @param entry the SearchResult * @return the type of the object class * @throws LdapInvalidAttributeValueException */ private static ObjectClassTypeEnum getType( Entry entry ) throws LdapInvalidAttributeValueException { Attribute at = entry.get( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT ); if ( at == null ) { return ObjectClassTypeEnum.STRUCTURAL; } else { try { return ObjectClassTypeEnum.getClassType( at.getString() ); } catch ( IllegalArgumentException e ) { return ObjectClassTypeEnum.STRUCTURAL; } catch ( NullPointerException e ) { return ObjectClassTypeEnum.STRUCTURAL; } } } /** * Gets whether or not the schema object contained a SearchResult is obsolete. * * @param entry the SearchResult * @return true if the schema object is obsolete, false if not * @throws LdapInvalidAttributeValueException */ private static boolean isHumanReadable( Entry entry ) throws LdapInvalidAttributeValueException { Attribute at = entry.get( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT ); if ( at == null ) { return false; } else { return !Boolean.parseBoolean( at.getString() ); } } /** * {@inheritDoc} */ public void exportSchema( Project project, StudioProgressMonitor monitor ) throws SchemaConnectorException { // TODO Auto-generated method stub } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/Messages.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/Messages.java
/* * 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.studio.schemaeditor.model.io; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileExporter.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileExporter.java
/* * 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.studio.schemaeditor.model.io; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaObjectRenderer; import org.apache.directory.api.ldap.model.schema.SchemaObjectSorter; import org.apache.directory.studio.schemaeditor.model.Schema; /** * This class is used to export a Schema file into the OpenLDAP Format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenLdapSchemaFileExporter { /** * Converts the given schema to its source code representation * in OpenLDAP Schema file format. * * @param schema * the schema to convert * @return * the corresponding source code representation */ public static String toSourceCode( Schema schema ) { StringBuffer sb = new StringBuffer(); for ( AttributeType at : SchemaObjectSorter.hierarchicalOrdered( schema.getAttributeTypes() ) ) { sb.append( toSourceCode( at ) ); sb.append( "\n" ); //$NON-NLS-1$ } for ( ObjectClass oc : SchemaObjectSorter.sortObjectClasses( schema.getObjectClasses() ) ) { sb.append( toSourceCode( oc ) ); sb.append( "\n" ); //$NON-NLS-1$ } return sb.toString(); } /** * Converts the given attribute type to its source code representation * in OpenLDAP Schema file format. * * @param at * the attribute type to convert * @return * the corresponding source code representation */ public static String toSourceCode( AttributeType at ) { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( at ); } /** * Converts the given object class to its source code representation * in OpenLDAP Schema file format. * * @param at * the object class to convert * @return * the corresponding source code representation */ public static String toSourceCode( ObjectClass oc ) { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( oc ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
/* * 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.studio.schemaeditor.model.io; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; import java.util.List; import java.util.Scanner; import java.util.regex.MatchResult; import org.apache.directory.api.ldap.model.exception.LdapSchemaException; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.parsers.OpenLdapSchemaParser; import org.apache.directory.studio.schemaeditor.model.Schema; import org.eclipse.osgi.util.NLS; /** * This class is used to import a Schema file in the OpenLDAP Format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenLdapSchemaFileImporter { /** * Extracts the Schema from the given path. * * @param inputStream * the {@link InputStream} of the file. * @param path * the path of the file. * @return * the corresponding schema * @throws OpenLdapSchemaFileImportException * if an error occurrs when importing the schema */ public static Schema getSchema( InputStream inputStream, String path ) throws OpenLdapSchemaFileImportException { OpenLdapSchemaParser parser = new OpenLdapSchemaParser(); try { parser.parse( inputStream ); } catch ( IOException e ) { throw new OpenLdapSchemaFileImportException( NLS.bind( Messages .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$ } catch ( ParseException | LdapSchemaException e ) { ExceptionMessage exceptionMessage = parseExceptionMessage( e.getMessage() ); throw new OpenLdapSchemaFileImportException( NLS.bind( Messages .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[] //$NON-NLS-1$ { path } ) + ( exceptionMessage == null ? "" : NLS.bind( Messages //$NON-NLS-1$ .getString( "OpenLdapSchemaFileImporter.ErrorMessage" ), new String[] //$NON-NLS-1$ { exceptionMessage.lineNumber, exceptionMessage.columnNumber, exceptionMessage.cause } ) ), e ); } String schemaName = getNameFromPath( path ); Schema schema = new Schema( schemaName ); List<?> ats = parser.getAttributeTypes(); for ( int i = 0; i < ats.size(); i++ ) { AttributeType at = convertAttributeType( ( AttributeType ) ats.get( i ) ); at.setSchemaName( schemaName ); schema.addAttributeType( at ); } List<?> ocs = parser.getObjectClasses(); for ( int i = 0; i < ocs.size(); i++ ) { ObjectClass oc = convertObjectClass( ( ObjectClass ) ocs.get( i ) ); oc.setSchemaName( schemaName ); schema.addObjectClass( oc ); } return schema; } /** * Gets the name of the file. * * @param path * the path * @return * the name of the file. */ private static String getNameFromPath( String path ) { File file = new File( path ); String fileName = file.getName(); if ( fileName.endsWith( ".schema" ) ) //$NON-NLS-1$ { String[] fileNameSplitted = fileName.split( "\\." ); //$NON-NLS-1$ return fileNameSplitted[0]; } return fileName; } /** * Convert the given AttributeTypeLiteral into its AttributeTypeImpl representation. * * @param at * the AttributeTypeLiteral * @return * the corresponding AttributeTypeImpl */ private static AttributeType convertAttributeType( AttributeType at ) { AttributeType newAT = new AttributeType( at.getOid() ); newAT.setNames( at.getNames() ); newAT.setDescription( at.getDescription() ); newAT.setSuperiorOid( at.getSuperiorOid() ); newAT.setUsage( at.getUsage() ); newAT.setSyntaxOid( at.getSyntaxOid() ); newAT.setSyntaxLength( at.getSyntaxLength() ); newAT.setObsolete( at.isObsolete() ); newAT.setSingleValued( at.isSingleValued() ); newAT.setCollective( at.isCollective() ); newAT.setUserModifiable( at.isUserModifiable() ); newAT.setEqualityOid( at.getEqualityOid() ); newAT.setOrderingOid( at.getOrderingOid() ); newAT.setSubstringOid( at.getSubstringOid() ); return newAT; } /** * Convert the given ObjectClassLiteral into its ObjectClassImpl representation. * * @param oc * the ObjectClassLiteral * @return * the corresponding ObjectClassImpl */ private static ObjectClass convertObjectClass( ObjectClass oc ) { ObjectClass newOC = new ObjectClass( oc.getOid() ); newOC.setNames( oc.getNames() ); newOC.setDescription( oc.getDescription() ); newOC.setSuperiorOids( oc.getSuperiorOids() ); newOC.setType( oc.getType() ); newOC.setObsolete( oc.isObsolete() ); newOC.setMustAttributeTypeOids( oc.getMustAttributeTypeOids() ); newOC.setMayAttributeTypeOids( oc.getMayAttributeTypeOids() ); return newOC; } /** * Parses the exception message and fills an {@link ExceptionMessage}. * * @param message * the exception message to parse * @return * the corresponding {@link ExceptionMessage}, or <code>null</code> */ private static ExceptionMessage parseExceptionMessage( String message ) { Scanner scanner = new Scanner( new ByteArrayInputStream( message.getBytes() ) ); String foundString = scanner.findWithinHorizon( ".*line (\\d+):(\\d+): *([^\\n]*).*", message.length() ); //$NON-NLS-1$ if ( foundString != null ) { MatchResult result = scanner.match(); if ( result.groupCount() == 3 ) { ExceptionMessage exceptionMessage = new ExceptionMessage(); exceptionMessage.lineNumber = result.group( 1 ); exceptionMessage.columnNumber = result.group( 2 ); exceptionMessage.cause = result.group( 3 ); scanner.close(); return exceptionMessage; } } scanner.close(); return null; } private static class ExceptionMessage { String lineNumber; String columnNumber; String cause; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
/* * 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.studio.schemaeditor.model.io; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.apache.directory.studio.schemaeditor.PluginUtils; import org.apache.directory.studio.schemaeditor.model.Project; import org.apache.directory.studio.schemaeditor.model.ProjectType; import org.apache.directory.studio.schemaeditor.model.Schema; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; import org.eclipse.osgi.util.NLS; /** * This class is used to import a Project file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ProjectsImporter { // The tags private static final String PROJECT_TAG = "project"; //$NON-NLS-1$ private static final String PROJECTS_TAG = "projects"; //$NON-NLS-1$ private static final String NAME_TAG = "name"; //$NON-NLS-1$ private static final String SCHEMAS_TAG = "schemas"; //$NON-NLS-1$ private static final String TYPE_TAG = "type"; //$NON-NLS-1$ private static final String CONNECTION_TAG = "connection"; //$NON-NLS-1$ private static final String SCHEMA_CONNECTOR_TAG = "schemaConnector"; //$NON-NLS-1$ private static final String SCHEMA_BACKUP_TAG = "schemaBackup"; //$NON-NLS-1$ /** * Extract the project from the given path * * @param inputStream * the {@link InputStream} of the file * @param path * the path of the file * @return * the corresponding project * @throws ProjectsImportException * if an error occurs when importing the project */ public static Project getProject( InputStream inputStream, String path ) throws ProjectsImportException { Project project = new Project(); SAXReader reader = new SAXReader(); Document document = null; try { document = reader.read( inputStream ); } catch ( DocumentException e ) { throw new ProjectsImportException( NLS.bind( Messages.getString( "ProjectsImporter.NotReadCorrectly" ), //$NON-NLS-1$ new String[] { path } ) ); } Element rootElement = document.getRootElement(); if ( !rootElement.getName().equals( PROJECT_TAG ) ) { throw new ProjectsImportException( NLS.bind( Messages.getString( "ProjectsImporter.NotValidProject" ), //$NON-NLS-1$ new String[] { path } ) ); } readProject( rootElement, project, path ); return project; } /** * Extract the projects from the given input stream * * @param inputStream * the {@link InputStream} of the file * @param path * the path of the file * @return * the corresponding projects * @throws ProjectsImportException * if an error occurs when importing the project */ public static Project[] getProjects( InputStream inputStream, String path ) throws ProjectsImportException { List<Project> projects = new ArrayList<Project>(); SAXReader reader = new SAXReader(); Document document = null; try { document = reader.read( inputStream ); } catch ( DocumentException e ) { PluginUtils.logError( NLS.bind( Messages.getString( "ProjectsImporter.NotReadCorrectly" ), new String[] //$NON-NLS-1$ { path } ), e ); throw new ProjectsImportException( NLS.bind( Messages.getString( "ProjectsImporter.NotReadCorrectly" ), //$NON-NLS-1$ new String[] { path } ) ); } Element rootElement = document.getRootElement(); if ( !rootElement.getName().equals( PROJECTS_TAG ) ) { throw new ProjectsImportException( NLS.bind( Messages.getString( "ProjectsImporter.NotValidProject" ), //$NON-NLS-1$ new String[] { path } ) ); } for ( Iterator<?> i = rootElement.elementIterator( PROJECT_TAG ); i.hasNext(); ) { Element projectElement = ( Element ) i.next(); Project project = new Project(); readProject( projectElement, project, path ); projects.add( project ); } return projects.toArray( new Project[0] ); } /** * Reads a project. * * @param element * the element * @param project * the project * @param path * the path * @throws ProjectsImportException * if an error occurs when importing the project */ private static void readProject( Element element, Project project, String path ) throws ProjectsImportException { // Name Attribute nameAttribute = element.attribute( NAME_TAG ); if ( ( nameAttribute != null ) && ( !nameAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { project.setName( nameAttribute.getValue() ); } // Type Attribute typeAttribute = element.attribute( TYPE_TAG ); if ( ( typeAttribute != null ) && ( !typeAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { try { project.setType( ProjectType.valueOf( typeAttribute.getValue() ) ); } catch ( IllegalArgumentException e ) { throw new ProjectsImportException( Messages.getString( "ProjectsImporter.NotConvertableValue" ) ); //$NON-NLS-1$ } } // If project is an Online Schema Project if ( project.getType().equals( ProjectType.ONLINE ) ) { // Connection Attribute connectionAttribute = element.attribute( CONNECTION_TAG ); if ( ( connectionAttribute != null ) && ( !connectionAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { project.setConnection( PluginUtils.getConnection( connectionAttribute.getValue() ) ); } // Schema Connector Attribute schemaConnectorAttribute = element.attribute( SCHEMA_CONNECTOR_TAG ); if ( ( schemaConnectorAttribute != null ) && ( !schemaConnectorAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$ { String schemaConnectorId = schemaConnectorAttribute.getValue(); SchemaConnector schemaConnector = null; List<SchemaConnector> schemaConnectors = PluginUtils.getSchemaConnectors(); for ( SchemaConnector sc : schemaConnectors ) { if ( sc.getId().equalsIgnoreCase( schemaConnectorId ) ) { schemaConnector = sc; } } if ( schemaConnector == null ) { throw new ProjectsImportException( NLS.bind( Messages .getString( "ProjectsImporter.NoSchemaConnectorIDFound" ), new String[] //$NON-NLS-1$ { schemaConnectorId } ) ); //$NON-NLS-1$ } project.setSchemaConnector( schemaConnector ); } // SchemaBackup Element schemaBackupElement = element.element( SCHEMA_BACKUP_TAG ); if ( schemaBackupElement != null ) { Element schemasElement = schemaBackupElement.element( SCHEMAS_TAG ); if ( schemasElement != null ) { Schema[] schemas = null; try { schemas = XMLSchemaFileImporter.readSchemas( schemasElement, path ); for ( Schema schema : schemas ) { schema.setProject( project ); } } catch ( XMLSchemaFileImportException e ) { throw new ProjectsImportException( Messages.getString( "ProjectsImporter.NotConvertableSchema" ) ); //$NON-NLS-1$ } project.setInitialSchema( Arrays.asList( schemas ) ); } } } // Schemas Element schemasElement = element.element( SCHEMAS_TAG ); if ( schemasElement != null ) { Schema[] schemas = null; try { schemas = XMLSchemaFileImporter.readSchemas( schemasElement, path ); } catch ( XMLSchemaFileImportException e ) { throw new ProjectsImportException( Messages.getString( "ProjectsImporter.NotConvertableSchema" ) ); //$NON-NLS-1$ } for ( Schema schema : schemas ) { schema.setProject( project ); project.getSchemaHandler().addSchema( schema ); } } } /** * This enum represents the different types of project files. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum ProjectFileType { SINGLE, MULTIPLE } /** * Gets the type of file. * * @param inputStream * the {@link InputStream} of the file * @param path * the path of the file * @return * the type of the file * @throws ProjectsImportException */ public static ProjectFileType getProjectFileType( InputStream inputStream, String path ) throws ProjectsImportException { SAXReader reader = new SAXReader(); Document document = null; try { document = reader.read( inputStream ); } catch ( DocumentException e ) { throw new ProjectsImportException( NLS.bind( Messages.getString( "ProjectsImporter.NotReadCorrectly" ), //$NON-NLS-1$ new String[] { path } ) ); } Element rootElement = document.getRootElement(); if ( rootElement.getName().equals( PROJECT_TAG ) ) { return ProjectFileType.SINGLE; } else if ( rootElement.getName().equals( PROJECTS_TAG ) ) { return ProjectFileType.MULTIPLE; } else { throw new ProjectsImportException( NLS.bind( Messages.getString( "ProjectsImporter.NotValidProject" ), //$NON-NLS-1$ new String[] { path } ) ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImportException.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImportException.java
/* * 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.studio.schemaeditor.model.io; /** * This class represents the ProjectsImportException. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ProjectsImportException extends Exception { private static final long serialVersionUID = 1L; /** * Creates a new instance of ProjectsImportException. * * @param message * the message */ public ProjectsImportException( String message ) { super( message ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileExporter.java
plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileExporter.java
/* * 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.studio.schemaeditor.model.io; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.List; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum; import org.apache.directory.api.ldap.model.schema.UsageEnum; import org.apache.directory.studio.schemaeditor.model.Schema; import org.dom4j.Branch; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.io.OutputFormat; import org.dom4j.io.XMLWriter; /** * This class is used to export a Schema file into the XML Format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class XMLSchemaFileExporter { // The Tags private static final String ALIAS_TAG = "alias"; //$NON-NLS-1$ private static final String ALIASES_TAG = "aliases"; //$NON-NLS-1$ private static final String ATTRIBUTE_TYPE_TAG = "attributetype"; //$NON-NLS-1$ private static final String ATTRIBUTE_TYPES_TAG = "attributetypes"; //$NON-NLS-1$ private static final String BOOLEAN_FALSE = "false"; //$NON-NLS-1$ private static final String BOOLEAN_TRUE = "true"; //$NON-NLS-1$ private static final String COLLECTIVE_TAG = "collective"; //$NON-NLS-1$ private static final String DESCRIPTION_TAG = "description"; //$NON-NLS-1$ private static final String EQUALITY_TAG = "equality"; //$NON-NLS-1$ private static final String HUMAN_READABLE_TAG = "humanreadable"; //$NON-NLS-1$ private static final String MANDATORY_TAG = "mandatory"; //$NON-NLS-1$ private static final String MATCHING_RULE_TAG = "matchingrule"; //$NON-NLS-1$ private static final String MATCHING_RULES_TAG = "matchingrules"; //$NON-NLS-1$ private static final String NAME_TAG = "name"; //$NON-NLS-1$ private static final String NO_USER_MODIFICATION_TAG = "nousermodification"; //$NON-NLS-1$ private static final String OBJECT_CLASS_TAG = "objectclass"; //$NON-NLS-1$ private static final String OBJECT_CLASSES_TAG = "objectclasses"; //$NON-NLS-1$ private static final String OBSOLETE_TAG = "obsolete"; //$NON-NLS-1$ private static final String OID_TAG = "oid"; //$NON-NLS-1$ private static final String OPTIONAL_TAG = "optional"; //$NON-NLS-1$ private static final String ORDERING_TAG = "ordering"; //$NON-NLS-1$ private static final String SCHEMA_TAG = "schema"; //$NON-NLS-1$ private static final String SCHEMAS_TAG = "schemas"; //$NON-NLS-1$ private static final String SINGLE_VALUE_TAG = "singlevalue"; //$NON-NLS-1$ private static final String SUBSTRING_TAG = "substring"; //$NON-NLS-1$ private static final String SUPERIOR_TAG = "superior"; //$NON-NLS-1$ private static final String SUPERIORS_TAG = "superiors"; //$NON-NLS-1$ private static final String SYNTAX_LENGTH_TAG = "syntaxlength"; //$NON-NLS-1$ private static final String SYNTAX_OID_TAG = "syntaxoid"; //$NON-NLS-1$ private static final String SYNTAX_TAG = "syntax"; //$NON-NLS-1$ private static final String SYNTAXES_TAG = "syntaxes"; //$NON-NLS-1$ private static final String TYPE_TAG = "type"; //$NON-NLS-1$ private static final String USAGE_TAG = "usage"; //$NON-NLS-1$ /** * Converts the given schema to its source code representation * in XML file format. * * @param schema * the schema to convert * @return * the corresponding source code representation * @throws IOException */ public static String toXml( Schema schema ) throws IOException { // Creating the Document Document document = DocumentHelper.createDocument(); // Adding the schema addSchema( schema, document ); // Creating the output stream we're going to put the XML in OutputStream os = new ByteArrayOutputStream(); OutputFormat outformat = OutputFormat.createPrettyPrint(); outformat.setEncoding( "UTF-8" ); //$NON-NLS-1$ // Writing the XML. XMLWriter writer = new XMLWriter( os, outformat ); writer.write( document ); writer.flush(); writer.close(); return os.toString(); } /** * Converts the given schemas to their source code representation * in one XML file format. * * @param schemas * the array of schemas to convert * @return * the corresponding source code representation * @throws IOException */ public static String toXml( Schema[] schemas ) throws IOException { // Creating the Document and the 'root' Element Document document = DocumentHelper.createDocument(); addSchemas( schemas, document ); // Creating the output stream we're going to put the XML in OutputStream os = new ByteArrayOutputStream(); OutputFormat outformat = OutputFormat.createPrettyPrint(); outformat.setEncoding( "UTF-8" ); //$NON-NLS-1$ // Writing the XML. XMLWriter writer = new XMLWriter( os, outformat ); writer.write( document ); writer.flush(); writer.close(); return os.toString(); } /** * Add the XML representation of the given schemas * to the given branch. * * @param schemas * the schemas * @param branch * the branch */ public static void addSchemas( Schema[] schemas, Branch branch ) { Element element = branch.addElement( SCHEMAS_TAG ); if ( schemas != null ) { for ( Schema schema : schemas ) { addSchema( schema, element ); } } } /** * Add the XML representation of the given schema * to the given branch. * * @param schema * the schema * @param branch * the branch */ public static void addSchema( Schema schema, Branch branch ) { Element element = branch.addElement( SCHEMA_TAG ); if ( schema != null ) { // Name String name = schema.getSchemaName(); if ( ( name != null ) && ( !name.equals( "" ) ) ) //$NON-NLS-1$ { element.addAttribute( NAME_TAG, name ); } // Attribute Types List<AttributeType> ats = schema.getAttributeTypes(); if ( ( ats != null ) && ( ats.size() >= 1 ) ) { Element attributeTypesNode = element.addElement( ATTRIBUTE_TYPES_TAG ); for ( AttributeType at : ats ) { toXml( at, attributeTypesNode ); } } // Object Classes List<ObjectClass> ocs = schema.getObjectClasses(); if ( ( ocs != null ) && ( ocs.size() >= 1 ) ) { Element objectClassesNode = element.addElement( OBJECT_CLASSES_TAG ); for ( ObjectClass oc : ocs ) { toXml( oc, objectClassesNode ); } } // Matching Rules List<MatchingRule> mrs = schema.getMatchingRules(); if ( ( mrs != null ) && ( mrs.size() >= 1 ) ) { Element matchingRulesNode = element.addElement( MATCHING_RULES_TAG ); for ( MatchingRule mr : mrs ) { toXml( mr, matchingRulesNode ); } } // Syntaxes List<LdapSyntax> syntaxes = schema.getSyntaxes(); if ( ( syntaxes != null ) && ( syntaxes.size() >= 1 ) ) { Element syntaxesNode = element.addElement( SYNTAXES_TAG ); for ( LdapSyntax syntax : syntaxes ) { toXml( syntax, syntaxesNode ); } } } } /** * Adds the given attribute type to its root Element. * * @param at * the attribute type * @param root * the root Element */ private static void toXml( AttributeType at, Element root ) { Element atNode = root.addElement( ATTRIBUTE_TYPE_TAG ); // OID String oid = at.getOid(); if ( ( oid != null ) && ( !oid.equals( "" ) ) ) //$NON-NLS-1$ { atNode.addAttribute( OID_TAG, oid ); } // Aliases List<String> aliases = at.getNames(); if ( ( aliases != null ) && ( aliases.size() >= 1 ) ) { Element aliasesNode = atNode.addElement( ALIASES_TAG ); for ( String alias : aliases ) { aliasesNode.addElement( ALIAS_TAG ).setText( alias ); } } // Description String description = at.getDescription(); if ( ( description != null ) && ( !description.equals( "" ) ) ) //$NON-NLS-1$ { atNode.addElement( DESCRIPTION_TAG ).setText( description ); } // Superior String superior = at.getSuperiorOid(); if ( ( superior != null ) && ( !superior.equals( "" ) ) ) //$NON-NLS-1$ { atNode.addElement( SUPERIOR_TAG ).setText( superior ); } // Usage UsageEnum usage = at.getUsage(); if ( usage != null ) { atNode.addElement( USAGE_TAG ).setText( usage.toString() ); } // Syntax String syntax = at.getSyntaxOid(); if ( ( syntax != null ) && ( !syntax.equals( "" ) ) ) //$NON-NLS-1$ { atNode.addElement( SYNTAX_TAG ).setText( syntax ); } // Syntax Length long syntaxLength = at.getSyntaxLength(); if ( syntaxLength > 0 ) { atNode.addElement( SYNTAX_LENGTH_TAG ).setText( "" + syntaxLength ); //$NON-NLS-1$ } // Obsolete if ( at.isObsolete() ) { atNode.addAttribute( OBSOLETE_TAG, BOOLEAN_TRUE ); } else { atNode.addAttribute( OBSOLETE_TAG, BOOLEAN_FALSE ); } // Single Value if ( at.isSingleValued() ) { atNode.addAttribute( SINGLE_VALUE_TAG, BOOLEAN_TRUE ); } else { atNode.addAttribute( SINGLE_VALUE_TAG, BOOLEAN_FALSE ); } // Collective if ( at.isCollective() ) { atNode.addAttribute( COLLECTIVE_TAG, BOOLEAN_TRUE ); } else { atNode.addAttribute( COLLECTIVE_TAG, BOOLEAN_FALSE ); } // No User Modification if ( at.isUserModifiable() ) { atNode.addAttribute( NO_USER_MODIFICATION_TAG, BOOLEAN_FALSE ); } else { atNode.addAttribute( NO_USER_MODIFICATION_TAG, BOOLEAN_TRUE ); } // Equality String equality = at.getEqualityOid(); if ( ( equality != null ) && ( !equality.equals( "" ) ) ) //$NON-NLS-1$ { atNode.addElement( EQUALITY_TAG ).setText( equality ); } // Ordering String ordering = at.getOrderingOid(); if ( ( ordering != null ) && ( !ordering.equals( "" ) ) ) //$NON-NLS-1$ { atNode.addElement( ORDERING_TAG ).setText( ordering ); } // Substring String substring = at.getSubstringOid(); if ( ( substring != null ) && ( !substring.equals( "" ) ) ) //$NON-NLS-1$ { atNode.addElement( SUBSTRING_TAG ).setText( substring ); } } /** * Adds the given object class to its root Element. * * @param oc * the object class to convert * @param root * the root Element */ private static void toXml( ObjectClass oc, Element root ) { Element ocNode = root.addElement( OBJECT_CLASS_TAG ); // OID String oid = oc.getOid(); if ( ( oid != null ) && ( !oid.equals( "" ) ) ) //$NON-NLS-1$ { ocNode.addAttribute( OID_TAG, oid ); } // Aliases List<String> aliases = oc.getNames(); if ( ( aliases != null ) && ( aliases.size() >= 1 ) ) { Element aliasesNode = ocNode.addElement( ALIASES_TAG ); for ( String alias : aliases ) { aliasesNode.addElement( ALIAS_TAG ).setText( alias ); } } // Description String description = oc.getDescription(); if ( ( description != null ) && ( !description.equals( "" ) ) ) //$NON-NLS-1$ { ocNode.addElement( DESCRIPTION_TAG ).setText( description ); } // Superiors List<String> superiors = oc.getSuperiorOids(); if ( ( superiors != null ) && ( superiors.size() >= 1 ) ) { Element superiorsNode = ocNode.addElement( SUPERIORS_TAG ); for ( String superior : superiors ) { superiorsNode.addElement( SUPERIOR_TAG ).setText( superior ); } } // Type ObjectClassTypeEnum type = oc.getType(); if ( type != null ) { ocNode.addElement( TYPE_TAG ).setText( type.toString() ); } // Obsolete if ( oc.isObsolete() ) { ocNode.addAttribute( OBSOLETE_TAG, BOOLEAN_TRUE ); } else { ocNode.addAttribute( OBSOLETE_TAG, BOOLEAN_FALSE ); } // Mandatory Attribute Types List<String> mandatoryATs = oc.getMustAttributeTypeOids(); if ( ( mandatoryATs != null ) && ( mandatoryATs.size() >= 1 ) ) { Element mandatoryNode = ocNode.addElement( MANDATORY_TAG ); for ( String mandatoryAT : mandatoryATs ) { mandatoryNode.addElement( ATTRIBUTE_TYPE_TAG ).setText( mandatoryAT ); } } // Optional Attribute Types List<String> optionalATs = oc.getMayAttributeTypeOids(); if ( ( optionalATs != null ) && ( optionalATs.size() >= 1 ) ) { Element optionalNode = ocNode.addElement( OPTIONAL_TAG ); for ( String optionalAT : optionalATs ) { optionalNode.addElement( ATTRIBUTE_TYPE_TAG ).setText( optionalAT ); } } } /** * Adds the given matching rule to its root Element. * * @param mr * the matching rule to convert * @param root * the root Element */ private static void toXml( MatchingRule mr, Element root ) { Element mrNode = root.addElement( MATCHING_RULE_TAG ); // OID String oid = mr.getOid(); if ( ( oid != null ) && ( !oid.equals( "" ) ) ) //$NON-NLS-1$ { mrNode.addAttribute( OID_TAG, oid ); } // Aliases List<String> aliases = mr.getNames(); if ( ( aliases != null ) && ( aliases.size() >= 1 ) ) { Element aliasesNode = mrNode.addElement( ALIASES_TAG ); for ( String alias : aliases ) { aliasesNode.addElement( ALIAS_TAG ).setText( alias ); } } // Description String description = mr.getDescription(); if ( ( description != null ) && ( !description.equals( "" ) ) ) //$NON-NLS-1$ { mrNode.addElement( DESCRIPTION_TAG ).setText( description ); } // Obsolete if ( mr.isObsolete() ) { mrNode.addAttribute( OBSOLETE_TAG, BOOLEAN_TRUE ); } else { mrNode.addAttribute( OBSOLETE_TAG, BOOLEAN_FALSE ); } // Syntax OID String syntaxOid = mr.getSyntaxOid(); if ( ( syntaxOid != null ) && ( !syntaxOid.equals( "" ) ) ) //$NON-NLS-1$ { mrNode.addElement( SYNTAX_OID_TAG ).setText( syntaxOid ); } } /** * Converts the given syntax to its source code representation * in XML file format. * * @param syntax * the syntax to convert * @param root * the root Element * @return * the corresponding source code representation */ private static void toXml( LdapSyntax syntax, Element root ) { Element syntaxNode = root.addElement( SYNTAX_TAG ); // OID String oid = syntax.getOid(); if ( ( oid != null ) && ( !oid.equals( "" ) ) ) //$NON-NLS-1$ { syntaxNode.addAttribute( OID_TAG, oid ); } // Aliases List<String> aliases = syntax.getNames(); if ( ( aliases != null ) && ( aliases.size() >= 1 ) ) { Element aliasesNode = syntaxNode.addElement( ALIASES_TAG ); for ( String alias : aliases ) { aliasesNode.addElement( ALIAS_TAG ).setText( alias ); } } // Description String description = syntax.getDescription(); if ( ( description != null ) && ( !description.equals( "" ) ) ) //$NON-NLS-1$ { syntaxNode.addElement( DESCRIPTION_TAG ).setText( description ); } // Obsolete if ( syntax.isObsolete() ) { syntaxNode.addAttribute( OBSOLETE_TAG, BOOLEAN_TRUE ); } else { syntaxNode.addAttribute( OBSOLETE_TAG, BOOLEAN_FALSE ); } // Human Readible if ( syntax.isHumanReadable() ) { syntaxNode.addAttribute( HUMAN_READABLE_TAG, BOOLEAN_TRUE ); } else { syntaxNode.addAttribute( HUMAN_READABLE_TAG, BOOLEAN_FALSE ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false