List of usage examples for java.util Vector isEmpty
public synchronized boolean isEmpty()
From source file:vitro.vspEngine.service.communication.DummyDCACommUtils.java
/** * @return the vector of sensorModels for this device. Also the out_advCapsToSensModels is set *///ww w. j a v a 2 s. com private Vector<SensorModel> retrievePhenomenaByDevice(String gwID, String devId, HashMap<String, Vector<SensorModel>> out_advCapsToSensModels) { Vector<SensorModel> thisNodesSensorModelsVec = new Vector<SensorModel>(); String[] tmpPhenomenaInputIDAS = null; String[] tmpPhenomenaModelName = null; String tmpXMLtoSend; String tmpXMLreceived; try { tmpXMLtoSend = SensorData.getDeviceDataSML(Config.getConfig().getServiceIDVITRO(), devId); tmpXMLreceived = IDASHttpRequest.getIDASHttpRequest().sendPOSTToIdasXML(tmpXMLtoSend); String[] dirtySensorMLForDevice; XPathString xpathStr = new XPathString(tmpXMLreceived); try { dirtySensorMLForDevice = xpathStr .parseXpathValues("//Envelope/Body/getDeviceDataResponse/sensorML/text()"); } catch (Exception ex) { ex.printStackTrace(); dirtySensorMLForDevice = new String[1]; } String cleanSensorMLForDevice = StringEscapeUtils.unescapeXml(dirtySensorMLForDevice[0]) .replaceAll("[^\\x20-\\x7e]", ""); // TODO: there must be a prettier way to remove the Buffer content{...} wrapping cleanSensorMLForDevice = cleanSensorMLForDevice.replaceAll(Pattern.quote("Buffer content: {"), ""); cleanSensorMLForDevice = cleanSensorMLForDevice.replaceAll(Pattern.quote("}"), ""); xpathStr = new XPathString(cleanSensorMLForDevice); // TODO: should we consider the inputs (sensed) or the outputs? (returned values) here? tmpPhenomenaInputIDAS = xpathStr.parseXpathValues( "//RegisterSensor/SensorDescription/System/inputs/InputList/input/ObservableProperty/@definition"); tmpPhenomenaModelName = xpathStr .parseXpathValues("//RegisterSensor/SensorDescription/System/inputs/InputList/input/@name"); String tmpCapDefinition = ""; if (tmpPhenomenaInputIDAS != null && tmpPhenomenaModelName != null && tmpPhenomenaInputIDAS.length == tmpPhenomenaModelName.length && tmpPhenomenaInputIDAS.length > 0) { for (int i = 0; i < tmpPhenomenaInputIDAS.length; i++) { Vector<SensorModel> advSensModels = new Vector<SensorModel>(); tmpCapDefinition = tmpPhenomenaInputIDAS[i]; String tmpSensorID = tmpPhenomenaModelName[i]; Integer thedigestInt = tmpSensorID.hashCode(); if (thedigestInt < 0) thedigestInt = thedigestInt * (-1); tmpSensorID = thedigestInt.toString(); //todo: eventually we should not use the digest anymore!!! if (!tmpCapDefinition.equalsIgnoreCase("") && (out_advCapsToSensModels.keySet().isEmpty() || !out_advCapsToSensModels.keySet().contains(tmpCapDefinition))) { out_advCapsToSensModels.put(tmpCapDefinition, advSensModels); } else { advSensModels = out_advCapsToSensModels.get(tmpCapDefinition); } boolean sensorModelFoundInCapsTable = false; if (!advSensModels.isEmpty()) { for (int sv = 0; sv < advSensModels.size(); sv++) { if (advSensModels.elementAt(sv).getGatewayId().equalsIgnoreCase(gwID) && advSensModels.elementAt(sv).getSmID().equals(tmpSensorID)) { sensorModelFoundInCapsTable = true; break; } } } SensorModel tmpSensModelToAdd = new SensorModel(tmpCapDefinition, gwID, tmpSensorID, SensorModel.numericDataType, null, null); if (!sensorModelFoundInCapsTable) { //if not found in the total HashMap of Capability to SensorModels of various gateways advSensModels.add(tmpSensModelToAdd); } if (!SensorModel.vectorContainsSensorModel(thisNodesSensorModelsVec, gwID, tmpSensorID)) { //if not found in the vector of SensorModels for this node thisNodesSensorModelsVec.add(tmpSensModelToAdd); } } } } catch (Exception e) { LOG.info(e.getMessage()); e.printStackTrace(); System.out.println(e.getMessage()); } return thisNodesSensorModelsVec; }
From source file:programs.samtools_mpileup.java
@Override public boolean init_checkRequirements() { // In case program is started without edition pgrmStartWithoutEdition(properties); // TEST OUTPUT PATH String specificId = Util.returnRandomAndDate(); if (properties.isSet("ObjectID")) { String oId = properties.get("ObjectID"); oId = Util.replaceSpaceByUnderscore(oId); specificId = specificId + "_" + oId; }/*from w w w . jav a 2 s . co m*/ String specificPath = outputsPath + specificId; if (!Util.CreateDir(specificPath) && !Util.DirExists(specificPath)) { setStatus(status_BadRequirements, Util.BROutputsDir()); return false; } // TEST INPUT VARIABLES HERE // ports are 3-PortInputUp, 2-PortInputDOWN, 4-PortInputDOWN2 Vector<Integer> BedFile1 = properties.getInputID("BedFile", PortInputDOWN2); inputPath1 = Unknown.getVectorFilePath(BedFile1); inputId1 = Unknown.getVectorFileId(BedFile1); input1 = Util.getFileNameAndExt(inputPath1); Vector<Integer> FastaFile2 = properties.getInputID("FastaFile", PortInputUP); inputPath2 = Unknown.getVectorFilePath(FastaFile2); inputId2 = Unknown.getVectorFileId(FastaFile2); input2 = Util.getFileNameAndExt(inputPath2); Vector<Integer> BamFile3 = properties.getInputID("BamFile", PortInputDOWN); inputPath3 = Unknown.getVectorFilePath(BamFile3); inputId3 = Unknown.getVectorFileId(BamFile3); input3 = Util.getFileNameAndExt(inputPath3); // Get the multiple inputs inputsPath3 = Unknown.getAllVectorFilePath(BamFile3); inputsIDs3 = Unknown.getVectorFileIds(BamFile3); Vector<Integer> BamBaiFile4 = properties.getInputID("BamBaiFile", PortInputDOWN); inputPath4 = Unknown.getVectorFilePath(BamBaiFile4); inputId4 = Unknown.getVectorFileId(BamBaiFile4); input4 = Util.getFileNameAndExt(inputPath4); //INSERT YOUR INPUT TEST HERE if (BedFile1.isEmpty() || input1.equals("Unknown") || input1.equals("")) { setStatus(status_warning, Util.BRTypeFile("BedFile")); //return false; } // Please, check if it's "else if" or it's a real "if" if (FastaFile2.isEmpty() || input2.equals("Unknown") || input2.equals("")) { setStatus(status_warning, Util.BRTypeFile("FastaFile")); //return false; } // Please, check if it's "else if" or it's a real "if" if ((BamFile3.isEmpty() || input3.equals("Unknown") || input3.equals("")) && (BamBaiFile4.isEmpty() || input4.equals("Unknown") || input4.equals(""))) { setStatus(status_BadRequirements, Util.BRTypeFile("BamBaiFile or BamFile")); return false; } // Test docker Var presence if (Docker.areDockerVariablesNotInProperties(properties)) { setStatus(status_BadRequirements, Util.BRDockerVariables()); return false; } // Extract Docker Variables String doOutputs = properties.get("DockerOutputs"); String doInputs = properties.get("DockerInputs"); // Prepare ouputs output1 = specificPath + File.separator + "OutputOf_" + input3 + ".bam"; outputInDo1 = doOutputs + "OutputOf_" + input3 + ".bam"; if (properties.isSet("AO_OO__VCF_box")) { output1 = specificPath + File.separator + "OutputOf_" + input3 + ".vcf"; outputInDo1 = doOutputs + "OutputOf_" + input3 + ".vcf"; } else if (properties.isSet("AO_OO__BCF_box")) { output1 = specificPath + File.separator + "OutputOf_" + input3 + ".bcf"; outputInDo1 = doOutputs + "OutputOf_" + input3 + ".bcf"; } output1 = Util.onlyOneOutputOf(output1); outputInDo1 = Util.onlyOneOutputOf(outputInDo1); // Prepare shared folders String[] simplePath = { inputPath1, inputPath2, inputPath3, inputPath4 }; String[] allInputsPath = Util.merge2TablesWithoutDup(simplePath, inputsPath3); String[] simpleId = { inputId1, inputId2, inputId3, inputId4 }; String[] allInputsId = Util.merge2TablesWithoutDup(simpleId, inputsIDs3); sharedFolders = Docker.createSharedFolders(allInputsPath, allInputsId, doInputs); sharedFolders = Docker.addInSharedFolder(sharedFolders, specificPath, doOutputs); // Prepare inputs HashMap<String, String> allInputsPathArg = new HashMap<String, String>(); allInputsPathArg.put(inputPath1, "--positions"); allInputsPathArg.put(inputPath2, "--fasta-ref"); allInputsPathArg.put(inputPath3, ""); allInputsPathArg.put(inputPath4, ""); for (String st : inputsPath3) { if (allInputsPathArg.get(st) == null) allInputsPathArg.put(st, ""); } allDoInputs = Docker.createAllDockerInputs(allInputsPathArg, allInputsPath, allInputsId, doInputs); // Prepare cluster relations Cluster.createLinkDockerClusterInputs(properties, allInputsPath, allInputsId, doInputs); Cluster.createLinkDockerClusterOutput(properties, output1, outputInDo1); // DOCKER INIT if (Docker.isDockerHere()) { long duration = Docker.prepareContainer(properties, sharedFolders); if (!Docker.isDockerContainerIDPresentIn(properties)) { setStatus(status_BadRequirements, Util.BRDockerInit()); return false; } setStatus(status_running, Util.RUNDockerDuration("launch", duration)); } else { setStatus(status_BadRequirements, Util.BRDockerNotFound()); return false; } return true; }
From source file:org.dogtagpki.server.ca.rest.ProfileService.java
public ProfileData createProfileData(String profileId) throws EBaseException { IProfile profile = getProfile(profileId); ProfileData data = new ProfileData(); data.setAuthenticatorId(profile.getAuthenticatorId()); data.setAuthzAcl(profile.getAuthzAcl()); data.setClassId(ps.getProfileClassId(profileId)); data.setDescription(profile.getDescription(getLocale(headers))); data.setEnabled(ps.isProfileEnable(profileId)); data.setEnabledBy(ps.getProfileEnableBy(profileId)); data.setId(profileId);/* w w w . j av a 2s. c o m*/ data.setName(profile.getName(getLocale(headers))); data.setRenewal(Boolean.getBoolean(profile.isRenewal())); data.setVisible(profile.isVisible()); data.setXMLOutput(Boolean.getBoolean(profile.isXmlOutput())); Enumeration<String> inputIds = profile.getProfileInputIds(); if (inputIds != null) { while (inputIds.hasMoreElements()) { ProfileInput input = createProfileInput(profile, inputIds.nextElement(), getLocale(headers)); if (input == null) continue; data.addProfileInput(input); } } // profile outputs Enumeration<String> outputIds = profile.getProfileOutputIds(); if (outputIds != null) { while (outputIds.hasMoreElements()) { ProfileOutput output = createProfileOutput(profile, outputIds.nextElement(), getLocale(headers)); if (output == null) continue; data.addProfileOutput(output); } } // profile policies Enumeration<String> policySetIds = profile.getProfilePolicySetIds(); if (policySetIds != null) { while (policySetIds.hasMoreElements()) { Vector<ProfilePolicy> pset = new Vector<ProfilePolicy>(); String policySetId = policySetIds.nextElement(); Enumeration<String> policyIds = profile.getProfilePolicyIds(policySetId); while (policyIds.hasMoreElements()) { String policyId = policyIds.nextElement(); pset.add(createProfilePolicy(profile, policySetId, policyId)); } if (!pset.isEmpty()) { data.addProfilePolicySet(policySetId, pset); } } } UriBuilder profileBuilder = uriInfo.getBaseUriBuilder(); URI uri = profileBuilder.path(ProfileResource.class).path("{id}").build(profileId); data.setLink(new Link("self", uri)); return data; }
From source file:com.evolveum.openicf.lotus.DominoConnector.java
private Registration createAndSetupRegistration(Map<String, Attribute> attrs, OperationOptions options, String firstName, String lastName, String orgUnit, String mailTemplate, Integer mailQuotaSize, Integer mailQuotaWThreshold, String certPw) throws NotesException { Vector<String> shortNameVector = getAttributeValue(attrs, SHORT_NAME, Vector.class, null, false); String shortName = null;/* w ww .j a v a 2s.c o m*/ if (shortNameVector != null && !shortNameVector.isEmpty()) { shortName = shortNameVector.get(0); } String policy = getAttributeValue(attrs, POLICY, String.class, config.getPolicy()); Integer defaultPasswordExp = getAttributeValue(attrs, DEFAULT_PASSWORD_EXP, Integer.class); Integer days = getDays(getAttributeValue(attrs, END_DATE, Long.class)); if (defaultPasswordExp == null) { if (days != null && days > 0L) { defaultPasswordExp = days; } else { defaultPasswordExp = config.getDefaultPasswordExp(); } } Vector altOrgUnit = getAttributeValue(attrs, ALT_ORG_UNIT, Vector.class); Vector mailReplicaServers = getAttributeValue(attrs, ROAM_RPL_SRVRS, Vector.class); Boolean northAmerican = getAttributeValue(attrs, NORTH_AMERICAN, Boolean.class, config.getNorthAmerican()); String certifierIdFile = getAttributeValue(attrs, CERTIFIER_ID_FILE, String.class, config.getCertifierIdFile()); String caCertifier = getAttributeValue(attrs, CA_CERTIFIER, String.class, config.getCaCertifierName()); if (config.getUseCAProcess() != null && config.getUseCAProcess()) { if (StringUtils.isEmpty(caCertifier)) { throw new ConnectorException( "Using CA process, but CA certifier name not defined (caCertifier attribute)."); } } else { if (StringUtils.isEmpty(certifierIdFile)) { throw new ConnectorException("Certifier ID file not defined."); } if (StringUtils.isEmpty(certPw)) { throw new ConnectorException("Cert. password (credentials) attribute not defined."); } } //roaming String roamSrvr = getAttributeValue(attrs, ROAM_SRVR, String.class, config.getRoamSrvr()); Integer roamCleanSetting = getAttributeValue(attrs, ROAM_CLEAN_SETTING, Integer.class, config.getRoamCleanSetting()); Integer roamCleanPer = getAttributeValue(attrs, ROAM_CLEAN_PER, Integer.class, config.getRoamCleanPer()); String roamSubDir = getAttributeValue(attrs, ROAM_SUBDIR, String.class, PREFIX_ROAMING + firstName + lastName); //groups validation Vector groups = getAttributeValue(attrs, GROUP_LIST, Vector.class); checkIfGroupsExist(groups); String internetAddress = getAttributeValue(attrs, INTERNET_ADDRESS); Boolean synchInternetPassword = getOperationOptionValue(options, SYNCH_INTERNET_PASSWORD, null); Integer mailOwnerAccess = getOperationOptionValue(options, MAIL_OWNER_ACCESS, config.getMailOwnerAccess()); LOG.ok("Creating registration."); Registration registration = connection.getSession().createRegistration(); RegistrationBuilder builder = new RegistrationBuilder(registration); builder.setCertifierName(caCertifier); builder.setPolicyName(policy); builder.setShortName(shortName); builder.setOrgUnit(orgUnit); builder.setAltOrgUnit(altOrgUnit); builder.setCertifierIDFile(certifierIdFile); builder.setMailTemplateName(mailTemplate); builder.setMailQuotaSizeLimit(mailQuotaSize); builder.setMailQuotaWarningThreshold(mailQuotaWThreshold); builder.setGroupList(groups); builder.setRoamingServer(roamSrvr); builder.setRoamingCleanupSetting(roamCleanSetting); builder.setRoamingCleanupPeriod(roamCleanPer); builder.setRoamingSubdir(roamSubDir); builder.setMailInternetAddress(internetAddress); builder.setSynchInternetPassword(synchInternetPassword); builder.setMailOwnerAccess(mailOwnerAccess); builder.setMailReplicaServers(mailReplicaServers); builder.setNorthAmerican(northAmerican); builder.setRegistrationLog(config.getRegistrationLog()); builder.setStoreIDInAddressBook(config.getStoreIDInAddressBook()); builder.setStoreIDInMailfile(config.getStoreIDInMailfile()); builder.setIDType(config.getRealIdType()); builder.setMailSystem(config.getMailSystem()); builder.setCreateMailDb(config.getCreateMailDb()); builder.setMinPasswordLength(config.getMinPasswordLength()); builder.setUpdateAddressBook(true); if (StringUtils.isNotEmpty(config.getMailACLManager())) { builder.setMailACLManager(config.getMailACLManager()); } builder.setMailACLManager("LocalDomainAdmins"); if (config.getCreateIdFile() != null && !config.getCreateIdFile()) { builder.setNoIDFile(true); builder.setCertifierName(config.getAdminName()); } DateTime expiration = connection.getSession().createDateTime("Today"); expiration.setNow(); expiration.adjustDay(defaultPasswordExp); builder.setExpiration(expiration); return registration; }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoCategorizedDocuments.java
@SuppressWarnings("unchecked") private void fetchChildrenForNotesDocument() throws NotesException { // LOGGER.info(getCallingMethod()+":"+"Start fetchChildrenForNotesDocument; Fetching children for doc with UNID=" // + this.getDocumentUniqueID()); Document curDoc = null;/*w w w . j a va 2s . c om*/ String docID = null; Vector<IDAVResource> resMembers = null; this.setMembers(new Vector<IDAVResource>()); String notesURL = this.getInternalAddress(); DAVRepositoryDominoCategorizedDocuments repository = (DAVRepositoryDominoCategorizedDocuments) this .getRepository(); // LOGGER.info("Internal Address is "+notesURL); // LOGGER.info("PublicHref is "+this.getPublicHref()); curDoc = DominoProxy.getDocument(notesURL); // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK"); if (curDoc == null) { LOGGER.error("Could not retrieve the document"); return; } boolean readOnly = this.checkReadOnlyAccess(curDoc); Date curCreationDate = curDoc.getCreated().toJavaDate(); if (curDoc.hasItem("DAVCreated")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); this.setReadOnly(readOnly); // Read the repository list to get the view try { LOGGER.info(getCallingMethod() + ":" + "Currdoc not null ; OK; Has UNID=" + curDoc.getUniversalID()); docID = curDoc.getUniversalID(); LOGGER.info(getCallingMethod() + ":" + "Openend document " + docID); // No children if there are no attachments if (!curDoc.hasEmbedded()) { // folder ViewEntryCollection responses = repository .getAllEntriesByKey(curDoc.getItemValueString(repository.getPubHrefField())); LOGGER.info(getCallingMethod() + ":" + "Get Responses..."); int numOfResponses = responses.getCount(); LOGGER.info(getCallingMethod() + ":" + "Current doc has " + String.valueOf(numOfResponses) + " responses"); if (numOfResponses > 1) { resMembers = new Vector<IDAVResource>(numOfResponses - 1); LOGGER.info(getCallingMethod() + ":" + "Start Process responses"); lotus.domino.ViewEntry ve = responses.getFirstEntry(); ve = responses.getNextEntry(); Document docResp = null; while (ve != null) { docResp = ve.getDocument(); // if(docResp.getUniversalID()!=docID){ LOGGER.info(getCallingMethod() + ":" + "Doc response has unid=" + docResp.getUniversalID() + "; Try find attachment(s)"); Vector<String> allEmbedded = DominoProxy.evaluate("@AttachmentNames", docResp); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).toString().equals("") ? 0 : allEmbedded.size()); LOGGER.info(getCallingMethod() + ":" + "Doc has " + String.valueOf(numOfAttachments) + " attachment(s)"); if (numOfAttachments == 0) { // No attachments in here! LOGGER.info(getCallingMethod() + ":" + "Doc " + docResp.getUniversalID() + " response has no attachment; is a directory; Create resource for it"); DAVResourceDominoCategorizedDocuments resAtt = new DAVResourceDominoCategorizedDocuments( this.getRepository(), this.getPublicHref() + "/" + docResp.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())) .getDirectoryField()), true); resAtt.setup(docResp); if (resAtt != null) { LOGGER.info(getCallingMethod() + ":" + "Created DavResourceDomino Attachments from getDocumentResource-OK"); if (resAtt.filter()) { this.getMembers().add(resAtt); } resMembers.add(resAtt); LOGGER.info(getCallingMethod() + ":" + "Resource successfull added"); } } else { LOGGER.info(getCallingMethod() + ":" + "Doc response " + docResp.getUniversalID() + " has attachments >0; "); String curAttName = allEmbedded.get(0).toString(); if ((curAttName != null) && (!curAttName.equals(""))) { LOGGER.info(getCallingMethod() + ":" + "Doc response fitrst attachment has name " + curAttName); DAVResourceDominoCategorizedDocuments resAtt = new DAVResourceDominoCategorizedDocuments( this.getRepository(), this.getPublicHref() + "/" + curAttName, true); resAtt.setup(docResp); if (resAtt != null) { // Now add it to the Vector LOGGER.info(getCallingMethod() + ":" + "Created DAVResourceDominoDocuments with getAttachmentResource-OK!\n Start load resource"); // resMembers.add(curAttachment); if (resAtt.filter()) { this.getMembers().add(resAtt); } LOGGER.info(getCallingMethod() + ":" + "Resource successfull added"); Date viewDate = this.getLastModified(); Date docDate = resAtt.getLastModified(); if (viewDate == null || (docDate != null && viewDate.before(docDate))) { this.setLastModified(docDate); } LOGGER.info(getCallingMethod() + ":" + "Resource successfull updated last modified"); LOGGER.info(getCallingMethod() + ":" + "Processing complete attachment:" + curAttName); } } } LOGGER.info(getCallingMethod() + ":" + "Start recycling.."); // Document docTmp=docResp; // } //end // if(docResp.getUniversalID()!=curDoc.getUniversalID()){ ve = responses.getNextEntry(); // docTmp.recycle(); LOGGER.info(getCallingMethod() + ":" + "Recycling OK!"); } // end while } // end if numresp>0 try { LOGGER.info(getCallingMethod() + ":" + "Final recycling.."); if (curDoc != null) { curDoc.recycle(); } LOGGER.info(getCallingMethod() + ":" + "End FINAL recycling OK!"); } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object LOGGER.info(getCallingMethod() + ":" + "Finish processing current doc as a directory; No more attachment(s) in it; Return!"); return; } // Get all attachments LOGGER.info(getCallingMethod() + ":" + "Current doc has attachments!"); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); int numOfAttchments = allEmbedded.size(); if (numOfAttchments == 0) { // No attachments in here! LOGGER.info(getCallingMethod() + ":" + "Something wrong: Doc + " + docID + " has no attachments (@AttachmentNames)"); return; } LOGGER.info(getCallingMethod() + ":" + docID + " has " + new Integer(numOfAttchments).toString() + " attachment(s)"); // Initialize an empty vector at the right size // We might need to enlarge it if we have more attachments resMembers = new Vector<IDAVResource>(numOfAttchments); LOGGER.info(getCallingMethod() + ":" + "Start processing attachment(s).."); for (int i = 0; i < numOfAttchments; i++) { String curAttName = allEmbedded.get(i).toString(); DAVResourceDominoCategorizedDocuments curAttachment = getDocumentResource(curDoc); if (curAttachment != null) { // Now add it to the Vector LOGGER.info(getCallingMethod() + ":" + "Resource attachment successfully created!"); // resMembers.add(curAttachment); if (curAttachment.filter()) { this.getMembers().add(curAttachment); } LOGGER.info("Resource attachment successfully added: " + curAttName + "; OK!"); } else { LOGGER.error("Could not load attachment#" + curAttName + "#"); } } } catch (NotesException ne) { LOGGER.error(ne); } catch (Exception e) { LOGGER.error(e); } finally { try { LOGGER.info(getCallingMethod() + ":" + "Final block; Start Recycling!"); if (curDoc != null) { curDoc.recycle(); } } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object // this.setMembers(resMembers); LOGGER.info("Completed reading attachments resources from Notes document; OK!"); } }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoCategorizedDocuments.java
private void setup(Document curDoc) { try {// w w w . j av a2 s . co m DAVRepositoryDominoCategorizedDocuments rep = (DAVRepositoryDominoCategorizedDocuments) this .getRepository(); LOGGER.info("Start setup with doc ..." + curDoc.getItemValueString(rep.getPubHrefField())); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); // LOGGER.info(getCallingMethod()+":"+"All Embedded computed"); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).equals("") ? 0 : allEmbedded.size()); String docID = curDoc.getUniversalID(); this.setDocumentUniqueID(docID); LOGGER.info("Num of attachments=" + new Integer(numOfAttachments).toString()); boolean readOnly = this.checkReadOnlyAccess(curDoc); this.setReadOnly(readOnly); // LOGGER.info("Creation date for "+curDoc.getUniversalID()+" ="+curDoc.getCreated().toString()+"; Time zone="+curDoc.getCreated().getZoneTime()+"; Local time="+curDoc.getCreated().getLocalTime()); Date curCreationDate = curDoc.getCreated().toJavaDate(); // LOGGER.info("Current date in Java is "+curCreationDate.toString()+"Time zone="+new // Integer(curCreationDate.getTimezoneOffset()).toString()+"; Locale time is:"+curCreationDate.toLocaleString()); if (curDoc.hasItem("DAVCreated")) { // Item davCreated=curDoc.getFirstItem("DAVCreated"); @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); if (curCreationDate == null) { curCreationDate = curDoc.getCreated().toJavaDate(); } } } } } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); if (curChangeDate == null) { curChangeDate = curDoc.getLastModified().toJavaDate(); } } } } } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); // LOGGER.info("Creation date is set to "+this.getCreationDate().toString()); // LOGGER.info("Last modified date is set to "+this.getLastModified().toString()); String pubHRef = ((IDAVAddressInformation) this.getRepository()).getPublicHref(); // LOGGER.info("THIS getpublichref="+this.getPublicHref()); String curAttName = null; if (numOfAttachments == 0) { // LOGGER.info(getCallingMethod()+":"+"Start setting resource"); String name = curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())).getDirectoryField()); this.setName(name); if (this.getPublicHref().equals("")) { this.setPublicHref(pubHRef + curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())).getPubHrefField())); } this.setCollection(true); this.setInternalAddress( ((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID); this.setResourceType("NotesDocument"); this.setMember(false); this.setContentLength(0L); // this.fetchChildren(); } else { curAttName = allEmbedded.get(0).toString(); // LOGGER.info("Attachment name is "+curAttName); this.setMember(true); this.setResourceType("NotesAttachment"); if (this.getPublicHref().equals("")) { try { this.setPublicHref(pubHRef + curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())) .getPubHrefField())); } catch (Exception e) { LOGGER.error(e); } // this.setPublicHref( pubHRef+"/"+curAttName); } this.setInternalAddress(((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID + "/$File/" + curAttName); this.setCollection(false); this.setName(curAttName); EmbeddedObject curAtt = curDoc.getAttachment(curAttName); if (curAtt == null) { return; } Long curSize = new Long(curAtt.getFileSize()); this.setContentLength(curSize); } // LOGGER.info("Current res realized! pubHREF="+this.getPublicHref()+"; Internal Address="+this.getInternalAddress()+"; "); } catch (NotesException ne) { LOGGER.error("ERROR! Can not set; " + ne.getMessage()); } }
From source file:edu.harvard.i2b2.eclipse.plugins.metadataLoader.views.loader.TableComposite.java
public void processMetadata(final Label theStatus, final Label theStatus2, final Display theDisplay, final Thread thisThread) throws Exception { // pass data and metadata table name. OntologyResponseMessage msg = new OntologyResponseMessage(); StatusType procStatus = null;/*from ww w. j a va 2 s . c om*/ CSVFileReader reader = null; try { String file = RunData.getInstance().getMetadataFile(); reader = new CSVFileReader(RunData.getInstance().getMetadataFile(), '|', '"'); // Read in header.. reader.readFields(); int count = 0; int start = 1; int end = 1000; MetadataLoadType metadata = new MetadataLoadType(); metadata.setTableName(RunData.getInstance().getMetadataTable()); Vector<String> fields = null; while (count < end) { try { if (thisThread.getName().equals("stop")) { reader.close(); I2B2Exception e2 = new I2B2Exception( "User cancelled load of table " + metadata.getTableName()); throw e2; } fields = reader.readFields(); if ((fields == null) || (fields.isEmpty())) { if (metadata.getMetadata().isEmpty()) break; System.out.println("Loading " + metadata.getTableName() + " metadata records " + start + " to " + count); final String theMsg = "Loading " + metadata.getTableName() + " metadata records " + start + " to " + count; theDisplay.syncExec(new Runnable() { public void run() { theStatus2.setText(theMsg); IActionBars bars = ((WorkbenchWindow) PlatformUI.getWorkbench() .getActiveWorkbenchWindow()).getActionBars(); bars.getStatusLineManager().setMessage(theMsg); } }); String response = OntServiceDriver.loadMetadata(metadata, "ONT"); procStatus = msg.processResult(response); if (procStatus.getType().equals("ERROR")) { System.setProperty("errorMessage", procStatus.getValue()); reader.close(); System.out.println("Error loading metadata records: exiting"); I2B2Exception e = new I2B2Exception(procStatus.getValue()); throw e; } // This one loads data reached when end of file found. // String response = MapperServiceDriver.getUnmappedTerms(unmap); //persistDao.batchUpdateMetadata(dbInfo, list); // This is call to ONT to load the table access data. break; } } catch (Exception e) { // TODO Auto-generated catch block reader.close(); System.out.println("Error loading metadata records: exiting"); I2B2Exception e2 = new I2B2Exception("Error loading metadata records for table " + metadata.getTableName() + "; exiting: " + e.getMessage()); throw e2; } if (fields.size() < 25) { System.out.println("problem; too few fields."); I2B2Exception e2 = new I2B2Exception( "Error processing metadata records: too few fields in file; exiting "); throw e2; } MetadataLoaderType term = new MetadataLoaderType(); metadata.getMetadata().add(term.fromMetadata(fields)); count++; if (end == count) { System.out.println("Loading metadata records " + start + " to " + count); final String theMsg = "Loading " + metadata.getTableName() + " metadata records " + start + " to " + count; theDisplay.syncExec(new Runnable() { public void run() { theStatus2.setText(theMsg); IActionBars bars = ((WorkbenchWindow) PlatformUI.getWorkbench() .getActiveWorkbenchWindow()).getActionBars(); bars.getStatusLineManager().setMessage(theMsg); } }); try { String response = OntServiceDriver.loadMetadata(metadata, "ONT"); procStatus = msg.processResult(response); if (procStatus.getType().equals("ERROR")) { System.setProperty("errorMessage", procStatus.getValue()); reader.close(); System.out.println("Error loading metadata records: exiting"); I2B2Exception e = new I2B2Exception(procStatus.getValue()); throw e; } //persistDao.batchUpdateMetadata(dbInfo, list); // This is call to ONT to load the table access data. // This one loads the incremental chunks of data. } catch (Exception e) { // TODO Auto-generated catch block reader.close(); System.out.println("Error loading metadata records: exiting"); I2B2Exception e2 = new I2B2Exception("Error loading metadata records for table " + metadata.getTableName() + "; exiting: " + e.getMessage()); throw e2; } metadata.getMetadata().clear(); end += 1000; start += 1000; if (thisThread.getName().equals("stop")) { reader.close(); I2B2Exception e2 = new I2B2Exception( "User cancelled load of table " + metadata.getTableName()); throw e2; } } } reader.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println("Metadata loader complete"); }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoDocuments.java
@SuppressWarnings("unchecked") private void fetchChildrenForNotesDocument() throws NotesException { // LOGGER.info(getCallingMethod()+":"+"Start fetchChildrenForNotesDocument; Fetching children for doc with UNID=" // + this.getDocumentUniqueID()); Document curDoc = null;/*from ww w. j a v a 2s .co m*/ // String docID = null; Vector<IDAVResource> resMembers = new Vector<IDAVResource>(); this.setMembers(resMembers); String notesURL = this.getInternalAddress(); // LOGGER.info("Internal Address is "+notesURL); // LOGGER.info("PublicHref is "+this.getPublicHref()); curDoc = DominoProxy.getDocument(notesURL); // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK"); if (curDoc == null) { LOGGER.error("Could not retrieve the document"); return; } boolean readOnly = this.checkReadOnlyAccess(curDoc); Date curCreationDate = curDoc.getCreated().toJavaDate(); if (curDoc.hasItem("DAVCreated")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); this.setReadOnly(readOnly); // Read the repository list to get the view try { // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK; Has UNID="+curDoc.getUniversalID()); // docID = curDoc.getUniversalID(); // LOGGER.info(getCallingMethod()+":"+"Openend document " + docID); // No children if there are no attachments if (!curDoc.hasEmbedded()) { // if(1==1){return;} // E.C. It is a directory, so fetch the children documents as // resources // LOGGER.info(getCallingMethod()+":"+"Current doc with unid="+curDoc.getUniversalID()+" has no embedded files. Try to find children"); DocumentCollection responses = curDoc.getResponses(); // LOGGER.info(getCallingMethod()+":"+"Get Responses..."); int numOfResponses = responses.getCount(); // LOGGER.info(getCallingMethod()+":"+"Current doc has "+String.valueOf(numOfResponses) // + " responses"); if (numOfResponses > 0) { resMembers = new Vector<IDAVResource>(numOfResponses); // LOGGER.info(getCallingMethod()+":"+"Start Process responses"); Document docResp = responses.getFirstDocument(); while (docResp != null) { // LOGGER.info(getCallingMethod()+":"+"Doc response has unid="+docResp.getUniversalID()+ // "; Try find attachment(s)"); Vector<String> allEmbedded = DominoProxy.evaluate("@AttachmentNames", docResp); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).toString().equals("") ? 0 : allEmbedded.size()); // LOGGER.info(getCallingMethod()+":"+"Doc has "+ // String.valueOf(numOfAttachments)+" attachment(s)"); if (numOfAttachments == 0) { // No attachments in here! // LOGGER.info(getCallingMethod()+":"+"Doc "+docResp.getUniversalID()+" response has no attachment; is a directory; Create resource for it"); DAVResourceDominoDocuments resAtt = new DAVResourceDominoDocuments(this.getRepository(), this.getPublicHref() + "/" + docResp.getItemValueString( ((DAVRepositoryDominoDocuments) (this.getRepository())) .getDirectoryField()), true); resAtt.setup(docResp); LOGGER.info(getCallingMethod() + ":" + "Created DavResourceDomino Attachments from getDocumentResource-OK"); this.getMembers().add(resAtt); // resMembers.add(resAtt); LOGGER.info(getCallingMethod() + ":" + "Resource successfull added"); } else { // LOGGER.info(getCallingMethod()+":"+"Doc response "+docResp.getUniversalID()+" has attachments >0; "); String curAttName = allEmbedded.get(0).toString(); if ((curAttName != null) && (!curAttName.equals(""))) { // LOGGER.info(getCallingMethod()+":"+"Doc response fitrst attachment has name "+curAttName); DAVResourceDominoDocuments resAtt = new DAVResourceDominoDocuments( this.getRepository(), this.getPublicHref() + "/" + curAttName, true); resAtt.setup(docResp); if (resAtt != null) { // Now add it to the Vector // LOGGER.info(getCallingMethod()+":"+"Created DAVResourceDominoDocuments with getAttachmentResource-OK!\n Start load resource"); // resMembers.add(curAttachment); this.getMembers().add(resAtt); // LOGGER.info(getCallingMethod()+":"+"Resource successfull added"); Date viewDate = this.getLastModified(); Date docDate = resAtt.getLastModified(); if (viewDate == null || (docDate != null && viewDate.before(docDate))) { this.setLastModified(docDate); } LOGGER.info(getCallingMethod() + ":" + "Resource successfull updated last modified"); // LOGGER.info(getCallingMethod()+":"+"Processing complete attachment:" // + curAttName); } } } // LOGGER.info(getCallingMethod()+":"+"Start recycling.."); docResp = responses.getNextDocument(docResp); // LOGGER.info(getCallingMethod()+":"+"Recycling OK!"); } // end while } // end if numresp>0 try { // LOGGER.info(getCallingMethod()+":"+"Final recycling.."); if (curDoc != null) { // curDoc.recycle(); } // LOGGER.info(getCallingMethod()+":"+"End FINAL recycling OK!"); } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object // LOGGER.info(getCallingMethod()+":"+"Finish processing current doc as a directory; No more attachment(s) in it; Return!"); return; } // Get all attachments // LOGGER.info(getCallingMethod()+":"+"Current doc has attachments!"); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); int numOfAttchments = allEmbedded.size(); if (numOfAttchments == 0) { // No attachments in here! // LOGGER.info(getCallingMethod()+":"+"Something wrong: Doc + "+docID // + " has no attachments (@AttachmentNames)"); return; } // LOGGER.info(getCallingMethod()+":"+docID + " has " + new // Integer(numOfAttchments).toString() + " attachment(s)"); // Initialize an empty vector at the right size // We might need to enlarge it if we have more attachments resMembers = new Vector<IDAVResource>(numOfAttchments); // LOGGER.info(getCallingMethod()+":"+"Start processing attachment(s).."); for (int i = 0; i < numOfAttchments; i++) { String curAttName = allEmbedded.get(i).toString(); DAVResourceDominoDocuments curAttachment = getDocumentResource(curDoc); if (curAttachment != null) { // Now add it to the Vector // LOGGER.info(getCallingMethod()+":"+"Resource attachment successfully created!"); // resMembers.add(curAttachment); this.getMembers().add(curAttachment); // LOGGER.info("Resource attachment successfully added: " + // curAttName+"; OK!"); } else { LOGGER.error("Could not load attachment#" + curAttName + "#"); } } } catch (NotesException ne) { LOGGER.error(ne); } catch (Exception e) { LOGGER.error(e); } finally { try { // LOGGER.info(getCallingMethod()+":"+"Final block; Start Recycling!"); if (curDoc != null) { // curDoc.recycle(); } } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object // this.setMembers(resMembers); // LOGGER.info("Completed reading attachments resources from Notes document; OK!"); } }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java
/*********************************************************************************************** * Crop the specified Vector of CalendarisedData to the range given by the start and end Calendars. * Return the cropped CalendarisedData, or NULL on failure. * * @param calendariseddata//from w w w.j av a2 s . c o m * @param startcalendar * @param endcalendar * * @return Vector<Object> */ public static Vector<Object> cropCalendarisedDataToRange(final Vector<Object> calendariseddata, final Calendar startcalendar, final Calendar endcalendar) { Vector<Object> vecCropped; vecCropped = null; if ((calendariseddata != null) && (!calendariseddata.isEmpty()) && (startcalendar != null) && (endcalendar != null)) { vecCropped = new Vector<Object>(calendariseddata.size()); for (int intDataIndex = 0; intDataIndex < calendariseddata.size(); intDataIndex++) { final Vector<Object> vecRow; final Calendar calendarRow; vecRow = (Vector) calendariseddata.get(intDataIndex); // We can safely assume that the data Vector is calendarised calendarRow = (Calendar) vecRow.get(DataTranslatorInterface.INDEX_TIMESTAMPED_CALENDAR); if ((calendarRow.equals(startcalendar) || calendarRow.after(startcalendar)) && (calendarRow.before(endcalendar) || calendarRow.equals(endcalendar))) { vecCropped.add(vecRow); } } } // Did we gather any data? if ((vecCropped != null) && (vecCropped.isEmpty())) { // Return NULL on failure vecCropped = null; } return (vecCropped); }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoDocuments.java
@SuppressWarnings("deprecation") private void setup(Document curDoc) { try {//from ww w . j a va 2s .c o m // LOGGER.info(getCallingMethod()+":"+"Start setup..."); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); // LOGGER.info(getCallingMethod()+":"+"All Embedded computed"); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).equals("") ? 0 : allEmbedded.size()); String docID = curDoc.getUniversalID(); this.setDocumentUniqueID(docID); // LOGGER.info("Num of attachments="+new // Integer(numOfAttachments).toString()); boolean readOnly = this.checkReadOnlyAccess(curDoc); this.setReadOnly(readOnly); LOGGER.info("Creation date for " + curDoc.getUniversalID() + " =" + curDoc.getCreated().toString() + "; Time zone=" + curDoc.getCreated().getZoneTime() + "; Local time=" + curDoc.getCreated().getLocalTime()); Date curCreationDate = curDoc.getCreated().toJavaDate(); LOGGER.info("Current date in Java is " + curCreationDate.toString() + "Time zone=" + new Integer(curCreationDate.getTimezoneOffset()).toString() + "; Locale time is:" + curCreationDate.toLocaleString()); if (curDoc.hasItem("DAVCreated")) { // Item davCreated=curDoc.getFirstItem("DAVCreated"); @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); if (curCreationDate == null) { curCreationDate = curDoc.getCreated().toJavaDate(); } } } } } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); if (curChangeDate == null) { curChangeDate = curDoc.getLastModified().toJavaDate(); } } } } } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); LOGGER.info("Creation date is set to " + this.getCreationDate().toString()); LOGGER.info("Last modified date is set to " + this.getLastModified().toString()); String pubHRef = ((IDAVAddressInformation) this.getRepository()).getPublicHref(); // LOGGER.info("THIS getpublichref="+this.getPublicHref()); String curAttName = null; if (numOfAttachments == 0) { // LOGGER.info(getCallingMethod()+":"+"Start setting resource"); this.setName(docID); String name = curDoc.getItemValueString( ((DAVRepositoryDominoDocuments) (this.getRepository())).getDirectoryField()); this.setName(name); if (this.getPublicHref().equals("")) { // try{ this.setPublicHref(pubHRef + "/" + name); // URLEncoder.encode(name, "UTF-8")); // }catch(UnsupportedEncodingException e){ // LOGGER.error(e); // } } this.setCollection(true); this.setInternalAddress( ((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID); this.setResourceType("NotesDocument"); this.setMember(false); this.setContentLength(0L); // this.fetchChildren(); } else { curAttName = allEmbedded.get(0).toString(); // LOGGER.info("Attachment name is "+curAttName); this.setMember(true); this.setResourceType("NotesAttachment"); if (this.getPublicHref().equals("")) { try { this.setPublicHref(pubHRef + "/" + URLEncoder.encode(curAttName, "UTF-8")); } catch (UnsupportedEncodingException e) { LOGGER.error(e); } // this.setPublicHref( pubHRef+"/"+curAttName); } this.setInternalAddress(((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID + "/$File/" + curAttName); this.setCollection(false); this.setName(curAttName); EmbeddedObject curAtt = curDoc.getAttachment(curAttName); if (curAtt == null) { // LOGGER.info("Error! Current Embedded is null"); return; } else { // LOGGER.info("Embedded is not null. OK! "); } Long curSize = new Long(curAtt.getFileSize()); this.setContentLength(curSize); } // LOGGER.info("Current res realized! pubHREF="+this.getPublicHref()+"; Internal Address="+this.getInternalAddress()+"; "); } catch (NotesException ne) { LOGGER.error("ERROR! Can not set; " + ne.getMessage()); } }