Java Code Examples for net.fortuna.ical4j.model.Property#getValue()

The following examples show how to use net.fortuna.ical4j.model.Property#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DavAvailability.java    From cosmo with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Imports a calendar object containing a VAVAILABILITY. 
 * @param cal The calendar imported.
 * @throws CosmoDavException - if something is wrong this exception is thrown.
 * </p>
 */
public void setCalendar(Calendar cal) throws CosmoDavException {
    AvailabilityItem availability = (AvailabilityItem) getItem();
    
    availability.setAvailabilityCalendar(cal);
    
    Component comp = cal.getComponent(ICalendarConstants.COMPONENT_VAVAILABLITY);
    if (comp==null) {
        throw new UnprocessableEntityException("VCALENDAR does not contain a VAVAILABILITY");
    }

    String val = null;
    Property prop = comp.getProperty(Property.UID);
    if (prop != null) {
        val = prop.getValue();
    }
    if (StringUtils.isBlank(val)) {
        throw new UnprocessableEntityException("VAVAILABILITY does not contain a UID");
    }
    availability.setIcalUid(val);
}
 
Example 2
Source File: JsonObservanceAdapter.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public Object getJsonProperty(String property) {
	if ( JSON_START.equals(property)) {
		return new JsonDatePropertyAdapter(_observance.getStartDate());
	}
	else if ( JSON_OFFSET_FROM.equals(property) ) {
		return _observance.getOffsetFrom().getValue();
	}
	else if ( JSON_OFFSET_TO.equals(property) ) {
		return _observance.getOffsetTo().getValue();
	}
	else if ( JSON_RECURRENCE_RULE.equals(property) ) {
		Property rrule = _observance.getProperty(RRULE);
		if ( rrule != null ) {
			return rrule.getValue();
		}
	}
	
	return null;
}
 
Example 3
Source File: Utils.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Reads an iCalendar property value and then unescapes it.
 * 
 * @param property
 * RFC         Java
 * \n          \r\n
 * \,          ,
 * \;          ; 
 * \\          \
 * @return
 */
public static String getUnescapedString(Property property) {
    String value = null;
    
    if ( property != null ) {
        value = property.getValue();
    }
    
    if ( value != null ) {
        
        // Replace all occurences of "\\n" with "\r\n".
        value = value.replaceAll("(?<!\\\\)\\\\n", "\r\n"); // $NON-NLS-1$ $NON-NLS-2$
        value = value.replaceAll("(?<!\\\\)\\\\N", "\r\n"); // $NON-NLS-1$ $NON-NLS-2$
        
        // Unescape all commas.
        value = value.replaceAll("\\\\,", ",");
        // Unescape all semicolons
        value = value.replaceAll("\\\\;", ";");
        // Unescape all backslashes.
        value = value.replaceAll("\\\\\\\\", "\\\\");
    }
    
    return value;
}
 
Example 4
Source File: EventReloaderJob.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns a list of categories or an empty list if none found.
 *
 * @param vEvent
 * @return
 */
private List<String> readCategory(VEvent vEvent) {
    PropertyList<Property> propertyCategoryList = vEvent.getProperties(Property.CATEGORIES);
    ArrayList<String> splittedCategoriesToReturn = new ArrayList<String>();
    if (propertyCategoryList != null) {
        for (int categoriesLineNum = 0; categoriesLineNum < propertyCategoryList.size(); categoriesLineNum++) {
            Property propertyCategory = propertyCategoryList.get(categoriesLineNum);
            String categories = propertyCategory.getValue();
            if (categories != null) {
                String[] categoriesSplit = StringUtils.split(categories, ",");
                for (String category : categoriesSplit) {
                    if (!splittedCategoriesToReturn.contains(category)) {
                        splittedCategoriesToReturn.add(category);
                    }
                }
            }
        }
    }

    return splittedCategoriesToReturn;
}
 
Example 5
Source File: ICalConverter.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
protected static String fromXProperty(PropertyList<Property> propertyList, String propertyName) {
    if (propertyName == null) {
        return null;
    }
    Property property = propertyList.getProperty(propertyName);
    if (property != null) {
        return property.getValue();
    }
    return null;
}
 
Example 6
Source File: ICalendarUtils.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Get X property value from component;
 * @param property x property to get
 * @param comp component
 * @return value of xproperty, null if property does not exist
 */
public static String getXProperty(String property, Component comp) {
    Property prop = comp.getProperties().getProperty(property);
    if(prop!=null) {
        return prop.getValue();
    }
    else {
        return null;
    }
}
 
Example 7
Source File: HibBaseEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public String getLocation() {
    Property p = getEvent().getProperties().
        getProperty(Property.LOCATION);
    if (p == null) {
        return null;
    }
    return p.getValue();
}
 
Example 8
Source File: HibBaseEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public String getStatus() {
    Property p = getEvent().getProperties().
        getProperty(Property.STATUS);
    if (p == null) {
        return null;
    }
    return p.getValue();
}
 
Example 9
Source File: StandardContentService.java    From cosmo with Apache License 2.0 5 votes vote down vote up
private void checkDatesForComponent(Component component){
    if(component == null){
        return;
    }
    
    Property dtStart = component.getProperty(Property.DTSTART);
    Property dtEnd = component.getProperty(Property.DTEND);
    
    if( dtStart instanceof DtStart && dtStart.getValue()!= null 
        && dtEnd instanceof DtEnd && dtEnd.getValue() != null 
       && ((DtStart)dtStart).getDate().compareTo(((DtEnd)dtEnd).getDate()) > 0 ){
        throw new IllegalArgumentException("End date [" + dtEnd + " is lower than start date [" + dtStart + "]");
    }
    
}
 
Example 10
Source File: EventValidator.java    From cosmo with Apache License 2.0 5 votes vote down vote up
private static boolean isTextPropertyValid(Property prop, int minLength, int maxLength) {

            if (prop == null && minLength == 0) {
                return true;
            } else if (prop == null) {
                return false;
            }
            String value = prop.getValue();
            int valueSize = value == null ? 0 : value.length();
            if (valueSize < minLength || valueSize > maxLength) {
                return false;
            }

            return true;
        }
 
Example 11
Source File: MockBaseEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Gets location.
 * @return The location.
 */
public String getLocation() {
    Property p = getEvent().getProperties().
        getProperty(Property.LOCATION);
    if (p == null) {
        return null;
    }
    return p.getValue();
}
 
Example 12
Source File: MockBaseEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Gets status.
 * @return The status.
 */
public String getStatus() {
    Property p = getEvent().getProperties().
        getProperty(Property.STATUS);
    if (p == null) {
        return null;
    }
    return p.getValue();
}
 
Example 13
Source File: ICalConverter.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
protected static ResponseProperties storePartyAssignments(String workEffortId, Component component, Map<String, Object> context) {
    ResponseProperties responseProps = null;
    Map<String, Object> serviceMap = new HashMap<>();
    List<Property> partyList = new LinkedList<>();
    partyList.addAll(UtilGenerics.checkList(component.getProperties("ATTENDEE"), Property.class));
    partyList.addAll(UtilGenerics.checkList(component.getProperties("CONTACT"), Property.class));
    partyList.addAll(UtilGenerics.checkList(component.getProperties("ORGANIZER"), Property.class));
    for (Property property : partyList) {
        String partyId = fromXParameter(property.getParameters(), partyIdXParamName);
        if (partyId == null) {
            serviceMap.clear();
            String address = property.getValue();
            if (address.toUpperCase(Locale.getDefault()).startsWith("MAILTO:")) {
                address = address.substring(7);
            }
            serviceMap.put("address", address);
            Map<String, Object> result = invokeService("findPartyFromEmailAddress", serviceMap, context);
            partyId = (String) result.get("partyId");
            if (partyId == null) {
                continue;
            }
            replaceParameter(property.getParameters(), toXParameter(partyIdXParamName, partyId));
        }
        serviceMap.clear();
        serviceMap.put("workEffortId", workEffortId);
        serviceMap.put("partyId", partyId);
        serviceMap.put("roleTypeId", fromRoleMap.get(property.getName()));
        Delegator delegator = (Delegator) context.get("delegator");
        List<GenericValue> assignments = null;
        try {
            assignments = EntityQuery.use(delegator).from("WorkEffortPartyAssignment").where(serviceMap).filterByDate().queryList();
            if (assignments.size() == 0) {
                serviceMap.put("statusId", "PRTYASGN_OFFERED");
                serviceMap.put("fromDate", new Timestamp(System.currentTimeMillis()));
                invokeService("assignPartyToWorkEffort", serviceMap, context);
            }
        } catch (GenericEntityException e) {
            responseProps = ICalWorker.createPartialContentResponse(e.getMessage());
            break;
        }
    }
    return responseProps;
}