Skip to content

Commit

Permalink
option to either synchronize or omit birth dates during contact sync. c…
Browse files Browse the repository at this point in the history
…lose #2564
  • Loading branch information
j-dimension committed Oct 11, 2024
1 parent ea8c956 commit a443167
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 13 deletions.
Binary file modified j-lawyer-client/lib/j-lawyer-cloud/j-lawyer-cloud.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="chkBookSync" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
Expand All @@ -51,6 +47,16 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="27" pref="27" max="-2" attributes="0"/>
<Component id="chkBirthdaySync" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="chkBookSync" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
Expand All @@ -60,12 +66,14 @@
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="chkBookSync" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkBirthdaySync" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="pnlCloud" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cmdGetAdressBooks" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cmbAddressBook" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
Expand Down Expand Up @@ -140,5 +148,10 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdGetAdressBooksActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="chkBirthdaySync">
<Properties>
<Property name="text" type="java.lang.String" value="Geburtsdaten synchronisieren"/>
</Properties>
</Component>
</SubComponents>
</Form>
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ public AddressBookSetupDialog(java.awt.Frame parent, boolean modal) {
try {

this.chkBookSync.setSelected(s.getSettingAsBoolean(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_ENABLED, false));
this.chkBirthdaySync.setSelected(s.getSettingAsBoolean(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_BIRTHDAYSYNC, true));
this.pnlCloud.setCloudHost(s.getSetting(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_HOST, ""));

this.pnlCloud.setCloudPath(s.getSetting(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_PATH, ""));
Expand Down Expand Up @@ -773,6 +774,7 @@ private void initComponents() {
cmbAddressBook = new javax.swing.JComboBox<>();
cmdSave = new javax.swing.JButton();
cmdGetAdressBooks = new javax.swing.JButton();
chkBirthdaySync = new javax.swing.JCheckBox();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Adressbuch-Synchronisation");
Expand Down Expand Up @@ -805,16 +807,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

chkBirthdaySync.setText("Geburtsdaten synchronisieren");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(chkBookSync)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
Expand All @@ -828,15 +829,24 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(cmbAddressBook, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdGetAdressBooks))
.addComponent(nextcloudTeaserPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE)
.addComponent(nextcloudTeaserPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 576, Short.MAX_VALUE)
.addComponent(pnlCloud, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(chkBirthdaySync))
.addComponent(chkBookSync))
.addGap(0, 0, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(chkBookSync)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkBirthdaySync)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pnlCloud, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
Expand Down Expand Up @@ -871,6 +881,7 @@ private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
try {
ServerSettings s = ServerSettings.getInstance();
s.setSettingAsBoolean(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_ENABLED, this.chkBookSync.isSelected());
s.setSettingAsBoolean(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_BIRTHDAYSYNC, this.chkBirthdaySync.isSelected());
s.setSetting(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_HOST, this.pnlCloud.getCloudHost());
s.setSetting(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_HREF, ((CloudAddressBook) this.cmbAddressBook.getSelectedItem()).getHref());
s.setSetting(ServerSettings.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_PATH, this.pnlCloud.getCloudPath());
Expand Down Expand Up @@ -958,6 +969,7 @@ public void windowClosing(java.awt.event.WindowEvent e) {
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox chkBirthdaySync;
private javax.swing.JCheckBox chkBookSync;
private javax.swing.JComboBox<String> cmbAddressBook;
private javax.swing.JButton cmdClose;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ You should also get your employer (if you work as a programmer) or school,
import org.apache.jackrabbit.webdav.property.DavPropertySet;
import org.jlawyer.cloud.contacts.CloudAddressBook;
import org.jlawyer.cloud.contacts.CloudContact;
//import org.osaf.caldav4j.methods.GetMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -713,6 +712,8 @@ public class NextcloudContactsConnector {
protected int port = 443;
protected String userName = null;
protected String password = null;

private boolean synchronizeBirthdays=false;

public NextcloudContactsConnector(String serverName, boolean useHTTPS, int port, String userName, String password) {
this.serverName = serverName;
Expand Down Expand Up @@ -916,7 +917,7 @@ private VCard getVCard(CloudContact c) {
n.setGiven(c.getFirstName());
//n.getPrefixes().add("Mr");

if (c.getBirthDate() != null && !("".equals(c.getBirthDate()))) {
if (this.synchronizeBirthdays && c.getBirthDate() != null && !("".equals(c.getBirthDate()))) {
try {
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
Date d = df.parse(c.getBirthDate());
Expand Down Expand Up @@ -1178,4 +1179,18 @@ public void setPassword(String password) {
this.password = password;
}

/**
* @return the synchronizeBirthdays
*/
public boolean isSynchronizeBirthdays() {
return synchronizeBirthdays;
}

/**
* @param synchronizeBirthdays the synchronizeBirthdays to set
*/
public void setSynchronizeBirthdays(boolean synchronizeBirthdays) {
this.synchronizeBirthdays = synchronizeBirthdays;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ public class ServerSettingsKeys {
public static final String SERVERCONF_SECURITY_FORCE_PASSWORDCOMPLEXITY="jlawyer.server.security.forcepasswordcomplexity";

public static final String SERVERCONF_CLOUDSYNC_ADDRESSBOOK_ENABLED="jlawyer.server.cloudsync.addressbook.enabled";
public static final String SERVERCONF_CLOUDSYNC_ADDRESSBOOK_BIRTHDAYSYNC="jlawyer.server.cloudsync.addressbook.birthdaysync";
public static final String SERVERCONF_CLOUDSYNC_ADDRESSBOOK_HOST="jlawyer.server.cloudsync.addressbook.host";
public static final String SERVERCONF_CLOUDSYNC_ADDRESSBOOK_PORT="jlawyer.server.cloudsync.addressbook.port";
public static final String SERVERCONF_CLOUDSYNC_ADDRESSBOOK_SSL="jlawyer.server.cloudsync.addressbook.ssl";
Expand Down
Binary file modified j-lawyer-server/j-lawyer-server-ejb/lib/j-lawyer-cloud.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,16 @@ private NextcloudContactsConnector getConnector() {
return null;
}
}

boolean synchronizeBirthdays=true;
s = this.settings.find(ServerSettingsKeys.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_BIRTHDAYSYNC);
if (s != null) {
if ("on".equalsIgnoreCase(s.getSettingValue()) || "1".equalsIgnoreCase(s.getSettingValue()) || "true".equalsIgnoreCase(s.getSettingValue())) {
synchronizeBirthdays=true;
} else {
synchronizeBirthdays=false;
}
}

String host = null;
s = this.settings.find(ServerSettingsKeys.SERVERCONF_CLOUDSYNC_ADDRESSBOOK_HOST);
Expand Down Expand Up @@ -808,6 +818,7 @@ private NextcloudContactsConnector getConnector() {
NextcloudContactsConnector nc = new NextcloudContactsConnector(host, ssl, port, user, pwd);
if(subPath!=null && !ServerStringUtils.isEmpty(subPath))
nc.setSubpathPrefix(subPath);
nc.setSynchronizeBirthdays(synchronizeBirthdays);
return nc;
} catch (Throwable t) {
log.error("Unable to get Nextcloud CardDAV connector", t);
Expand Down

0 comments on commit a443167

Please sign in to comment.