List of usage examples for java.util HashSet isEmpty
public boolean isEmpty()
From source file:amie.keys.CSAKey.java
public void discoverConditionalKeysForComplexConditions(Graph graph, HashSet<Node> candidateKeys, Rule conditionRule, Set<Rule> output) { HashSet<Node> childrenCandidateKeys = new HashSet<>(); // System.out.println("candidates:" + candidateKeys); for (Node candidateKey : candidateKeys) { // System.out.println("candidate:" + candidateKey); if (candidateKey.toExplore) { // System.out.println("candidate:" + candidateKey); if (candidateKey.toExplore) { List<String> properties = candidateKey.mapToString(id2Property); // System.out.println("properties:"+properties); Rule amieRule = buildAMIERule(properties, conditionRule); // System.out.println("amieRule:" + amieRule.getDatalogFullRuleString()); boolean isConditionalKey = isConditionaKey(amieRule); if (amieRule.getSupport() < support || isConditionalKey) { candidateKey.toExplore = false; // System.out.println("key"); flagChildren(graph, candidateKey); }/*from w w w . j a v a 2s . co m*/ // If the rule is a conditional above the support // and there is no a simpler key already discovered // then output it if (isConditionalKey && amieRule.getSupport() >= support && !isSubsumedByKey(amieRule, conditionRule, conditions2Keys)) { synchronized (output) { output.add(amieRule); } //System.out.println(Utilities.formatKey(amieRule) + "\tThread " + Thread.currentThread().getId()); System.out.println(Utilities.formatKey(amieRule)); conditions2Keys.put(conditionRule, amieRule); } if (candidateKey.toExplore) { if (graph.graph.containsKey(candidateKey)) { childrenCandidateKeys.addAll(graph.graph.get(candidateKey)); } } } } else { flagChildren(graph, candidateKey); } } //System.out.println("OUT"); if (!childrenCandidateKeys.isEmpty()) { discoverConditionalKeysForComplexConditions(graph, childrenCandidateKeys, conditionRule, output); } }
From source file:com.emc.storageos.volumecontroller.impl.plugins.IsilonCommunicationInterface.java
/** * Generate Export Map for UnManagedFileSystem * Ignore exports with multiple exports for the same path * Ignore exports that have multiple security flavors * Ignore exports with multiple paths// w w w . j a v a 2 s . co m * Ignore exports not found on the array * Ignore exports which have the same internal export key ( <sec, perm, root-mapping>) * * @param umfs * @param expIdMap * @param storagePort * @param fsPath * @param isilonApi * @return boolean */ private boolean getUnManagedFSExportMap(UnManagedFileSystem umfs, HashMap<String, HashSet<Integer>> expIdMap, StoragePort storagePort, String fsPath, String zoneName, IsilonApi isilonApi) { UnManagedFSExportMap exportMap = new UnManagedFSExportMap(); boolean validExports = false; for (String expMapPath : expIdMap.keySet()) { HashSet<Integer> isilonExportIds = new HashSet<>(); _log.info("getUnManagedFSExportMap {} : export ids : {}", expMapPath, expIdMap.get(expMapPath)); isilonExportIds = expIdMap.get(expMapPath); if (isilonExportIds != null && !isilonExportIds.isEmpty()) { validExports = getUnManagedFSExportMap(umfs, isilonExportIds, storagePort, expMapPath, zoneName, isilonApi); } else { validExports = false; } if (!validExports) { // perform resetting umfs export map umfs.setFsUnManagedExportMap(exportMap); return false; } } return true; }
From source file:com.emc.storageos.volumecontroller.impl.plugins.IsilonCommunicationInterface.java
/** * Generate Export Map for UnManagedFileSystem * Ignore exports with multiple exports for the same path * Ignore exports that have multiple security flavors * Ignore exports with multiple paths//from w w w.j av a 2 s . c o m * Ignore exports not found on the array * Ignore exports which have the same internal export key ( <sec, perm, root-mapping>) * * @param umfs * @param expIdMap * @param storagePort * @param fsPath * @param isilonApi * @return boolean */ private List<UnManagedFileExportRule> getUnManagedFSExportRules(UnManagedFileSystem umfs, HashMap<String, HashSet<Integer>> expIdMap, StoragePort storagePort, String fsPath, String zoneName, IsilonApi isilonApi) { List<UnManagedFileExportRule> exportRules = new ArrayList<UnManagedFileExportRule>(); UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(_dbClient); List<UnManagedFileExportRule> exportRulesTemp = null; boolean isAllRulesValid = true; for (String expMapPath : expIdMap.keySet()) { HashSet<Integer> isilonExportIds = new HashSet<>(); _log.info("getUnManagedFSExportMap {} : export ids : {}", expMapPath, expIdMap.get(expMapPath)); isilonExportIds = expIdMap.get(expMapPath); if (isilonExportIds != null && !isilonExportIds.isEmpty()) { exportRulesTemp = getUnManagedFSExportRules(umfs, storagePort, isilonExportIds, expMapPath, zoneName, isilonApi); // validate export rules for each path if (null != exportRulesTemp && !exportRulesTemp.isEmpty()) { isAllRulesValid = validationUtility.validateUnManagedExportRules(exportRulesTemp, false); if (isAllRulesValid) { _log.info("Validating rules success for export {}", expMapPath); exportRules.addAll(exportRulesTemp); } else { _log.info("Ignroing the rules for export {}", expMapPath); isAllRulesValid = false; } } } } if (exportRules.isEmpty() || false == isAllRulesValid) { umfs.setHasExports(false); _log.info("FileSystem " + fsPath + " does not have valid ViPR exports "); exportRules.clear(); } return exportRules; }
From source file:com.pari.pcb.zip.ZIPProcessor.java
private void processConiguration(String fileName, FileInfo fileInfo, ZipEntry entry, ZipFile inZip) { String hostName = fileInfo.hostName; String osType = fileInfo.ostype; String version = fileInfo.version; ZIPFileResult fileResult = new ZIPFileResult(fileName); if (hostName == null) { fileResult.msg = "Unable to parse hostname"; fileResultMap.put(fileName, fileResult); return;/*from ww w . j av a 2 s . c o m*/ } else { if (hostName.contains("=")) { fileResult.msg = "Illegal hostname. Should not contain '='"; fileResult.hostName = hostName; fileResultMap.put(fileName, fileResult); return; } } fileResult.fileType = fileInfo.fileType; fileResult.hostName = fileInfo.hostName; fileResult.osType = fileInfo.ostype; String currOsType = osTypeMap.get(hostName); if ((currOsType != null) && (!currOsType.equals(osType))) { // TODO: // Different OS types from different files. Handle this later } osTypeMap.put(hostName, osType); if (runConfigMap.containsKey(hostName)) { fileResult.msg = "Duplicate Configuration for: " + hostName; logger.debug("\tDuplicate config for : " + hostName); // HostName already exists. Duplicate hostname. String oldFileName = runConfigFileMap.get(hostName); HashSet<String> hs = dupConfigsFileMap.get(hostName); if (hs == null) { hs = new HashSet<String>(); dupConfigsFileMap.put(hostName, hs); } hs.add(oldFileName); hs.add(fileName); runConfigFileMap.remove(hostName); runConfigMap.remove(hostName); } else { // Host name does not exist in running config. Check if it exists in the duplicates. HashSet<String> hs = dupConfigsFileMap.get(hostName); if ((hs != null) && !hs.isEmpty()) { logger.debug("\tDuplicate config for : " + hostName); fileResult.msg = "Duplicate Configuration for: " + hostName; // It exists in the duplicates. Add it to that list. hs.add(fileName); } else { // It does not exist in the duplicates either. try { addRunConfig(hostName, entry, inZip); runConfigFileMap.put(hostName, fileName); if ((version != null) && (versionNumberMap.get(hostName) == null)) { versionNumberMap.put(hostName, version); } } catch (Exception ex) { logger.error("Exception while saving running config for device " + hostName, ex); } } } fileResultMap.put(fileName, fileResult); }
From source file:com.pari.pcb.zip.ZIPProcessor.java
private void processVersionFile(String fileName, FileInfo fileInfo, ZipEntry entry, ZipFile inZip) { String hostName = fileInfo.hostName; String osType = fileInfo.ostype; String version = fileInfo.version; ZIPFileResult fileResult = new ZIPFileResult(fileName); fileResult.hostName = fileInfo.hostName; fileResult.osType = fileInfo.ostype; fileResult.fileType = fileInfo.fileType; if (hostName == null) { fileResult.msg = "Unable to parse hostname"; fileResultMap.put(fileName, fileResult); return;/*from w ww. j ava2s . c om*/ } else { if (hostName.contains("=")) { fileResult.msg = "Illegal hostname. Should not contain '='"; fileResult.hostName = hostName; fileResultMap.put(fileName, fileResult); return; } } String currOsType = osTypeMap.get(hostName); if ((currOsType != null) && (!currOsType.equals(osType))) { // TODO: // Different OS types from different files. Handle this later } osTypeMap.put(hostName, osType); if (showVerMap.containsKey(hostName)) { logger.debug("\tDuplicate version for : " + hostName); fileResult.msg = "Duplicate version for: " + hostName; // HostName already exists. Duplicate hostname. String oldFileName = showVerFileMap.get(hostName); HashSet<String> hs = dupVersionsFileMap.get(hostName); if (hs == null) { hs = new HashSet<String>(); dupVersionsFileMap.put(hostName, hs); } hs.add(oldFileName); hs.add(fileName); showVerFileMap.remove(hostName); showVerMap.remove(hostName); } else { // Host name does not exist in show versions list. Check if it exists in the duplicates. HashSet<String> hs = dupVersionsFileMap.get(hostName); if ((hs != null) && !hs.isEmpty()) { fileResult.msg = "Duplicate version for: " + hostName; logger.debug("\tDuplicate version for : " + hostName); hs.add(fileName); } else { // It does not exist in the duplicates either. try { if (entry == null && fileInfo.entryName != null) { entry = inZip.getEntry(fileInfo.entryName); } addShowVersion(hostName, entry, inZip); showVerFileMap.put(hostName, fileName); if (version != null) { versionNumberMap.put(hostName, version); } } catch (Exception ex) { logger.error("Exception while saving version for " + hostName, ex); } } } fileResultMap.put(fileName, fileResult); }
From source file:dao.DirectoryAuthorDaoDb.java
/** * This method lists all the authors for each directory that is in the directory list of this user * @param userId the user id - who is the author of all these directories * @param userLogin the user login - who is the author of all these directories * @param accessFlag the access flag that specifies the datasource master(1) or slave(0) * @return HashSet set is the list of authors * @throws BaseDaoException/*from w w w . ja v a 2s . c o m*/ */ public HashSet listAuthors(String userId, String userLogin, int accessFlag) throws BaseDaoException { if (RegexStrUtil.isNull(userId) || RegexStrUtil.isNull(userLogin)) { throw new BaseDaoException("params are null"); } /** Jboss methods * fqn - full qualified name */ Fqn fqn = cacheUtil.fqn(DbConstants.AUTHORS_LIST); Object obj = treeCache.get(fqn, userLogin); if (obj != null) { return (HashSet) obj; } /** * lists the directories given the userId */ List result = listDirectories(userId, userLogin); /** * Get scalability datasource for directory, diradmin, hdlogin not partitioned */ String sourceName = scalabilityManager.getReadZeroScalability(); ds = scalabilityManager.getSource(sourceName); if (ds == null) { throw new BaseDaoException("ds null, listAuthors() " + sourceName + " userId = " + userId); } /** * lists the authors for each directory that this user adminsters or is author of * eg: Directory_1 * Authors: * eg: Directory_2 * Authors: */ HashSet authors = new HashSet(); HashSet myResult = null; Connection conn = null; try { conn = ds.getConnection(); for (int i = 0; i < result.size(); i++) { myResult = listAuthorQuery.run(conn, ((Directory) result.get(i)).getValue(DbConstants.DIRECTORY_ID)); authors.add(myResult); } } catch (Exception e) { try { if (conn != null) { conn.close(); } } catch (Exception e1) { throw new BaseDaoException( "error while listing author query, conn.close()exception in listAuthorQuery " + userLogin, e1); } throw new BaseDaoException("exception in list authors, " + userLogin, e); } try { if (conn != null) { conn.close(); } } catch (Exception e2) { throw new BaseDaoException("conn.close exception after completing listAuthorQuery " + userLogin, e2); } if ((authors != null) && (!authors.isEmpty())) { treeCache.put(fqn, userLogin, authors); } return authors; }
From source file:com.android.leanlauncher.LauncherTransitionable.java
/** * A package was uninstalled. We take both the super set of packageNames * in addition to specific applications to remove, the reason being that * this can be called when a package is updated as well. In that scenario, * we only remove specific components from the workspace, where as * package-removal should clear all items by package name. * * @param reason if non-zero, the icons are not permanently removed, rather marked as disabled. * Implementation of the method from LauncherModel.Callbacks. *///from w ww . j a va2 s .co m @Override public void bindComponentsRemoved(final ArrayList<String> packageNames, final ArrayList<AppInfo> appInfos, final UserHandleCompat user, final int reason) { Runnable r = new Runnable() { public void run() { bindComponentsRemoved(packageNames, appInfos, user, reason); } }; if (waitUntilResume(r)) { return; } if (reason == 0) { HashSet<ComponentName> removedComponents = new HashSet<ComponentName>(); for (AppInfo info : appInfos) { removedComponents.add(info.componentName); } if (!packageNames.isEmpty()) { mWorkspace.removeItemsByPackageName(packageNames, user); } if (!removedComponents.isEmpty()) { mWorkspace.removeItemsByComponentName(removedComponents, user); } // Notify the drag controller mDragController.onAppsRemoved(packageNames, removedComponents); } else { mWorkspace.disableShortcutsByPackageName(packageNames, user, reason); } // Update AllApps if (mAppsCustomizeContent != null) { mAppsCustomizeContent.removeApps(appInfos); } }
From source file:com.android.messaging.mmslib.pdu.PduPersister.java
/** * Persist a PDU object to specific location in the storage. * * @param pdu The PDU object to be stored. * @param uri Where to store the given PDU object. * @param subId Subscription id associated with this message. * @param subPhoneNumber TODO/*from w w w . j av a2s. c o m*/ * @param preOpenedFiles if not null, a map of preopened InputStreams for the parts. * @return A Uri which can be used to access the stored PDU. */ public Uri persist(final GenericPdu pdu, final Uri uri, final int subId, final String subPhoneNumber, final Map<Uri, InputStream> preOpenedFiles) throws MmsException { if (uri == null) { throw new MmsException("Uri may not be null."); } long msgId = -1; try { msgId = ContentUris.parseId(uri); } catch (final NumberFormatException e) { // the uri ends with "inbox" or something else like that } final boolean existingUri = msgId != -1; if (!existingUri && MESSAGE_BOX_MAP.get(uri) == null) { throw new MmsException("Bad destination, must be one of " + "content://mms/inbox, content://mms/sent, " + "content://mms/drafts, content://mms/outbox, " + "content://mms/temp."); } synchronized (PDU_CACHE_INSTANCE) { // If the cache item is getting updated, wait until it's done updating before // purging it. if (PDU_CACHE_INSTANCE.isUpdating(uri)) { if (LOCAL_LOGV) { LogUtil.v(TAG, "persist: " + uri + " blocked by isUpdating()"); } try { PDU_CACHE_INSTANCE.wait(); } catch (final InterruptedException e) { Log.e(TAG, "persist1: ", e); } } } PDU_CACHE_INSTANCE.purge(uri); final PduHeaders header = pdu.getPduHeaders(); PduBody body = null; ContentValues values = new ContentValues(); // Mark new messages as seen in the telephony database so that we don't have to // do a global "set all messages as seen" since that occasionally seems to be // problematic (i.e. very slow). See bug 18189471. values.put(Mms.SEEN, 1); //Set<Entry<Integer, String>> set; for (int i = ENCODED_STRING_COLUMN_NAME_MAP.size(); --i >= 0;) { final int field = ENCODED_STRING_COLUMN_NAME_MAP.keyAt(i); final EncodedStringValue encodedString = header.getEncodedStringValue(field); if (encodedString != null) { final String charsetColumn = CHARSET_COLUMN_NAME_MAP.get(field); values.put(ENCODED_STRING_COLUMN_NAME_MAP.valueAt(i), toIsoString(encodedString.getTextString())); values.put(charsetColumn, encodedString.getCharacterSet()); } } for (int i = TEXT_STRING_COLUMN_NAME_MAP.size(); --i >= 0;) { final byte[] text = header.getTextString(TEXT_STRING_COLUMN_NAME_MAP.keyAt(i)); if (text != null) { values.put(TEXT_STRING_COLUMN_NAME_MAP.valueAt(i), toIsoString(text)); } } for (int i = OCTET_COLUMN_NAME_MAP.size(); --i >= 0;) { final int b = header.getOctet(OCTET_COLUMN_NAME_MAP.keyAt(i)); if (b != 0) { values.put(OCTET_COLUMN_NAME_MAP.valueAt(i), b); } } for (int i = LONG_COLUMN_NAME_MAP.size(); --i >= 0;) { final long l = header.getLongInteger(LONG_COLUMN_NAME_MAP.keyAt(i)); if (l != -1L) { values.put(LONG_COLUMN_NAME_MAP.valueAt(i), l); } } final SparseArray<EncodedStringValue[]> addressMap = new SparseArray<EncodedStringValue[]>( ADDRESS_FIELDS.length); // Save address information. for (final int addrType : ADDRESS_FIELDS) { EncodedStringValue[] array = null; if (addrType == PduHeaders.FROM) { final EncodedStringValue v = header.getEncodedStringValue(addrType); if (v != null) { array = new EncodedStringValue[1]; array[0] = v; } } else { array = header.getEncodedStringValues(addrType); } addressMap.put(addrType, array); } final HashSet<String> recipients = new HashSet<String>(); final int msgType = pdu.getMessageType(); // Here we only allocate thread ID for M-Notification.ind, // M-Retrieve.conf and M-Send.req. // Some of other PDU types may be allocated a thread ID outside // this scope. if ((msgType == PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND) || (msgType == PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF) || (msgType == PduHeaders.MESSAGE_TYPE_SEND_REQ)) { switch (msgType) { case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND: case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF: loadRecipients(PduHeaders.FROM, recipients, addressMap); // For received messages (whether group MMS is enabled or not) we want to // associate this message with the thread composed of all the recipients // EXCLUDING our own number. This includes the person who sent the // message (the FROM field above) in addition to the other people the message // was addressed TO (or CC fields to address group messaging compatibility // issues with devices that place numbers in this field). Typically our own // number is in the TO/CC field so we have to remove it in loadRecipients. checkAndLoadToCcRecipients(recipients, addressMap, subPhoneNumber); break; case PduHeaders.MESSAGE_TYPE_SEND_REQ: loadRecipients(PduHeaders.TO, recipients, addressMap); break; } long threadId = -1L; if (!recipients.isEmpty()) { // Given all the recipients associated with this message, find (or create) the // correct thread. threadId = MmsSmsUtils.Threads.getOrCreateThreadId(mContext, recipients); } else { LogUtil.w(TAG, "PduPersister.persist No recipients; persisting PDU to thread: " + threadId); } values.put(Mms.THREAD_ID, threadId); } // Save parts first to avoid inconsistent message is loaded // while saving the parts. final long dummyId = System.currentTimeMillis(); // Dummy ID of the msg. // Figure out if this PDU is a text-only message boolean textOnly = true; // Get body if the PDU is a RetrieveConf or SendReq. if (pdu instanceof MultimediaMessagePdu) { body = ((MultimediaMessagePdu) pdu).getBody(); // Start saving parts if necessary. if (body != null) { final int partsNum = body.getPartsNum(); if (LOCAL_LOGV) { LogUtil.v(TAG, "PduPersister.persist partsNum: " + partsNum); } if (partsNum > 2) { // For a text-only message there will be two parts: 1-the SMIL, 2-the text. // Down a few lines below we're checking to make sure we've only got SMIL or // text. We also have to check then we don't have more than two parts. // Otherwise, a slideshow with two text slides would be marked as textOnly. textOnly = false; } for (int i = 0; i < partsNum; i++) { final PduPart part = body.getPart(i); persistPart(part, dummyId, preOpenedFiles); // If we've got anything besides text/plain or SMIL part, then we've got // an mms message with some other type of attachment. final String contentType = getPartContentType(part); if (LOCAL_LOGV) { LogUtil.v(TAG, "PduPersister.persist part: " + i + " contentType: " + contentType); } if (contentType != null && !ContentType.APP_SMIL.equals(contentType) && !ContentType.TEXT_PLAIN.equals(contentType)) { textOnly = false; } } } } // Record whether this mms message is a simple plain text or not. This is a hint for the // UI. if (OsUtil.isAtLeastJB_MR1()) { values.put(Mms.TEXT_ONLY, textOnly ? 1 : 0); } if (OsUtil.isAtLeastL_MR1()) { values.put(Mms.SUBSCRIPTION_ID, subId); } else { Assert.equals(ParticipantData.DEFAULT_SELF_SUB_ID, subId); } Uri res = null; if (existingUri) { res = uri; SqliteWrapper.update(mContext, mContentResolver, res, values, null, null); } else { res = SqliteWrapper.insert(mContext, mContentResolver, uri, values); if (res == null) { throw new MmsException("persist() failed: return null."); } // Get the real ID of the PDU and update all parts which were // saved with the dummy ID. msgId = ContentUris.parseId(res); } values = new ContentValues(1); values.put(Part.MSG_ID, msgId); SqliteWrapper.update(mContext, mContentResolver, Uri.parse("content://mms/" + dummyId + "/part"), values, null, null); // We should return the longest URI of the persisted PDU, for // example, if input URI is "content://mms/inbox" and the _ID of // persisted PDU is '8', we should return "content://mms/inbox/8" // instead of "content://mms/8". // TODO: Should the MmsProvider be responsible for this??? if (!existingUri) { res = Uri.parse(uri + "/" + msgId); } // Save address information. for (final int addrType : ADDRESS_FIELDS) { final EncodedStringValue[] array = addressMap.get(addrType); if (array != null) { persistAddress(msgId, addrType, array); } } return res; }
From source file:com.emc.storageos.volumecontroller.impl.plugins.IsilonCommunicationInterface.java
/** * get UnManaged Cifs Shares and their ACLs * //from w w w. j a va2 s . c o m * @param unManagedFileSystem * @param smbShares * @param unManagedCifsShareACLList * @param fsPath * @param isilonApi */ private void setUnmanagedCifsShareACL(UnManagedFileSystem unManagedFileSystem, HashSet<String> smbShares, List<UnManagedCifsShareACL> unManagedCifsShareACLList, StoragePort storagePort, String fsname, String zoneName, IsilonApi isilonApi) { _log.debug("Set CIFS shares and their respective ACL of UMFS: {} from Isilon SMB share details - start", fsname); if (null != smbShares && !smbShares.isEmpty()) { UnManagedSMBShareMap unManagedSmbShareMap = null; if (null == unManagedFileSystem.getUnManagedSmbShareMap()) { unManagedSmbShareMap = new UnManagedSMBShareMap(); unManagedFileSystem.setUnManagedSmbShareMap(unManagedSmbShareMap); } unManagedSmbShareMap = unManagedFileSystem.getUnManagedSmbShareMap(); UnManagedSMBFileShare unManagedSMBFileShare = null; for (String shareId : smbShares) { // get smb share details IsilonSMBShare isilonSMBShare = getIsilonSMBShare(isilonApi, shareId, zoneName); if (null != isilonSMBShare) { unManagedSMBFileShare = new UnManagedSMBFileShare(); unManagedSMBFileShare.setName(isilonSMBShare.getName()); unManagedSMBFileShare.setDescription(isilonSMBShare.getDescription()); unManagedSMBFileShare.setNativeId(unManagedFileSystem.getNativeGuid()); unManagedSMBFileShare.setMountPoint( "\\\\" + storagePort.getPortNetworkId() + "\\" + isilonSMBShare.getName()); unManagedSMBFileShare.setPath(isilonSMBShare.getPath()); unManagedSMBFileShare.setMaxUsers(-1); // setting the dummy permission.This is not used by isilon, but used by other storage system unManagedSMBFileShare.setPermission(FileControllerConstants.CIFS_SHARE_PERMISSION_CHANGE); unManagedSMBFileShare .setPermissionType(FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW); // set Unmanaged SMB Share unManagedSmbShareMap.put(isilonSMBShare.getName(), unManagedSMBFileShare); _log.info("SMB share name {} and fs mount point {} ", unManagedSMBFileShare.getName(), unManagedSMBFileShare.getMountPoint()); // process ACL permission UnManagedCifsShareACL unManagedCifsShareACL = null; int aclSize = 0; List<IsilonSMBShare.Permission> permissionList = isilonSMBShare.getPermissions(); for (IsilonSMBShare.Permission permission : permissionList) { // Isilon can have deny permission type. Do not ingest the ACL for deny if (FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW .equalsIgnoreCase(permission.getPermissionType())) { aclSize++; _log.debug("IsilonSMBShare: [{}] permission details: {}", isilonSMBShare.getName(), permission.toString()); unManagedCifsShareACL = new UnManagedCifsShareACL(); // Set share name unManagedCifsShareACL.setShareName(isilonSMBShare.getName()); // Set permission unManagedCifsShareACL.setPermission(permission.getPermission()); // We take only username and we can ignore type and id // Set user unManagedCifsShareACL.setUser(permission.getTrustee().getName()); // Set filesystem id unManagedCifsShareACL.setFileSystemId(unManagedFileSystem.getId()); unManagedCifsShareACL.setId(URIUtil.createId(UnManagedCifsShareACL.class)); unManagedCifsShareACLList.add(unManagedCifsShareACL); } } _log.debug("ACL size of share: [{}] is {}", isilonSMBShare.getName(), aclSize); } } if (!unManagedSmbShareMap.isEmpty()) { unManagedFileSystem.setHasShares(true); } } }
From source file:eionet.cr.harvest.scheduled.HarvestingJob.java
/** * * @throws DAOException//from w w w.jav a2s.c om */ private void handleBatchQueue() throws DAOException { // Even if it is not currently a batch harvesting hour, we shall proceed to getting the list of next scheduled sources, and // looping over them, as there are specific sources for which the batch-harvesting hours should be ignored. Currently these // are sources whose harvest interval is less than 8 hours. if (isBatchHarvestingHour()) { LOGGER.trace("Handling batch queue..."); } // Initialize batch queue collection. batchQueue = Collections.synchronizedList(new ArrayList<HarvestSourceDTO>()); // Initialize collection for sources that will have to be deleted. HashSet<String> sourcesToDelete = new HashSet<String>(); // Initialize harvest source DAO. HarvestSourceDAO sourceDao = DAOFactory.get().getDao(HarvestSourceDAO.class); // Get next scheduled sources. List<HarvestSourceDTO> nextScheduledSources = getNextScheduledSources(); if (isBatchHarvestingHour()) { LOGGER.trace(nextScheduledSources.size() + " next scheduled sources found"); } // Loop over next scheduled sources. for (HarvestSourceDTO sourceDTO : nextScheduledSources) { // If source is marked with permanent error then increase its unavailability count if it's a // priority source, or simply delete it if it's not a priority source. // If source not marked with permanent and its unavailability count is >=5 and it's a // non-priority source then delete it. // In all other cases, add the harvest source to the batch-harvest queue. if (sourceDTO.isPermanentError()) { if (sourceDTO.isPrioritySource()) { LOGGER.trace("Increasing unavailability count of permanent-error priority source " + sourceDTO.getUrl()); sourceDao.increaseUnavailableCount(sourceDTO.getUrl()); } else { LOGGER.debug( sourceDTO.getUrl() + " will be deleted as a non-priority source with permanent error"); sourcesToDelete.add(sourceDTO.getUrl()); } } else if (sourceDTO.getCountUnavail() >= 5) { if (!sourceDTO.isPrioritySource()) { LOGGER.debug(sourceDTO.getUrl() + " will be deleted as a non-priority source with unavailability >= 5"); sourcesToDelete.add(sourceDTO.getUrl()); } } else { batchQueue.add(sourceDTO); } } // Harvest the batch harvest queue (if anything added to it). for (Iterator<HarvestSourceDTO> iter = batchQueue.iterator(); iter.hasNext();) { HarvestSourceDTO sourceDTO = iter.next(); // For sources where interval is less than 8 hours, the batch harvesting hours doesn't apply. // They are always harvested. boolean ignoreBatchHarvestingHour = sourceDTO.getIntervalMinutes().intValue() < 480; if (isBatchHarvestingHour() || ignoreBatchHarvestingHour) { // Remove source from batch harvest queue before starting its harvest. iter.remove(); LOGGER.trace("Going to batch-harvest " + sourceDTO.getUrl()); pullHarvest(sourceDTO, false); } } // Delete sources that were found necessary to delete (if any). if (!sourcesToDelete.isEmpty()) { LOGGER.debug("Deleting " + sourcesToDelete.size() + " sources found above"); for (Iterator<String> iter = sourcesToDelete.iterator(); iter.hasNext();) { String sourceUrl = iter.next(); if (CurrentHarvests.contains(sourceUrl)) { iter.remove(); LOGGER.debug("Skipping deletion of " + sourceUrl + " because it is currently being harvested"); } } sourceDao.removeHarvestSources(sourcesToDelete); } }