
it.tidalwave.netbeans.indexeddataobject.IndexedDataObjectCapabilitiesProvider Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* OpenBlueSky - NetBeans Platform Enhancements
* Copyright (C) 2006-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* 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.
*
***********************************************************************************************************************
*
* WWW: http://openbluesky.kenai.com
* SCM: https://kenai.com/hg/openbluesky~src
*
**********************************************************************************************************************/
package it.tidalwave.netbeans.indexeddataobject;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import it.tidalwave.netbeans.capabilitiesprovider.CapabilitiesProviderSupport;
import it.tidalwave.netbeans.indexedfilesystem.IndexedFileSystem;
import it.tidalwave.netbeans.indexeddataobject.impl.IndexedDataObjectIdentifiable;
import it.tidalwave.netbeans.indexeddataobject.impl.IndexedDataObjectReplace;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id: $
*
**********************************************************************************************************************/
public class IndexedDataObjectCapabilitiesProvider extends CapabilitiesProviderSupport
{
@Override @Nonnull
public Collection extends Object> createCapabilities (final @Nonnull T dataObject)
{
checkIndexed(dataObject.getPrimaryFile());
return Arrays.asList(new IndexedDataObjectIdentifiable(dataObject), new IndexedDataObjectReplace(dataObject));
}
/***************************************************************************
*
*
**************************************************************************/
private static void checkIndexed (final @Nonnull FileObject fileObject)
{
if (fileObject.getAttribute(IndexedFileSystem.ID_ATTRIBUTE) == null)
{
// would be nice to automatically index it, but often fails with
// java.io.IOException: java.lang.UnsupportedOperationException: Error in data system. Please reopen the bug #17014 with the following message:
// DataLoader:it.tidalwave.bluemarine.photo.PhotoDataLoader
// DataObject:it.tidalwave.bluemarine.photo.PhotoDataObject@1d2c12[AbstractFileObject@648a53[...]]
// PrimaryEntry:org.openide.loaders.FileEntry@648a53
// PrimaryFile:AbstractFileObject@648a53[...]
// SecondaryFile:MasterFileObject@708bac[...]
// Furthermore, automatic, incremental indexing would be slow and without this error
// you could miss the fact that batch indexing is not working.
// fileObject = indexedFileSystem.findResource(fileObject.getPath());
throw new IllegalArgumentException("fileObject is not indexed: " + fileObject);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy