diff --git a/ccm-cms/src/com/arsdigita/cms/FolderRetrieveTest.java b/ccm-cms/src/com/arsdigita/cms/FolderRetrieveTest.java new file mode 100644 index 000000000..2570036c2 --- /dev/null +++ b/ccm-cms/src/com/arsdigita/cms/FolderRetrieveTest.java @@ -0,0 +1,42 @@ +package com.arsdigita.cms; + +import com.arsdigita.util.cmd.Program; +import java.io.PrintWriter; +import org.apache.commons.cli.CommandLine; + +/** + * + * @author Jens Pelzetter + */ +public class FolderRetrieveTest extends Program { + + public FolderRetrieveTest() { + super("FolderRetrieveTest", "1.0.0", ""); + } + + public static final void main(final String[] args) { + new FolderRetrieveTest().run(args); + } + + public void doRun(final CommandLine cmdLine) { + + final PrintWriter writer = new PrintWriter(System.out); + + final ContentSectionCollection sections = ContentSection.getAllSections(); + sections.addEqualsFilter("label", "content"); + sections.next(); + final ContentSection section = sections.getContentSection(); + + final Folder folder = Folder.retrieveFolder(section, "/personen"); + + if (folder == null) { + writer.println("Failed to get folder."); + } else { + writer.printf("Got folder '%s'\n", folder.getPath()); + } + + writer.flush(); + + } + +} diff --git a/ccm-core/src/com/arsdigita/util/cmd/SetNewPassword.java b/ccm-core/src/com/arsdigita/util/cmd/SetNewPassword.java new file mode 100644 index 000000000..4b6f62794 --- /dev/null +++ b/ccm-core/src/com/arsdigita/util/cmd/SetNewPassword.java @@ -0,0 +1,54 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.arsdigita.util.cmd; + +import com.arsdigita.kernel.User; +import com.arsdigita.kernel.UserAuthentication; +import com.arsdigita.kernel.UserCollection; +import org.apache.commons.cli.CommandLine; + +/** + * + * @author Jens Pelzetter + */ +public class SetNewPassword extends Program{ + + public SetNewPassword() { + super("SetNewPasswort", "1.0.0", "SetNewPassword screenname newpassword"); + } + + @Override + protected void doRun(CommandLine cmdLine) { + final String[] args = cmdLine.getArgs(); + + if (args.length != 2) { + System.out.println("Usage: SetNewPassword screenname newpassword"); + return; + } + + final UserCollection users = User.retrieveAll(); + users.addEqualsFilter("screenName", args[0]); + if (users.isEmpty()) { + System.out.printf("User '%s' not found.\n", args[0]); + return; + } + + users.next(); + final User user = users.getUser(); + users.close(); + + final UserAuthentication auth = UserAuthentication.retrieveForUser(user); + auth.setPassword(args[1]); + auth.save(); + + System.out.println("Set new password"); + + } + + public static void main(final String[] args) { + new SetNewPassword().run(args); + } + +}