converted to maven project
This commit is contained in:
commit
da8c7278d5
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
661
LICENSE.txt
Normal file
661
LICENSE.txt
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
13
authorization/.gitignore
vendored
Normal file
13
authorization/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
661
authorization/LICENSE.txt
Normal file
661
authorization/LICENSE.txt
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
54
authorization/pom.xml
Normal file
54
authorization/pom.xml
Normal file
@ -0,0 +1,54 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>authorization</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin Authorization</name>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,60 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public class CASTicketValidator implements TicketValidator {
|
||||
|
||||
private final String proxyValidateURL;
|
||||
private final String proxyServiceURL;
|
||||
|
||||
public CASTicketValidator() throws TechnicalException {
|
||||
Config config = Config.getInstance();
|
||||
proxyValidateURL = config.getProperty(Config.CAS_VALIDATE_URL);
|
||||
proxyServiceURL = config.getProperty(Config.CAS_SERVICE_URL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String validate(final String ticket) throws UserException, TechnicalException {
|
||||
if (proxyServiceURL == null || proxyValidateURL == null) {
|
||||
throw new TechnicalException("TicketValidator is not initialized.");
|
||||
}
|
||||
try {
|
||||
URL url = new URL(proxyValidateURL + "?service=" + proxyServiceURL + "&ticket=" + ticket);
|
||||
URLConnection httpConnection = url.openConnection();
|
||||
httpConnection.connect();
|
||||
InputStream inputStream = httpConnection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String nextLine = reader.readLine();
|
||||
while (nextLine != null) {
|
||||
if (nextLine.contains("<cas:user>")) {
|
||||
String user = extractUser(nextLine);
|
||||
inputStream.close();
|
||||
return user;
|
||||
}
|
||||
nextLine = reader.readLine();
|
||||
}
|
||||
inputStream.close();
|
||||
throw new UserException(new UserError(UserError.MSG_INVALID_TICKET));
|
||||
} catch (IOException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String extractUser(String nextLine) {
|
||||
int start = nextLine.indexOf("<cas:user>");
|
||||
int end = nextLine.indexOf("</cas:user>");
|
||||
String user = nextLine.substring(start + 10, end);
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
@Stateless
|
||||
public class LoginService implements LoginServiceLocal {
|
||||
|
||||
@PersistenceContext(name = "hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
private TicketValidator ticketValidator;
|
||||
|
||||
@Override
|
||||
public RequestContext createContext(final String ticket, final String runAsUser) throws UserException, TechnicalException {
|
||||
if (ticket != null && !ticket.isEmpty()) {
|
||||
final String ticketUser = validateTicket(ticket);
|
||||
String runAs = runAsUser;
|
||||
if (runAs == null || runAs.isEmpty()) {
|
||||
runAs = ticketUser;
|
||||
} else {
|
||||
checkRunAsAllowed(ticketUser, runAs);
|
||||
}
|
||||
Role scope = findRunAsRole(runAs);
|
||||
return new RequestContext(runAsUser, scope);
|
||||
}
|
||||
throw new UserException(new UserError(UserError.MSG_INVALID_TICKET, ticket));
|
||||
}
|
||||
|
||||
private Role findRunAsRole(final String login) throws TechnicalException {
|
||||
Role resultRole = Role.NONE;
|
||||
if (hasHostmasterRole(login)) {
|
||||
resultRole = Role.SYSTEM;
|
||||
} else {
|
||||
if (hasCustomerRole(login)) {
|
||||
resultRole = Role.CUSTOMER;
|
||||
} else {
|
||||
if (hasPacAdminRole(login)) {
|
||||
resultRole = Role.PACKET;
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultRole;
|
||||
}
|
||||
|
||||
private boolean hasCustomerRole(final String login) throws TechnicalException {
|
||||
final String customersPac = Config.getInstance().getProperty(Config.PAC_CUSTOMER_ACCOUNTS);
|
||||
return login.startsWith(customersPac) && login.length() == 9 && login.charAt(5) == '-';
|
||||
}
|
||||
|
||||
private boolean hasHostmasterRole(final String login) throws TechnicalException {
|
||||
final String hostmastersPac = Config.getInstance().getProperty(Config.PAC_HOSTMASTER_ACCOUNTS);
|
||||
return login.length() == 2 || ( login.startsWith(hostmastersPac) && login.length() == 8 && login.charAt(5) == '-' );
|
||||
}
|
||||
|
||||
private boolean hasPacAdminRole(final String login) throws TechnicalException {
|
||||
return login.length() == 5;
|
||||
}
|
||||
|
||||
private void checkRunAsAllowed(final String ticketUser, final String runAsUser)
|
||||
throws UserException {
|
||||
assert ticketUser != null && !ticketUser.isEmpty();
|
||||
assert runAsUser != null && !runAsUser.isEmpty();
|
||||
if (ticketUser.length() != 2 && !runAsUser.startsWith(ticketUser)) {
|
||||
throw new UserException(new UserError(
|
||||
UserError.MSG_FORBIDDEN_RUNAS, ticketUser, runAsUser));
|
||||
}
|
||||
}
|
||||
|
||||
private String validateTicket(final String ticket) throws TechnicalException, UserException {
|
||||
final TicketValidator ticketValidator = getTicketValidator();
|
||||
return ticketValidator.validate(ticket);
|
||||
}
|
||||
|
||||
private TicketValidator getTicketValidator() throws TechnicalException {
|
||||
if (ticketValidator == null) {
|
||||
try {
|
||||
final String property = Config.getInstance().getProperty(Config.TICKETVALIDATOR_CLASS);
|
||||
final Class<?> validatorClass = Class.forName(property);
|
||||
ticketValidator = (TicketValidator) validatorClass.newInstance();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
return ticketValidator;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
@Local
|
||||
public interface LoginServiceLocal {
|
||||
|
||||
RequestContext createContext(String ticket, String runAsUser) throws UserException, TechnicalException;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
public class RequestContext {
|
||||
|
||||
private final String runAsLogin;
|
||||
private final Role runAsRole;
|
||||
|
||||
public RequestContext(final String runAs, final Role runAsRole) {
|
||||
this.runAsLogin = runAs;
|
||||
this.runAsRole = runAsRole;
|
||||
}
|
||||
|
||||
public String getLoginUser() {
|
||||
return runAsLogin;
|
||||
}
|
||||
|
||||
public Role getLoginRole() {
|
||||
return runAsRole;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface RequiredScope {
|
||||
|
||||
ScopePolicy[] value();
|
||||
|
||||
}
|
7
authorization/src/main/java/de/hsadmin/login/Role.java
Normal file
7
authorization/src/main/java/de/hsadmin/login/Role.java
Normal file
@ -0,0 +1,7 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
public enum Role {
|
||||
|
||||
SYSTEM, CUSTOMER, HIVE, PACKET, DOMAIN, USER, NONE, ANY
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
|
||||
public @interface ScopePolicy {
|
||||
|
||||
Role value();
|
||||
String property() default "";
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
public class TestTicketValidator implements TicketValidator {
|
||||
|
||||
@Override
|
||||
public String validate(final String ticket) {
|
||||
final int colonPosition = ticket.indexOf(':');
|
||||
final String ticketUser = ticket.substring(colonPosition + 1);
|
||||
return ticketUser;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public interface TicketValidator {
|
||||
|
||||
String validate(String ticket) throws UserException, TechnicalException;
|
||||
|
||||
}
|
13
cli/.gitignore
vendored
Normal file
13
cli/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
661
cli/LICENSE.txt
Normal file
661
cli/LICENSE.txt
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
52
cli/pom.xml
Normal file
52
cli/pom.xml
Normal file
@ -0,0 +1,52 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>cli</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin Cli</name>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-client</artifactId>
|
||||
<version>3.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jline</groupId>
|
||||
<artifactId>jline</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
80
cli/src/main/java/de/hsadmin/jscli/Main.java
Normal file
80
cli/src/main/java/de/hsadmin/jscli/Main.java
Normal file
@ -0,0 +1,80 @@
|
||||
package de.hsadmin.jscli;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import de.hsadmin.jscli.conf.CommandlineParser;
|
||||
import de.hsadmin.jscli.console.ConsoleWrapper;
|
||||
import de.hsadmin.jscli.json.JSONFormatter;
|
||||
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final ConsoleWrapper console = new ConsoleWrapper();
|
||||
final JSONFormatter formatter = new JSONFormatter();
|
||||
try {
|
||||
final CommandlineParser cmdParser = new CommandlineParser(args);
|
||||
final String runAs = cmdParser.getRunAs();
|
||||
console.open(runAs + "@hsadmin> ");
|
||||
final String user = cmdParser.getUser();
|
||||
final ScriptClient scriptClient = new ScriptClient(console, user, runAs, cmdParser.getArgs());
|
||||
final String file = cmdParser.getFile();
|
||||
if (file != null && file.length() > 0) {
|
||||
if ("-".equals(file)) {
|
||||
scriptClient.execute(new InputStreamReader(System.in));
|
||||
console.println(formatter.format(scriptClient.getLastRpcResult()));
|
||||
} else {
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
bufferedReader = new BufferedReader(new FileReader(file));
|
||||
String inputLine = bufferedReader.readLine();
|
||||
boolean isFirstLine = true;
|
||||
final StringBuffer scriptFromFile = new StringBuffer();
|
||||
while (inputLine != null) {
|
||||
if (isFirstLine && inputLine.startsWith("#!")) {
|
||||
scriptFromFile.append("//");
|
||||
scriptFromFile.append(inputLine.substring(2));
|
||||
} else {
|
||||
scriptFromFile.append(inputLine);
|
||||
}
|
||||
scriptFromFile.append("\n");
|
||||
isFirstLine = false;
|
||||
inputLine = bufferedReader.readLine();
|
||||
}
|
||||
scriptClient.execute(scriptFromFile.toString());
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("File not found: " + file);
|
||||
} finally {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String expr = cmdParser.getExpression();
|
||||
if (expr != null && expr.length() > 0) {
|
||||
scriptClient.execute(expr);
|
||||
console.println(formatter.format(scriptClient.getLastRpcResult()));
|
||||
}
|
||||
if (cmdParser.isInteractive()) {
|
||||
String command = console.readInput();
|
||||
while (!("bye".equals(command.trim()) || "exit".equals(command.trim()) || "quit".equals(command.trim()))) {
|
||||
try {
|
||||
scriptClient.execute(command);
|
||||
console.println(formatter.format(scriptClient.getLastRpcResult()));
|
||||
} catch (Exception e) {
|
||||
console.println("Error: " + e.getLocalizedMessage() + "\n");
|
||||
}
|
||||
command = console.readInput();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
92
cli/src/main/java/de/hsadmin/jscli/RpcClient.java
Normal file
92
cli/src/main/java/de/hsadmin/jscli/RpcClient.java
Normal file
@ -0,0 +1,92 @@
|
||||
package de.hsadmin.jscli;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
||||
|
||||
import de.hsadmin.jscli.cas.CASTicketProvider;
|
||||
import de.hsadmin.jscli.conf.Config;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public class RpcClient {
|
||||
|
||||
private static final String XMLRPC_URL = "https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin";
|
||||
|
||||
private final List<XmlRpcClient> clientList;
|
||||
private final Map<String, XmlRpcClient> clientMap;
|
||||
|
||||
public RpcClient(final CASTicketProvider tgt) throws JSCliException {
|
||||
clientList = new ArrayList<XmlRpcClient>();
|
||||
clientMap = new HashMap<String, XmlRpcClient>();
|
||||
try {
|
||||
final String xmlrpcURLsString = Config.getInstance().getProperty("xmlrpcURL", XMLRPC_URL);
|
||||
final String[] xmlrpcURLsArray = xmlrpcURLsString.split(",");
|
||||
for (final String xmlrpcURL : xmlrpcURLsArray) {
|
||||
final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
|
||||
config.setServerURL(new URL(xmlrpcURL));
|
||||
config.setEnabledForExtensions(true);
|
||||
final XmlRpcClient client = new XmlRpcClient();
|
||||
client.setConfig(config);
|
||||
clientList.add(client);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> listMethods() throws JSCliException {
|
||||
final List<String> methodList = new ArrayList<String>();
|
||||
for (final XmlRpcClient client : clientList) {
|
||||
final List<Object> execute = execute(client, "system.listMethods");
|
||||
for (final Object obj : execute) {
|
||||
final String methodString = obj.toString();
|
||||
final String[] path = methodString.split("\\.");
|
||||
if (path.length == 2) {
|
||||
clientMap.put(path[0], client);
|
||||
}
|
||||
methodList.add(methodString);
|
||||
}
|
||||
}
|
||||
return methodList;
|
||||
}
|
||||
|
||||
private List<Object> execute(final XmlRpcClient client, final String method) throws JSCliException {
|
||||
return execute(client, method, new ArrayList<Object>());
|
||||
}
|
||||
|
||||
private List<Object> execute(final XmlRpcClient client, final String method, final List<?> params) throws JSCliException {
|
||||
try {
|
||||
final Object execute = client.execute(method, params);
|
||||
final ArrayList<Object> list = new ArrayList<Object>();
|
||||
if (execute instanceof Object[]) {
|
||||
final Object[] resArray = (Object[]) execute;
|
||||
for (int idx=0; idx < resArray.length; idx++) {
|
||||
list.add(resArray[idx]);
|
||||
}
|
||||
}
|
||||
if (execute instanceof Map) {
|
||||
list.add(execute);
|
||||
}
|
||||
return list;
|
||||
} catch (XmlRpcException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object> execute(final String method, final List<?> params) throws JSCliException {
|
||||
final String[] path = method.split("\\.");
|
||||
if (path.length == 2) {
|
||||
return execute(clientMap.get(path[0]), method, params);
|
||||
} else {
|
||||
throw new JSCliException("method not found: " + method);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
127
cli/src/main/java/de/hsadmin/jscli/ScriptClient.java
Normal file
127
cli/src/main/java/de/hsadmin/jscli/ScriptClient.java
Normal file
@ -0,0 +1,127 @@
|
||||
package de.hsadmin.jscli;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import de.hsadmin.jscli.cas.CASTicketProvider;
|
||||
import de.hsadmin.jscli.console.ConsoleWrapper;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public class ScriptClient {
|
||||
|
||||
final private ScriptEngine engine;
|
||||
final private Set<String> completionStrings;
|
||||
|
||||
public ScriptClient(final ConsoleWrapper console, final String user, final String runAs, final String... arguments) throws JSCliException {
|
||||
final CASTicketProvider ticketProvider = new CASTicketProvider(console, user, runAs);
|
||||
final RpcClient rpcClient = new RpcClient(ticketProvider);
|
||||
final ScriptEngineManager engineManager = new ScriptEngineManager();
|
||||
engine = engineManager.getEngineByName("js");
|
||||
engine.put("casgrantingticket", ticketProvider);
|
||||
engine.put("xmlrpcclient", rpcClient);
|
||||
engine.put("xmlrpcLastResult", null);
|
||||
completionStrings = new HashSet<String>();
|
||||
completionStrings.add("set");
|
||||
completionStrings.add("where");
|
||||
considerArguments(arguments);
|
||||
try {
|
||||
final InputStream inputResource = getClass().getClassLoader().getResourceAsStream("js/functions.js");
|
||||
engine.eval(new InputStreamReader(inputResource));
|
||||
} catch (ScriptException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
final List<String> methods = rpcClient.listMethods();
|
||||
for (final String method : methods) {
|
||||
final String[] parts = method.split("\\.");
|
||||
if (parts.length == 2) {
|
||||
final String module = parts[0];
|
||||
final String function = parts[1];
|
||||
if ("system".equals(module) || "getModuleLookup".equals(function) || "createValueObject".equals(function)) {
|
||||
continue;
|
||||
}
|
||||
completionStrings.add(module);
|
||||
final String jsFunctionIdent;
|
||||
if ("delete".equals(function)) {
|
||||
jsFunctionIdent = module + "['remove']";
|
||||
completionStrings.add(module + ".remove");
|
||||
} else {
|
||||
jsFunctionIdent = module + "['" + function + "']";
|
||||
completionStrings.add(module + "." + function);
|
||||
}
|
||||
try {
|
||||
engine.eval(
|
||||
"if (typeof " + module + " === 'undefined')" +
|
||||
" { var " + module + " = { }; };\n" +
|
||||
jsFunctionIdent +
|
||||
" = function(json) { return hsaModuleCall('" + module + "', '" + function + "', json); }"
|
||||
);
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
console.codeCompletion(getCodeCompletionStrings());
|
||||
}
|
||||
|
||||
public String[] getCodeCompletionStrings() {
|
||||
final String[] codeCompletionStrings = new String[completionStrings.size()];
|
||||
int idx = 0;
|
||||
for (final String s : completionStrings) {
|
||||
codeCompletionStrings[idx] = s;
|
||||
idx++;
|
||||
}
|
||||
return codeCompletionStrings;
|
||||
}
|
||||
|
||||
public Object execute(final String snippet) throws JSCliException {
|
||||
try {
|
||||
engine.put("xmlrpcLastResult", null);
|
||||
return engine.eval(snippet);
|
||||
} catch (ScriptException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object execute(final Reader rd) throws JSCliException {
|
||||
try {
|
||||
engine.put("xmlrpcLastResult", null);
|
||||
return engine.eval(rd);
|
||||
} catch (ScriptException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getLastRpcResult() {
|
||||
return engine.get("xmlrpcLastResult");
|
||||
}
|
||||
|
||||
private void considerArguments(final String... arguments)
|
||||
throws JSCliException {
|
||||
final StringBuilder argsBuilder = new StringBuilder("var arguments = [ ");
|
||||
boolean isFirstArg = true;
|
||||
for (final String arg : arguments) {
|
||||
if (!isFirstArg) {
|
||||
argsBuilder.append(", ");
|
||||
}
|
||||
argsBuilder.append('\'');
|
||||
argsBuilder.append(arg);
|
||||
argsBuilder.append('\'');
|
||||
isFirstArg = false;
|
||||
}
|
||||
argsBuilder.append(" ];");
|
||||
try {
|
||||
engine.eval(argsBuilder.toString());
|
||||
} catch (ScriptException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
200
cli/src/main/java/de/hsadmin/jscli/cas/CASTicketProvider.java
Normal file
200
cli/src/main/java/de/hsadmin/jscli/cas/CASTicketProvider.java
Normal file
@ -0,0 +1,200 @@
|
||||
package de.hsadmin.jscli.cas;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import de.hsadmin.jscli.conf.Config;
|
||||
import de.hsadmin.jscli.console.PasswordReader;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public class CASTicketProvider {
|
||||
|
||||
private static final String LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
||||
private static final String BACKEND_URL = "https://config.hostsharing.net:443/hsar/backend";
|
||||
|
||||
final private String loginURL;
|
||||
final private String backendURL;
|
||||
final private String runAs;
|
||||
final private String user;
|
||||
final private PasswordReader passwordReader;
|
||||
|
||||
private String grantingTicket;
|
||||
|
||||
public CASTicketProvider(final PasswordReader console, final String user, final String runAs) throws JSCliException {
|
||||
this.passwordReader = console;
|
||||
this.user = user;
|
||||
this.runAs = runAs;
|
||||
final Config config = Config.getInstance();
|
||||
backendURL = config.getProperty("backendURL", BACKEND_URL);
|
||||
loginURL = config.getProperty("loginURL", LOGIN_URL);
|
||||
if ("TestUmgebung".equals(loginURL)) {
|
||||
grantingTicket = "ticket:" + user;
|
||||
} else {
|
||||
grantingTicket = readFiledGrantingTicket();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTicket() throws JSCliException, FileNotFoundException {
|
||||
if (grantingTicket != null && grantingTicket.startsWith("ticket:")) {
|
||||
return grantingTicket.replaceFirst("ticket", "user");
|
||||
}
|
||||
try {
|
||||
String encodedParams = URLEncoder.encode("service", "UTF-8")
|
||||
+ "=" + URLEncoder.encode(backendURL, "UTF-8");
|
||||
return doHttpPost(grantingTicket, encodedParams);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getRunAs() {
|
||||
return runAs;
|
||||
}
|
||||
|
||||
private String getGrantingTicket() throws JSCliException {
|
||||
grantingTicket = null;
|
||||
String password = Config.getInstance().getProperty(user + ".passWord");
|
||||
if (password == null || password.length() <= 0) {
|
||||
password = readPasswordFromConsole();
|
||||
}
|
||||
try {
|
||||
String encodedParams = URLEncoder.encode("username", "UTF-8")
|
||||
+ "=" + URLEncoder.encode(user, "UTF-8")
|
||||
+ "&" + URLEncoder.encode("password", "UTF-8")
|
||||
+ "=" + URLEncoder.encode(password, "UTF-8");
|
||||
grantingTicket = doHttpPost(loginURL, encodedParams);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new JSCliException(e);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new JSCliException("cas server not available: " + loginURL);
|
||||
}
|
||||
return grantingTicket;
|
||||
}
|
||||
|
||||
private String readPasswordFromConsole() throws JSCliException {
|
||||
return passwordReader.readPassword();
|
||||
}
|
||||
|
||||
private String doHttpPost(final String urlString, final String encodedParams) throws JSCliException, FileNotFoundException {
|
||||
String result = null;
|
||||
try {
|
||||
result = extractTicket(urlString, encodedParams);
|
||||
} catch (FileNotFoundException e) {
|
||||
grantingTicket = getGrantingTicket();
|
||||
saveProperties(grantingTicket, getTicketFile());
|
||||
try {
|
||||
result = extractTicket(grantingTicket, encodedParams);
|
||||
} catch (IOException e1) {
|
||||
throw new JSCliException(e1);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String extractTicket(final String urlString,
|
||||
final String encodedParams) throws MalformedURLException,
|
||||
IOException, ProtocolException {
|
||||
String result;
|
||||
final HttpsURLConnection connection = doConnect(urlString, encodedParams);
|
||||
final String ticket = readTicket(connection);
|
||||
if (ticket != null && ticket.startsWith("ST-")) {
|
||||
result = ticket;
|
||||
} else {
|
||||
result = connection.getHeaderField("Location");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String readTicket(final HttpsURLConnection connection)
|
||||
throws IOException {
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
final String ticket = reader.readLine();
|
||||
String readLine = null;
|
||||
do {
|
||||
readLine = reader.readLine();
|
||||
} while (readLine != null);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
private HttpsURLConnection doConnect(final String urlString,
|
||||
final String encodedParams) throws MalformedURLException,
|
||||
IOException, ProtocolException {
|
||||
final URL url = new URL(urlString);
|
||||
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setAllowUserInteraction(false);
|
||||
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
|
||||
writer.write(encodedParams);
|
||||
writer.close();
|
||||
return connection;
|
||||
}
|
||||
|
||||
private String readFiledGrantingTicket() throws JSCliException {
|
||||
String filedTicket = null;
|
||||
final File file = getTicketFile();
|
||||
final Properties properties = loadProperties(file);
|
||||
filedTicket = properties.getProperty(user);
|
||||
if (filedTicket == null) {
|
||||
filedTicket = getGrantingTicket();
|
||||
saveProperties(filedTicket, file);
|
||||
}
|
||||
return filedTicket;
|
||||
}
|
||||
|
||||
private File getTicketFile() {
|
||||
final String userHome = System.getProperty("user.home");
|
||||
final String ticketFileName = userHome + "/.hsadmin.tgt";
|
||||
return new File(ticketFileName);
|
||||
}
|
||||
|
||||
private void saveProperties(final String filedTicket, final File file) throws JSCliException {
|
||||
final Properties properties = loadProperties(file);
|
||||
if (filedTicket != null) {
|
||||
properties.setProperty(user, filedTicket);
|
||||
try {
|
||||
properties.store(new FileOutputStream(file), "");
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Properties loadProperties(final File file) throws JSCliException {
|
||||
final Properties properties = new Properties();
|
||||
if (file.isFile() && file.canRead()) {
|
||||
try {
|
||||
properties.load(new FileReader(file));
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return grantingTicket;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package de.hsadmin.jscli.conf;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public class CommandlineParser {
|
||||
|
||||
|
||||
private CommandLine cmd;
|
||||
private Options opts;
|
||||
|
||||
public CommandlineParser(String[] args) throws JSCliException {
|
||||
opts = new Options();
|
||||
opts.addOption("h", "help", false, "print this message");
|
||||
opts.addOption("u", "user", true, "specify login user");
|
||||
opts.addOption("r", "runas", true, "specify run-as user");
|
||||
opts.addOption("e", "expr", true, "expression to execute");
|
||||
opts.addOption("f", "file", true, "script file to execute");
|
||||
opts.addOption("i", "interactive", false, "interactive shell");
|
||||
PosixParser parser = new PosixParser();
|
||||
try {
|
||||
if (args.length < 1) {
|
||||
printHelp();
|
||||
System.exit(0);
|
||||
}
|
||||
cmd = parser.parse(opts, args);
|
||||
if (cmd.hasOption("help")) {
|
||||
printHelp();
|
||||
System.exit(0);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
final String systemUser = System.getProperty("user.name");
|
||||
final String configUser = Config.getInstance().getProperty("userName", systemUser);
|
||||
return cmd.getOptionValue("user", configUser);
|
||||
}
|
||||
|
||||
public String getRunAs() {
|
||||
return cmd.getOptionValue("runas", getUser());
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return cmd.getOptionValue("expr", null);
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return cmd.getOptionValue("file", null);
|
||||
}
|
||||
|
||||
public boolean isInteractive() {
|
||||
return cmd.hasOption("interactive");
|
||||
}
|
||||
|
||||
public void printHelp() {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp("hsscript", opts);
|
||||
}
|
||||
|
||||
public String[] getArgs() {
|
||||
return cmd.getArgs();
|
||||
}
|
||||
|
||||
}
|
57
cli/src/main/java/de/hsadmin/jscli/conf/Config.java
Normal file
57
cli/src/main/java/de/hsadmin/jscli/conf/Config.java
Normal file
@ -0,0 +1,57 @@
|
||||
package de.hsadmin.jscli.conf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Config {
|
||||
|
||||
private static Config instance;
|
||||
|
||||
private Properties props;
|
||||
|
||||
private Config() {
|
||||
props = new Properties();
|
||||
File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
|
||||
if (!file.canRead()) {
|
||||
file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/hsadmin/hsadmin.properties");
|
||||
}
|
||||
if (file.canRead()) {
|
||||
try {
|
||||
props.load(new FileReader(file));
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Config getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Config();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getProperty(String propertyName) {
|
||||
String property = props.getProperty(propertyName);
|
||||
if (property == null) {
|
||||
return null;
|
||||
}
|
||||
return property.trim();
|
||||
}
|
||||
|
||||
public String getProperty(String propertyName, String defaultValue) {
|
||||
return props.getProperty(propertyName, defaultValue).trim();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package de.hsadmin.jscli.console;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import jline.ConsoleReader;
|
||||
import jline.History;
|
||||
import jline.SimpleCompletor;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public class ConsoleWrapper implements PasswordReader {
|
||||
|
||||
private ConsoleReader cons;
|
||||
private String prompt;
|
||||
|
||||
public void open(final String prompt) throws JSCliException {
|
||||
this.prompt = prompt;
|
||||
try {
|
||||
cons = new ConsoleReader();
|
||||
cons.setDefaultPrompt(prompt);
|
||||
final String userHome = System.getProperty("user.home");
|
||||
cons.setHistory(new History(new File(userHome + "/.hsscript_history")));
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String readInput() throws JSCliException {
|
||||
try {
|
||||
String line = cons.readLine();
|
||||
while (line.trim().endsWith("\\")) {
|
||||
line = line.substring(0, line.length() - 1) + "\n" + cons.readLine(">");
|
||||
}
|
||||
return line;
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void println(final String text) throws JSCliException {
|
||||
try {
|
||||
if (cons != null) {
|
||||
cons.printString(text);
|
||||
cons.printNewline();
|
||||
} else {
|
||||
throw new JSCliException("cannot write console");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String readPassword() throws JSCliException {
|
||||
try {
|
||||
final String pw = cons.readLine("Password: ", new Character('*'));
|
||||
cons.setDefaultPrompt(prompt);
|
||||
return pw;
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void codeCompletion(final String[] candidateStrings) {
|
||||
cons.addCompletor(new SimpleCompletor(candidateStrings));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package de.hsadmin.jscli.console;
|
||||
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public interface PasswordReader {
|
||||
|
||||
String readPassword() throws JSCliException;
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package de.hsadmin.jscli.exception;
|
||||
|
||||
|
||||
public class JSCliException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public JSCliException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public JSCliException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
104
cli/src/main/java/de/hsadmin/jscli/json/JSONFormatter.java
Normal file
104
cli/src/main/java/de/hsadmin/jscli/json/JSONFormatter.java
Normal file
@ -0,0 +1,104 @@
|
||||
package de.hsadmin.jscli.json;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSONFormatter {
|
||||
|
||||
private int indent = 1;
|
||||
|
||||
public String format(final Object object) {
|
||||
if (object == null) return "";
|
||||
if (object instanceof List<?>) {
|
||||
return formatList((List<?>) object);
|
||||
}
|
||||
if (object instanceof Map<?, ?>) {
|
||||
return formatMap((Map<?, ?>) object);
|
||||
}
|
||||
if (object instanceof String) {
|
||||
return formatString((String) object);
|
||||
}
|
||||
if (object instanceof Boolean) {
|
||||
return ((Boolean) object).toString();
|
||||
}
|
||||
if (object instanceof Object[]) {
|
||||
return formatArr((Object[]) object);
|
||||
}
|
||||
return "an instance of " + object.getClass().getCanonicalName();
|
||||
}
|
||||
|
||||
public String formatMap(final Map<?, ?> map) {
|
||||
final StringBuffer result = new StringBuffer();
|
||||
result.append('{');
|
||||
incr();
|
||||
result.append(newline());
|
||||
final StringBuffer formattedMap = new StringBuffer();
|
||||
final List<String> listOfKeys = Arrays.asList(map.keySet().toArray(new String[] {}));
|
||||
Collections.sort(listOfKeys);
|
||||
for (final Object key : listOfKeys) {
|
||||
if (formattedMap.length() > 0) {
|
||||
formattedMap.append(',');
|
||||
formattedMap.append(newline());
|
||||
}
|
||||
formattedMap.append(key.toString());
|
||||
formattedMap.append(':');
|
||||
formattedMap.append(format(map.get(key)));
|
||||
}
|
||||
result.append(formattedMap.toString());
|
||||
decr();
|
||||
result.append(newline());
|
||||
result.append('}');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public String formatString(final String str) {
|
||||
return "'" + str + "'";
|
||||
}
|
||||
|
||||
public String formatList(final List<?> list) {
|
||||
return formatArr(list.toArray());
|
||||
}
|
||||
|
||||
public String formatArr(final Object[] arr) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append('[');
|
||||
incr();
|
||||
result.append(newline());
|
||||
StringBuffer formattedList = new StringBuffer();
|
||||
for (int idx = 0; idx < arr.length; idx ++) {
|
||||
if (formattedList.length() > 0) {
|
||||
formattedList.append(',');
|
||||
formattedList.append(newline());
|
||||
}
|
||||
formattedList.append(format(arr[idx]));
|
||||
}
|
||||
result.append(formattedList.toString());
|
||||
decr();
|
||||
if (formattedList.length() > 0) {
|
||||
result.append(newline());
|
||||
}
|
||||
result.append(']');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private void incr() {
|
||||
indent += 3;
|
||||
}
|
||||
|
||||
private void decr() {
|
||||
if (indent > 3) {
|
||||
indent -= 3;
|
||||
}
|
||||
}
|
||||
|
||||
private String newline() {
|
||||
int ind = indent;
|
||||
if (ind > 52) {
|
||||
ind = 52;
|
||||
}
|
||||
return "\n ".substring(0, indent);
|
||||
}
|
||||
|
||||
}
|
85
cli/src/main/resources/js/functions.js
Normal file
85
cli/src/main/resources/js/functions.js
Normal file
@ -0,0 +1,85 @@
|
||||
importClass(java.util.ArrayList);
|
||||
importClass(java.util.HashMap);
|
||||
|
||||
function hsaParseParam(val) {
|
||||
if (val instanceof java.util.List) {
|
||||
return val;
|
||||
}
|
||||
if (val instanceof java.util.Map) {
|
||||
return val;
|
||||
}
|
||||
if (typeof val === 'object' && val.constructor === Array) {
|
||||
return hsaParseParamArray(val);
|
||||
}
|
||||
if (typeof val === 'object') {
|
||||
return hsaParseParamObject(val);
|
||||
}
|
||||
}
|
||||
|
||||
function hsaParseParamArray(o) {
|
||||
var lst = new ArrayList();
|
||||
var val = '';
|
||||
for (var idx=0; idx < o.length; idx++) {
|
||||
val = o[idx];
|
||||
if (typeof val === 'object' && val.constructor === Array) {
|
||||
val = hsaParseParamArray(val);
|
||||
}
|
||||
else if (typeof val === 'object') {
|
||||
val = hsaParseParamObject(val);
|
||||
};
|
||||
lst.add(val);
|
||||
};
|
||||
return lst;
|
||||
}
|
||||
|
||||
function hsaParseParamObject(o) {
|
||||
var hsh = new HashMap();
|
||||
for (var key in o) {
|
||||
var val = o[key];
|
||||
if (typeof val === 'object' && val.constructor === Array) {
|
||||
val = hsaParseParamArray(val);
|
||||
}
|
||||
else if (typeof val === 'object') {
|
||||
val = hsaParseParamObject(val);
|
||||
};
|
||||
hsh.put(key, val);
|
||||
};
|
||||
return hsh;
|
||||
}
|
||||
|
||||
function hsaToNativeJSObject(val) {
|
||||
if (val instanceof java.util.List) {
|
||||
var res = [];
|
||||
for (var i = 0; i < val.size(); i++) {
|
||||
res[i] = hsaToNativeJSObject(val.get(i));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (val instanceof java.util.Map) {
|
||||
var res = {};
|
||||
var iter = val.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
var key = iter.next();
|
||||
res[key] = hsaToNativeJSObject(val.get(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function hsaModuleCall(mod, fct, json) {
|
||||
var params = new ArrayList();
|
||||
params.add(casgrantingticket.getRunAs());
|
||||
params.add(casgrantingticket.getTicket());
|
||||
if (typeof json === "undefined") {
|
||||
json = {where:{}, set:{}};
|
||||
}
|
||||
if (fct == "update" || fct == "add") {
|
||||
params.add(hsaParseParamObject(json["set"]));
|
||||
}
|
||||
if (fct == "update" || fct == "delete" || fct == "search") {
|
||||
params.add(hsaParseParamObject(json["where"]));
|
||||
}
|
||||
xmlrpcLastResult = xmlrpcclient.execute(mod + "." + fct, params);
|
||||
return hsaToNativeJSObject(xmlrpcLastResult);
|
||||
}
|
13
common/.gitignore
vendored
Normal file
13
common/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
661
common/LICENSE.txt
Normal file
661
common/LICENSE.txt
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
37
common/pom.xml
Normal file
37
common/pom.xml
Normal file
@ -0,0 +1,37 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin Common</name>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
62
common/src/main/java/de/hsadmin/common/config/Config.java
Normal file
62
common/src/main/java/de/hsadmin/common/config/Config.java
Normal file
@ -0,0 +1,62 @@
|
||||
package de.hsadmin.common.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
|
||||
public class Config {
|
||||
|
||||
public static final String CAS_VALIDATE_URL = "cas.validate.url";
|
||||
public static final String CAS_SERVICE_URL = "cas.service.url";
|
||||
public static final String PAC_HOSTMASTER_ACCOUNTS = "accountprefix.hostmaster";
|
||||
public static final String PAC_CUSTOMER_ACCOUNTS = "accountprefix.customer";
|
||||
public static final String PACKET_DOMAINS_POSTFIX = "domainpostfix.pacdomain";
|
||||
public static final String TICKETVALIDATOR_CLASS = "ticketvalidator.class";
|
||||
|
||||
private static Config instance;
|
||||
|
||||
private final Properties props;
|
||||
|
||||
private Config() throws TechnicalException {
|
||||
props = new Properties();
|
||||
File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
|
||||
if (!file.canRead()) {
|
||||
file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/hsadmin/hsadmin.properties");
|
||||
}
|
||||
if (file.canRead()) {
|
||||
try {
|
||||
props.load(new FileReader(file));
|
||||
} catch (IOException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Config getInstance() throws TechnicalException {
|
||||
if (instance == null) {
|
||||
instance = new Config();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getProperty(final String propertyName) {
|
||||
return props.getProperty(propertyName);
|
||||
}
|
||||
|
||||
public String getProperty(final String propertyName, final String defaultValue) {
|
||||
return props.getProperty(propertyName, defaultValue).trim();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package de.hsadmin.common.error;
|
||||
|
||||
public class TechnicalException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public TechnicalException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public TechnicalException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
54
common/src/main/java/de/hsadmin/common/error/UserError.java
Normal file
54
common/src/main/java/de/hsadmin/common/error/UserError.java
Normal file
@ -0,0 +1,54 @@
|
||||
package de.hsadmin.common.error;
|
||||
|
||||
public class UserError {
|
||||
|
||||
public static final String MSG_REQUIRED_FIELD = "MSG_REQUIRED_FIELD";
|
||||
public static final String MSG_NO_FIELD_WRITEACCESS = "MSG_NO_FIELD_WRITEACCESS";
|
||||
public static final String MSG_FIELD_NOT_SEARCHABLE = "MSG_FIELD_NOT_SEARCHABLE";
|
||||
public static final String MSG_NOT_IMPLEMENTED = "MSG_NOT_IMPLEMENTED";
|
||||
public static final String MSG_FIELD_DOESNOT_EXIST = "MSG_FIELD_DOESNOT_EXIST";
|
||||
public static final String MSG_FORBIDDEN_RUNAS = "MSG_FORBIDDEN_RUNAS";
|
||||
public static final String MSG_INVALID_TICKET = "MSG_INVALID_TICKET";
|
||||
public static final String MSG_MISSING_AUTHORIZATION = "MSG_MISSING_AUTHORIZATION";
|
||||
public static final String MSG_INVALID_DATEFORMAT = "MSG_INVALID_DATEFORMAT";
|
||||
public static final String MSG_FIELD_REQUIRES_MINLENGTH = "MSG_FIELD_REQUIRES_MINLENGTH";
|
||||
public static final String MSG_FIELD_EXCEEDS_MAXLENGTH = "MSG_FIELD_EXCEEDS_MAXLENGTH";
|
||||
public static final String MSG_FIELD_DOESNOT_MATCH_REGEXP = "MSG_FIELD_DOESNOT_MATCH_REGEXP";
|
||||
public static final String MSG_UNKNOWN_KEY = "MSG_UNKNOWN_KEY";
|
||||
public static final String MSG_INT_VALUE_EXPECTED = "MSG_INT_VALUE_EXPECTED";
|
||||
public static final String MSG_PAC_NOT_CANCELLED = "MSG_PAC_NOT_CANCELLED";
|
||||
public static final String MSG_PAC_CANCEL_DATE_IN_FUTURE = "MSG_PAC_CANCEL_DATE_IN_FUTURE";
|
||||
public static final String MSG_CUSTOMER_HAS_PACS = "MSG_CUSTOMER_HAS_PACS";
|
||||
public static final String MSG_CUSTOMER_IS_MEMBER = "MSG_CUSTOMER_IS_MEMBER";
|
||||
public static final String MSG_CUSTOMER_DELETE_DEADLINE_NOT_EXPIRED = "MSG_CUSTOMER_DELETE_DEADLINE_NOT_EXPIRED";
|
||||
public static final String MSG_ENTITY_EXISTS = "MSG_ENTITY_EXISTS";
|
||||
public static final String MSG_BOOLEAN_VALUE_EXPECTED = "MSG_BOOLEAN_VALUE_EXPECTED";
|
||||
public static final String MSG_DATE_VALUE_EXPECTED = "MSG_DATE_VALUE_EXPECTED";
|
||||
public static final String MSG_STRING_VALUE_EXPECTED = "MSG_STRING_VALUE_EXPECTED";
|
||||
public static final String MSG_HASHMAP_VALUE_EXPECTED = "MSG_HASHMAP_VALUE_EXPECTED";
|
||||
public static final String MSG_FIELD_DOESNOT_VALIDATE = "MSG_FIELD_DOESNOT_VALIDATE";
|
||||
|
||||
private final String message;
|
||||
private final String[] parameters;
|
||||
|
||||
public UserError(String msgKey, String... params) {
|
||||
this.message = msgKey;
|
||||
this.parameters = params;
|
||||
}
|
||||
|
||||
public String getLocalizedMessage() {
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(message);
|
||||
stringBuilder.append(": ");
|
||||
for (String p : parameters) {
|
||||
stringBuilder.append(p);
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
return stringBuilder.substring(0, stringBuilder.length() - 2);
|
||||
}
|
||||
|
||||
public String getMessageKey() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package de.hsadmin.common.error;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class UserErrorList {
|
||||
|
||||
private final List<UserError> errors;
|
||||
|
||||
public UserErrorList() {
|
||||
errors = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String buildMessage() {
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
final String lineSeparator = System.getProperty("line.separator");
|
||||
for (UserError err : errors) {
|
||||
stringBuilder.append(err.getLocalizedMessage());
|
||||
stringBuilder.append(lineSeparator);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public void add(String messageId, String... params) {
|
||||
errors.add(new UserError(messageId, params));
|
||||
}
|
||||
|
||||
public void raiseException() throws UserException {
|
||||
if (!errors.isEmpty()) {
|
||||
throw new UserException(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<UserError> errors() {
|
||||
return errors.iterator();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package de.hsadmin.common.error;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UserException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final List<UserError> errors;
|
||||
|
||||
public UserException(final Exception e) {
|
||||
super(e);
|
||||
errors = new ArrayList<>();
|
||||
}
|
||||
|
||||
public UserException(final UserErrorList errorList) {
|
||||
super(errorList.buildMessage());
|
||||
errors = new ArrayList<>();
|
||||
final Iterator<UserError> iterator = errorList.errors();
|
||||
while (iterator.hasNext()) {
|
||||
UserError err = iterator.next();
|
||||
errors.add(err);
|
||||
}
|
||||
}
|
||||
|
||||
public UserException(final UserError userError) {
|
||||
super(userError.getLocalizedMessage());
|
||||
errors = new ArrayList<>();
|
||||
errors.add(userError);
|
||||
}
|
||||
|
||||
public boolean hasError(final String errorMessageKey) {
|
||||
boolean listContainsError = false;
|
||||
for (UserError err : errors) {
|
||||
if (err.getMessageKey().equals(errorMessageKey)) {
|
||||
listContainsError = true;
|
||||
}
|
||||
}
|
||||
return listContainsError;
|
||||
}
|
||||
|
||||
}
|
42
common/src/main/java/de/hsadmin/common/util/DateUtil.java
Normal file
42
common/src/main/java/de/hsadmin/common/util/DateUtil.java
Normal file
@ -0,0 +1,42 @@
|
||||
package de.hsadmin.common.util;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateUtil {
|
||||
|
||||
final static public DateFormat DEFAULT_DATEFORMAT = new SimpleDateFormat("dd.MM.yy");
|
||||
|
||||
private final Calendar instance;
|
||||
|
||||
private DateUtil() {
|
||||
instance = Calendar.getInstance();
|
||||
setTimeToNull(instance);
|
||||
}
|
||||
|
||||
public static DateUtil getInstance(final Date dateValue) {
|
||||
final DateUtil dateUtil = new DateUtil();
|
||||
dateUtil.setDate(dateValue);
|
||||
return dateUtil;
|
||||
}
|
||||
|
||||
public void setDate(final Date dateValue) {
|
||||
instance.setTime(dateValue);
|
||||
setTimeToNull(instance);
|
||||
}
|
||||
|
||||
public Date yearsLater(final int years) {
|
||||
instance.add(Calendar.YEAR, years);
|
||||
return instance.getTime();
|
||||
}
|
||||
|
||||
private void setTimeToNull(final Calendar calendar) {
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package de.hsadmin.common.util;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public class ReflectionUtil {
|
||||
|
||||
public static boolean hasProperty(final Class<?> clasz, final String propertyName) throws UserException {
|
||||
try {
|
||||
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, clasz);
|
||||
return propertyDescriptor.getReadMethod() != null;
|
||||
} catch (IllegalArgumentException | IntrospectionException e) {
|
||||
throw new UserException(new UserError(UserError.MSG_FIELD_DOESNOT_EXIST, propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public static Annotation getAnnotation(final Class<?> clasz, final String propertyName, Class<? extends Annotation> annotationClass) throws TechnicalException {
|
||||
try {
|
||||
final Field field = clasz.getDeclaredField(propertyName);
|
||||
if (field != null) {
|
||||
return field.getAnnotation(annotationClass);
|
||||
}
|
||||
return null;
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object invokeGetter(final Object anObject, final String propertyName) throws TechnicalException {
|
||||
try {
|
||||
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||
return propertyDescriptor.getReadMethod().invoke(anObject);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void invokeSetter(final Object anObject, final String propertyName, final Object value) throws TechnicalException {
|
||||
try {
|
||||
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||
propertyDescriptor.getWriteMethod().invoke(anObject, value);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object newInstance(final Object anObject, String propertyName) throws TechnicalException {
|
||||
try {
|
||||
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||
final Object newInstance = propertyDescriptor.getReadMethod().getReturnType().newInstance();
|
||||
invokeSetter(anObject, propertyName, newInstance);
|
||||
return newInstance;
|
||||
} catch (InstantiationException | IllegalAccessException | IntrospectionException | TechnicalException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
13
framework/.gitignore
vendored
Normal file
13
framework/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
661
framework/LICENSE.txt
Normal file
661
framework/LICENSE.txt
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
70
framework/pom.xml
Normal file
70
framework/pom.xml
Normal file
@ -0,0 +1,70 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>framework</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin Framework</name>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>authorization</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-server</artifactId>
|
||||
<version>3.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
25
framework/src/main/java/de/hsadmin/module/Module.java
Normal file
25
framework/src/main/java/de/hsadmin/module/Module.java
Normal file
@ -0,0 +1,25 @@
|
||||
package de.hsadmin.module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
|
||||
public interface Module<VO extends ValueObject> {
|
||||
|
||||
public VO create(RequestContext requestContext, VO prototype)
|
||||
throws UserException, TechnicalException;
|
||||
|
||||
public List<VO> read(RequestContext requestContext, VO criteria)
|
||||
throws UserException, TechnicalException;
|
||||
|
||||
public List<VO> update(RequestContext requestContext, VO criteria, VO prototype)
|
||||
throws UserException, TechnicalException;
|
||||
|
||||
public void delete(RequestContext requestContext, VO criteria)
|
||||
throws UserException, TechnicalException;
|
||||
|
||||
public VO buildVO() throws TechnicalException;
|
||||
|
||||
}
|
23
framework/src/main/java/de/hsadmin/module/ValueObject.java
Normal file
23
framework/src/main/java/de/hsadmin/module/ValueObject.java
Normal file
@ -0,0 +1,23 @@
|
||||
package de.hsadmin.module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.module.property.Property;
|
||||
|
||||
public interface ValueObject {
|
||||
|
||||
public List<Property<?>> properties() throws UserException, TechnicalException;
|
||||
|
||||
public Property<?> get(String propertyName) throws UserException;
|
||||
|
||||
public boolean hasProperty(String propertyName) throws UserException;
|
||||
|
||||
public void copyPropertiesToPersistentObject(Object persistentObject)
|
||||
throws UserException, TechnicalException;
|
||||
|
||||
public void copyPropertiesFromPersistentObject(Object persistentObject)
|
||||
throws UserException, TechnicalException;
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package de.hsadmin.module.impl;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
import de.hsadmin.login.ScopePolicy;
|
||||
import de.hsadmin.module.Module;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.property.Property;
|
||||
import de.hsadmin.module.property.StringProperty;
|
||||
|
||||
public abstract class AbstractModule<VO extends ValueObject> implements Module<VO> {
|
||||
|
||||
private final ValidationDelegate<VO> validationDelegate;
|
||||
|
||||
public AbstractModule() {
|
||||
validationDelegate = new ValidationDelegate<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VO create(final RequestContext requestContext, final VO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
checkScopePolicy(requestContext, "create");
|
||||
validationDelegate.checkPrototypeIsCreateable(prototype);
|
||||
return prototype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VO> read(final RequestContext requestContext, final VO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
checkScopePolicy(requestContext, "read", criteria);
|
||||
validationDelegate.checkCriteriaIsSearchable(criteria);
|
||||
final List<VO> readValueObjects = new ArrayList<>();
|
||||
return readValueObjects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VO> update(final RequestContext requestContext, final VO criteria,
|
||||
final VO prototype) throws UserException, TechnicalException {
|
||||
checkScopePolicy(requestContext, "update", criteria);
|
||||
validationDelegate.checkCriteriaIsSearchable(criteria);
|
||||
validationDelegate.checkPrototypeIsUpdateable(prototype);
|
||||
final List<VO> valueObjectsForUpdate = read(requestContext, criteria);
|
||||
return valueObjectsForUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(final RequestContext requestContext, final VO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
checkScopePolicy(requestContext, "delete", criteria);
|
||||
validationDelegate.checkCriteriaIsSearchable(criteria);
|
||||
}
|
||||
|
||||
protected void checkScopePolicy(final RequestContext requestContext, final String methodName,
|
||||
final VO criteria) throws TechnicalException, UserException {
|
||||
final String scopeAttribute = checkScopePolicy(requestContext, methodName);
|
||||
if (scopeAttribute != null && !scopeAttribute.isEmpty()) {
|
||||
final Property<?> property = criteria.get(scopeAttribute);
|
||||
if (property.valueIsNullOrEmpty() && property instanceof StringProperty) {
|
||||
((StringProperty) property).setValue(requestContext.getLoginUser());
|
||||
} else {
|
||||
if (!requestContext.getLoginUser().equals(property.getValue())) {
|
||||
throw new UserException(new UserError(UserError.MSG_MISSING_AUTHORIZATION, methodName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String checkScopePolicy(final RequestContext requestContext, final String methodName)
|
||||
throws TechnicalException, UserException {
|
||||
try {
|
||||
Method method = null;
|
||||
final Class<?> valueClass = buildVO().getClass();
|
||||
if ("update".equals(methodName)) {
|
||||
method = getClass().getMethod(methodName, RequestContext.class, valueClass, valueClass);
|
||||
} else {
|
||||
method = getClass().getMethod(methodName, RequestContext.class, valueClass);
|
||||
}
|
||||
if (method == null) {
|
||||
throw new UserException(new UserError(UserError.MSG_MISSING_AUTHORIZATION, methodName));
|
||||
}
|
||||
final RequiredScope annotation = method.getAnnotation(RequiredScope.class);
|
||||
if (annotation == null) {
|
||||
throw new UserException(new UserError(UserError.MSG_MISSING_AUTHORIZATION, methodName));
|
||||
}
|
||||
final ScopePolicy[] scopePolicies = annotation.value();
|
||||
for (ScopePolicy policy : scopePolicies) {
|
||||
if (policy.value() == requestContext.getLoginRole() || policy.value() == Role.ANY) {
|
||||
return policy.property();
|
||||
}
|
||||
}
|
||||
throw new UserException(new UserError(UserError.MSG_MISSING_AUTHORIZATION, methodName));
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package de.hsadmin.module.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.property.Property;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.SearchPolicy;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
|
||||
public abstract class AbstractProperty<T> implements Property<T> {
|
||||
|
||||
private final ValueObject owningVO;
|
||||
private final String name;
|
||||
private final ReadWritePolicy policy;
|
||||
private final SearchPolicy search;
|
||||
private final boolean required;
|
||||
|
||||
private PersistentObjectMapper<T> persistentObjectMapper;
|
||||
private ParameterMapMapper<T> parameterMapMapper;
|
||||
|
||||
public AbstractProperty(
|
||||
final ValueObject owner,
|
||||
final String propertyName,
|
||||
final ReadWritePolicy readWritePolicy,
|
||||
final SearchPolicy searchPolicy,
|
||||
final boolean required) {
|
||||
this.owningVO = owner;
|
||||
this.name = propertyName;
|
||||
this.policy = readWritePolicy;
|
||||
this.search = searchPolicy;
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
protected PersistentObjectMapper<T> getPersistentObjectMapper() {
|
||||
return persistentObjectMapper;
|
||||
}
|
||||
|
||||
protected ParameterMapMapper<T> getParameterMapMapper() {
|
||||
return parameterMapMapper;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setPersistentObjectMapper(final PersistentObjectMapper<?> mapper) {
|
||||
persistentObjectMapper = (PersistentObjectMapper<T>) mapper;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setParameterMapMapper(ParameterMapMapper<?> mapper) {
|
||||
parameterMapMapper = (ParameterMapMapper<T>) mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadWritePolicy access() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchPolicy search() {
|
||||
return search;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean required() {
|
||||
return required;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<? extends Property<T>> getPropertyType() {
|
||||
return (Class<? extends Property<T>>) getClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T getValue() throws TechnicalException {
|
||||
return (T) ReflectionUtil.invokeGetter(owningVO, getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) throws TechnicalException {
|
||||
ReflectionUtil.invokeSetter(owningVO, getName(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valueIsNullOrEmpty() {
|
||||
try {
|
||||
return getValue() == null;
|
||||
} catch (TechnicalException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return "Property " + name + ": " + getValue();
|
||||
} catch (TechnicalException e) {
|
||||
return "Property " + name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueFromPersistentObject(Object persistentObject) throws TechnicalException, UserException {
|
||||
setValue(getPersistentObjectMapper().readValueFromPersistentObject(persistentObject, getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueToPersistentObject(Object persistentObject) throws TechnicalException, UserException {
|
||||
T newValue = getValue();
|
||||
if (newValue != null) {
|
||||
getPersistentObjectMapper().writeValueToPersistentObject(persistentObject, getName(), newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueToParameterMap(Map<String, Object> rpcParameter)
|
||||
throws TechnicalException, UserException {
|
||||
getParameterMapMapper().writeValueToParameterMap(rpcParameter, getName(), getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueFromParameterMap(Map<String, Object> rpcParameter) throws TechnicalException, UserException {
|
||||
setValue(getParameterMapMapper().readValueFromParameterMap(rpcParameter, getName()));
|
||||
}
|
||||
|
||||
}
|
168
framework/src/main/java/de/hsadmin/module/impl/AbstractVO.java
Normal file
168
framework/src/main/java/de/hsadmin/module/impl/AbstractVO.java
Normal file
@ -0,0 +1,168 @@
|
||||
package de.hsadmin.module.impl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.property.ContainsElements;
|
||||
import de.hsadmin.module.property.ElementsType;
|
||||
import de.hsadmin.module.property.Property;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.Required;
|
||||
import de.hsadmin.module.property.Search;
|
||||
import de.hsadmin.module.property.SearchPolicy;
|
||||
import de.hsadmin.module.property.mapping.Mapping;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.ReferredPropertyPath;
|
||||
|
||||
public abstract class AbstractVO implements ValueObject {
|
||||
|
||||
private final Map<String, Property<?>> propertiesMap;
|
||||
|
||||
public AbstractVO() throws TechnicalException {
|
||||
propertiesMap = new HashMap<>();
|
||||
final Field[] fields = getClass().getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
if (isPropertyField(f)) {
|
||||
initializeProperty(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Property<?>> properties() throws UserException, TechnicalException {
|
||||
final List<Property<?>> result = new ArrayList<>();
|
||||
try {
|
||||
final Field[] fields = getClass().getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
if (isPropertyField(f)) {
|
||||
result.add(get(f.getName()));
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property<?> get(final String propertyName) throws UserException {
|
||||
assert propertyName != null && propertyName.length() > 0;
|
||||
return propertiesMap.get(propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProperty(final String propertyName) throws UserException {
|
||||
assert propertyName != null && propertyName.length() > 0;
|
||||
return ReflectionUtil.hasProperty(getClass(), propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyPropertiesToPersistentObject(final Object persistentObject) throws UserException, TechnicalException {
|
||||
assert persistentObject != null;
|
||||
final List<Property<?>> properties = properties();
|
||||
for (Property<?> p : properties) {
|
||||
p.copyValueToPersistentObject(persistentObject);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyPropertiesFromPersistentObject(final Object persistentObject) throws UserException, TechnicalException {
|
||||
assert persistentObject != null;
|
||||
final List<Property<?>> properties = properties();
|
||||
for (Property<?> p : properties) {
|
||||
p.copyValueFromPersistentObject(persistentObject);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPropertyField(final Field f) {
|
||||
ReadWrite annotation = f.getAnnotation(ReadWrite.class);
|
||||
return annotation != null;
|
||||
}
|
||||
|
||||
private void initializeProperty(final Field f) throws TechnicalException {
|
||||
try {
|
||||
String simplePropertyClassName = f.getType().getSimpleName();
|
||||
if ("int".equals(simplePropertyClassName)) {
|
||||
simplePropertyClassName = "Integer";
|
||||
}
|
||||
if ("boolean".equals(simplePropertyClassName)) {
|
||||
simplePropertyClassName = "Boolean";
|
||||
}
|
||||
final Class<?> type = Class.forName("de.hsadmin.module.property." + simplePropertyClassName + "Property");
|
||||
final Constructor<?> constructor = type.getConstructor(ValueObject.class, String.class, ReadWritePolicy.class, SearchPolicy.class, boolean.class);
|
||||
final Property<?> newInstance = (Property<?>) constructor.newInstance(this, f.getName(), getReadWritePolicy(f), getSearchPolicy(f), isRequired(f));
|
||||
set(f.getName(), newInstance);
|
||||
if (ContainsElements.class.isAssignableFrom(type)) {
|
||||
ContainsElements container = (ContainsElements) newInstance;
|
||||
container.setElementsType(getElementsType(f));
|
||||
}
|
||||
Mapping mapping = f.getAnnotation(Mapping.class);
|
||||
if (mapping != null && newInstance instanceof AbstractProperty<?>) {
|
||||
AbstractProperty<?> prop = (AbstractProperty<?>) newInstance;
|
||||
PersistentObjectMapper<?> persistentObjectMapper = mapping.boMapping().newInstance();
|
||||
ParameterMapMapper<?> parameterMapMapper = mapping.rpcMapping().newInstance();
|
||||
prop.setParameterMapMapper(parameterMapMapper);
|
||||
prop.setPersistentObjectMapper(persistentObjectMapper);
|
||||
if (persistentObjectMapper instanceof ReferredPropertyPath) {
|
||||
((ReferredPropertyPath) persistentObjectMapper).setPropertyPath(mapping.boMappingPath());;
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException
|
||||
| NoSuchMethodException | SecurityException | UserException | ClassNotFoundException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void set(final String propertyName, final Property<?> propertyInstance) throws UserException {
|
||||
assert propertyName != null && propertyName.length() > 0;
|
||||
assert propertyInstance != null;
|
||||
propertiesMap.put(propertyName, propertyInstance);
|
||||
}
|
||||
|
||||
private SearchPolicy getSearchPolicy(final Field f) {
|
||||
final Search search = f.getAnnotation(Search.class);
|
||||
SearchPolicy searchPolicy = SearchPolicy.NONE;
|
||||
if (search != null) {
|
||||
searchPolicy = search.value();
|
||||
}
|
||||
return searchPolicy;
|
||||
}
|
||||
|
||||
private Class<? extends ValueObject> getElementsType(final Field f) throws TechnicalException {
|
||||
final ElementsType annotation = f.getAnnotation(ElementsType.class);
|
||||
if (annotation != null) {
|
||||
return annotation.value();
|
||||
}
|
||||
throw new TechnicalException("annotation ElementsType required");
|
||||
}
|
||||
|
||||
private boolean isRequired(final Field f) {
|
||||
final Required requiredAnn = f.getAnnotation(Required.class);
|
||||
boolean required = false;
|
||||
if (requiredAnn != null) {
|
||||
required = requiredAnn.value();
|
||||
}
|
||||
return required;
|
||||
}
|
||||
|
||||
private ReadWritePolicy getReadWritePolicy(final Field f) {
|
||||
final ReadWrite readWrite = f.getAnnotation(ReadWrite.class);
|
||||
ReadWritePolicy rwPolicy = ReadWritePolicy.NONE;
|
||||
if (readWrite != null) {
|
||||
rwPolicy = readWrite.value();
|
||||
}
|
||||
return rwPolicy;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package de.hsadmin.module.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.ValidatorFactory;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserErrorList;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.property.Property;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.SearchPolicy;
|
||||
|
||||
public class ValidationDelegate<T extends ValueObject> {
|
||||
|
||||
private static final ValidatorFactory vf;
|
||||
|
||||
static {
|
||||
vf = Validation.buildDefaultValidatorFactory();
|
||||
}
|
||||
|
||||
public void checkPrototypeIsCreateable(final T prototype) throws UserException, TechnicalException {
|
||||
final UserErrorList errors = new UserErrorList();
|
||||
final List<Property<?>> properties = prototype.properties();
|
||||
for (Property<?> p : properties) {
|
||||
if (p.valueIsNullOrEmpty()) {
|
||||
if (p.required()) {
|
||||
errors.add(UserError.MSG_REQUIRED_FIELD, p.getName());
|
||||
}
|
||||
} else {
|
||||
final ReadWritePolicy rwPolicy = p.access();
|
||||
if (rwPolicy != ReadWritePolicy.READWRITE && rwPolicy != ReadWritePolicy.WRITEONCE) {
|
||||
errors.add(UserError.MSG_NO_FIELD_WRITEACCESS, p.getName());
|
||||
} else {
|
||||
Set<ConstraintViolation<T>> validateResults = vf.getValidator().validate(prototype);
|
||||
if (!validateResults.isEmpty()) {
|
||||
for (ConstraintViolation<T> violation: validateResults) {
|
||||
errors.add(UserError.MSG_FIELD_DOESNOT_VALIDATE, violation.getMessage(), violation.getPropertyPath().toString(), violation.getInvalidValue().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
errors.raiseException();
|
||||
}
|
||||
|
||||
public void checkPrototypeIsUpdateable(final T prototype) throws UserException, TechnicalException {
|
||||
final List<Property<?>> properties = prototype.properties();
|
||||
final UserErrorList errors = new UserErrorList();
|
||||
for (Property<?> p : properties) {
|
||||
final ReadWritePolicy rwPolicy = p.access();
|
||||
if (!p.valueIsNullOrEmpty()) {
|
||||
if (rwPolicy != ReadWritePolicy.READWRITE) {
|
||||
errors.add(UserError.MSG_NO_FIELD_WRITEACCESS, p.getName());
|
||||
} else {
|
||||
Set<ConstraintViolation<T>> validateResults = vf.getValidator().validate(prototype);
|
||||
if (!validateResults.isEmpty()) {
|
||||
for (ConstraintViolation<T> violation: validateResults) {
|
||||
errors.add(UserError.MSG_FIELD_DOESNOT_VALIDATE, violation.getMessage(), violation.getPropertyPath().toString(), violation.getInvalidValue().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
errors.raiseException();
|
||||
}
|
||||
|
||||
public void checkCriteriaIsSearchable(final T criteria) throws UserException, TechnicalException {
|
||||
final UserErrorList errors = new UserErrorList();
|
||||
final List<Property<?>> properties = criteria.properties();
|
||||
for (Property<?> p : properties) {
|
||||
final SearchPolicy searchPolicy = p.search();
|
||||
if (!p.valueIsNullOrEmpty() && searchPolicy != SearchPolicy.COMPARE && searchPolicy != SearchPolicy.EQUALS && searchPolicy != SearchPolicy.LIKE) {
|
||||
errors.add(UserError.MSG_FIELD_NOT_SEARCHABLE, p.getName());
|
||||
}
|
||||
}
|
||||
errors.raiseException();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
import de.hsadmin.module.property.mapping.DefaultBooleanParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultBooleanPersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
|
||||
public class BooleanProperty extends AbstractProperty<Boolean> implements Property<Boolean> {
|
||||
|
||||
private static final PersistentObjectMapper<Boolean> defaultPersistentObjectMapper;
|
||||
private static final ParameterMapMapper<Boolean> defaultParameterMapMapper;
|
||||
|
||||
static {
|
||||
defaultPersistentObjectMapper = new DefaultBooleanPersistentObjectMapper();
|
||||
defaultParameterMapMapper = new DefaultBooleanParameterMapMapper();
|
||||
}
|
||||
|
||||
public BooleanProperty(final ValueObject ownerVO, final String propertyName, final ReadWritePolicy readWritePolicy, final SearchPolicy searchPolicy, final boolean required) {
|
||||
super(ownerVO, propertyName, readWritePolicy, searchPolicy, required);
|
||||
setParameterMapMapper(defaultParameterMapMapper);
|
||||
setPersistentObjectMapper(defaultPersistentObjectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return Boolean.class;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import de.hsadmin.module.ValueObject;
|
||||
|
||||
public interface ContainsElements {
|
||||
|
||||
public Class<? extends ValueObject> getElementsType();
|
||||
|
||||
public void setElementsType(Class<? extends ValueObject> elementsType);
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
import de.hsadmin.module.property.mapping.DefaultDateParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultDatePersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
|
||||
public class DateProperty extends AbstractProperty<Date> implements Property<Date> {
|
||||
|
||||
private static final PersistentObjectMapper<Date> defaultPersistentObjectMapper;
|
||||
private static final ParameterMapMapper<Date> defaultParameterMapMapper;
|
||||
|
||||
static {
|
||||
defaultPersistentObjectMapper = new DefaultDatePersistentObjectMapper();
|
||||
defaultParameterMapMapper = new DefaultDateParameterMapMapper();
|
||||
}
|
||||
|
||||
public DateProperty(final ValueObject ownerVO, final String propertyName, final ReadWritePolicy readWritePolicy, final SearchPolicy searchPolicy, final boolean required) {
|
||||
super(ownerVO, propertyName, readWritePolicy, searchPolicy, required);
|
||||
setPersistentObjectMapper(defaultPersistentObjectMapper);
|
||||
setParameterMapMapper(defaultParameterMapMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return Date.class;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Display {
|
||||
|
||||
int sequence() default 9999;
|
||||
DisplayPolicy visible() default DisplayPolicy.ALWAYS;
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
public enum DisplayPolicy {
|
||||
|
||||
ALWAYS, OPTIONAL, NEVER
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import de.hsadmin.module.ValueObject;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ElementsType {
|
||||
|
||||
Class<? extends ValueObject> value();
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
import de.hsadmin.module.property.mapping.DefaultIntegerParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultIntegerPersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
|
||||
public class IntegerProperty extends AbstractProperty<Integer> implements Property<Integer> {
|
||||
|
||||
private static final PersistentObjectMapper<Integer> defaultPersistentObjectMapper;
|
||||
private static final ParameterMapMapper<Integer> defaultParameterMapMapper;
|
||||
|
||||
static {
|
||||
defaultPersistentObjectMapper = new DefaultIntegerPersistentObjectMapper();
|
||||
defaultParameterMapMapper = new DefaultIntegerParameterMapMapper();
|
||||
}
|
||||
|
||||
public IntegerProperty(final ValueObject ownerVO, final String propertyName, final ReadWritePolicy readWritePolicy, final SearchPolicy searchPolicy, final boolean required) {
|
||||
super(ownerVO, propertyName, readWritePolicy, searchPolicy, required);
|
||||
setPersistentObjectMapper(defaultPersistentObjectMapper);
|
||||
setParameterMapMapper(defaultParameterMapMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
import de.hsadmin.module.property.mapping.DefaultListParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultListPersistentObjectMapper;
|
||||
|
||||
public class ListProperty<VO extends ValueObject> extends AbstractProperty<List<ValueObject>> implements Property<List<ValueObject>>, ContainsElements {
|
||||
|
||||
private Class<? extends ValueObject> elementsType;
|
||||
|
||||
public ListProperty(final ValueObject ownerVO, final String propertyName, final ReadWritePolicy readWritePolicy, final SearchPolicy searchPolicy, final boolean required) {
|
||||
super(ownerVO, propertyName, readWritePolicy, searchPolicy, required);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return List.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valueIsNullOrEmpty() {
|
||||
List<ValueObject> val = null;
|
||||
try {
|
||||
val = getValue();
|
||||
} catch (TechnicalException e) {
|
||||
return true;
|
||||
}
|
||||
return val == null || val.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ValueObject> getElementsType() {
|
||||
return elementsType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementsType(final Class<? extends ValueObject> elementsType) {
|
||||
this.elementsType = elementsType;
|
||||
setPersistentObjectMapper(new DefaultListPersistentObjectMapper<ValueObject>(elementsType));
|
||||
setParameterMapMapper(new DefaultListParameterMapMapper<VO>(elementsType));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public interface Property<T> {
|
||||
|
||||
public String getName();
|
||||
|
||||
public T getValue() throws TechnicalException;
|
||||
|
||||
public void setValue(T value) throws TechnicalException;
|
||||
|
||||
public Class<? extends Property<?>> getPropertyType();
|
||||
|
||||
public Class<?> getValueType();
|
||||
|
||||
public ReadWritePolicy access();
|
||||
|
||||
public SearchPolicy search();
|
||||
|
||||
public boolean required();
|
||||
|
||||
public boolean valueIsNullOrEmpty();
|
||||
|
||||
public void copyValueFromPersistentObject(final Object persistentObject) throws TechnicalException, UserException;
|
||||
|
||||
public void copyValueToPersistentObject(final Object persistentObject) throws TechnicalException, UserException;
|
||||
|
||||
public void copyValueToParameterMap(final Map<String, Object> rpcParameter) throws TechnicalException, UserException;
|
||||
|
||||
public void copyValueFromParameterMap(final Map<String, Object> rpcParameter) throws TechnicalException, UserException;
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ReadWrite {
|
||||
|
||||
ReadWritePolicy value();
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
public enum ReadWritePolicy {
|
||||
READ, READWRITE, WRITEONCE, NONE
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Required {
|
||||
|
||||
boolean value();
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Search {
|
||||
|
||||
SearchPolicy value();
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
public enum SearchPolicy {
|
||||
EQUALS, LIKE, COMPARE, NONE
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
import de.hsadmin.module.property.mapping.DefaultStringParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultStringPersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
|
||||
public class StringProperty extends AbstractProperty<String> implements Property<String> {
|
||||
|
||||
private static final PersistentObjectMapper<String> defaultPersistentObjectMapper;
|
||||
private static final ParameterMapMapper<String> defaultParameterMapMapper;
|
||||
|
||||
static {
|
||||
defaultPersistentObjectMapper = new DefaultStringPersistentObjectMapper();
|
||||
defaultParameterMapMapper = new DefaultStringParameterMapMapper();
|
||||
}
|
||||
|
||||
public StringProperty(final ValueObject ownerVO, final String propertyName, final ReadWritePolicy readWritePolicy, final SearchPolicy searchPolicy, final boolean required) {
|
||||
super(ownerVO, propertyName, readWritePolicy, searchPolicy, required);
|
||||
setParameterMapMapper(defaultParameterMapMapper);
|
||||
setPersistentObjectMapper(defaultPersistentObjectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valueIsNullOrEmpty() {
|
||||
String val = null;
|
||||
try {
|
||||
val = getValue();
|
||||
} catch (TechnicalException e) {
|
||||
return true;
|
||||
}
|
||||
return val == null || val.isEmpty();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class StringSet {
|
||||
|
||||
private Set<String> stringSet;
|
||||
|
||||
public StringSet() {
|
||||
stringSet = null;
|
||||
}
|
||||
|
||||
public String[] getStrings() {
|
||||
if (stringSet == null) {
|
||||
return null;
|
||||
}
|
||||
return stringSet.toArray(new String[] { } );
|
||||
}
|
||||
|
||||
public void setStrings(final String[] changedStringSet) {
|
||||
stringSet = null;
|
||||
if (changedStringSet != null) {
|
||||
stringSet = new TreeSet<String>();
|
||||
stringSet.addAll(Arrays.asList(changedStringSet));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
import de.hsadmin.module.property.mapping.DefaultStringSetParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultStringSetPersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
|
||||
public class StringSetProperty extends AbstractProperty<StringSet> {
|
||||
|
||||
private static final PersistentObjectMapper<StringSet> defaultPersistentObjectMapper;
|
||||
private static final ParameterMapMapper<StringSet> defaultParameterMapMapper;
|
||||
|
||||
static {
|
||||
defaultPersistentObjectMapper = new DefaultStringSetPersistentObjectMapper();
|
||||
defaultParameterMapMapper = new DefaultStringSetParameterMapMapper();
|
||||
}
|
||||
|
||||
private final ValueObject owningVO;
|
||||
|
||||
public StringSetProperty(final ValueObject owner, final String propertyName,
|
||||
final ReadWritePolicy readWritePolicy, final SearchPolicy searchPolicy,
|
||||
final boolean required) {
|
||||
super(owner, propertyName, readWritePolicy, searchPolicy, required);
|
||||
owningVO = owner;
|
||||
setParameterMapMapper(defaultParameterMapMapper);
|
||||
setPersistentObjectMapper(defaultPersistentObjectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return StringSet.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final StringSet value) throws TechnicalException {
|
||||
ReflectionUtil.invokeSetter(owningVO, getName(), value.getStrings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringSet getValue() throws TechnicalException {
|
||||
final StringSet value = new StringSet();
|
||||
final Object stringList = ReflectionUtil.invokeGetter(owningVO, getName());
|
||||
if (stringList instanceof String[]) {
|
||||
value.setStrings(((String[]) stringList));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valueIsNullOrEmpty() {
|
||||
try {
|
||||
final Object stringList = ReflectionUtil.invokeGetter(owningVO, getName());
|
||||
if (stringList == null) {
|
||||
return true;
|
||||
}
|
||||
if (stringList instanceof String[]) {
|
||||
return ((String[]) stringList).length == 0;
|
||||
}
|
||||
return false;
|
||||
} catch (TechnicalException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueFromPersistentObject(Object persistentObject)
|
||||
throws TechnicalException, UserException {
|
||||
// TODO Auto-generated method stub
|
||||
super.copyValueFromPersistentObject(persistentObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueToPersistentObject(Object persistentObject)
|
||||
throws TechnicalException, UserException {
|
||||
// TODO Auto-generated method stub
|
||||
super.copyValueToPersistentObject(persistentObject);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public class DefaultBooleanParameterMapMapper implements
|
||||
ParameterMapMapper<Boolean> {
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, final Boolean value)
|
||||
throws TechnicalException, UserException {
|
||||
if (value != null) {
|
||||
rpcParameter.put(propertyName, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName) throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
String stringValue = (String) value;
|
||||
if ("true".equalsIgnoreCase(stringValue)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if ("false".equalsIgnoreCase(stringValue)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
throw new UserException(new UserError(UserError.MSG_BOOLEAN_VALUE_EXPECTED, propertyName, stringValue));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
|
||||
public class DefaultBooleanPersistentObjectMapper implements PersistentObjectMapper<Boolean> {
|
||||
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject, final String propertyName, final Boolean value) throws TechnicalException {
|
||||
ReflectionUtil.invokeSetter(persistentObject, propertyName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean readValueFromPersistentObject(final Object persistentObject, final String propertyName) throws TechnicalException {
|
||||
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
if (object instanceof Boolean) {
|
||||
return (Boolean) object;
|
||||
} else {
|
||||
if (object instanceof String) {
|
||||
return Boolean.parseBoolean((String) object);
|
||||
} else {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.DateUtil;
|
||||
|
||||
public class DefaultDateParameterMapMapper implements ParameterMapMapper<Date> {
|
||||
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, final Date value)
|
||||
throws TechnicalException, UserException {
|
||||
if (value != null) {
|
||||
rpcParameter.put(propertyName, DateUtil.DEFAULT_DATEFORMAT.format(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName) throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof Date) {
|
||||
return (Date) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
try {
|
||||
return DateUtil.DEFAULT_DATEFORMAT.parse((String) value);
|
||||
} catch (ParseException e) {
|
||||
throw new UserException(new UserError(UserError.MSG_INVALID_DATEFORMAT, propertyName, (String) value));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.util.DateUtil;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
|
||||
public class DefaultDatePersistentObjectMapper implements PersistentObjectMapper<Date> {
|
||||
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject, final String propertyName, final Date value) throws TechnicalException {
|
||||
ReflectionUtil.invokeSetter(persistentObject, propertyName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date readValueFromPersistentObject(final Object persistentObject, final String propertyName) throws TechnicalException {
|
||||
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
if (object instanceof Date) {
|
||||
return (Date) object;
|
||||
} else {
|
||||
if (object instanceof String) {
|
||||
try {
|
||||
return DateUtil.DEFAULT_DATEFORMAT.parse((String) object);
|
||||
} catch (ParseException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public class DefaultIntegerParameterMapMapper implements ParameterMapMapper<Integer> {
|
||||
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, Integer value)
|
||||
throws TechnicalException, UserException {
|
||||
if (value != null) {
|
||||
rpcParameter.put(propertyName, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName)
|
||||
throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
try {
|
||||
return Integer.parseInt((String) value);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new UserException(new UserError(UserError.MSG_INT_VALUE_EXPECTED, propertyName, (String) value));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
|
||||
public class DefaultIntegerPersistentObjectMapper implements PersistentObjectMapper<Integer> {
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject, final String propertyName, final Integer value) throws TechnicalException {
|
||||
ReflectionUtil.invokeSetter(persistentObject, propertyName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer readValueFromPersistentObject(final Object persistentObject, final String propertyName) throws TechnicalException {
|
||||
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
if (object instanceof Integer) {
|
||||
return (Integer) object;
|
||||
} else {
|
||||
if (object instanceof String) {
|
||||
try {
|
||||
return Integer.parseInt((String) object);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.property.Property;
|
||||
|
||||
public class DefaultListParameterMapMapper<VO extends ValueObject> implements ParameterMapMapper<List<VO>> {
|
||||
|
||||
final private Class<? extends ValueObject> elementsType;
|
||||
|
||||
public DefaultListParameterMapMapper(Class<? extends ValueObject> elementsType) {
|
||||
this.elementsType = elementsType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueToParameterMap(Map<String, Object> rpcParameter, String propertyName, List<VO> value)
|
||||
throws TechnicalException, UserException {
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
for (Object o : value) {
|
||||
assert o instanceof ValueObject;
|
||||
ValueObject vo = (ValueObject) o;
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
List<Property<?>> properties = vo.properties();
|
||||
for (Property<?> p : properties) {
|
||||
p.copyValueToParameterMap(map);
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
rpcParameter.put(propertyName, list);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<VO> readValueFromParameterMap(Map<String, Object> rpcParameter, String propertyName)
|
||||
throws TechnicalException, UserException {
|
||||
final List<VO> value = new ArrayList<>();
|
||||
final Object list = rpcParameter.get(propertyName);
|
||||
try {
|
||||
if (list instanceof Object[]) {
|
||||
for (Object obj : (Object[])list) {
|
||||
if (obj instanceof Map<?, ?>) {
|
||||
final VO vo = (VO) elementsType.newInstance();
|
||||
final Map<?, ?> map = (Map<?, ?>) obj;
|
||||
for (Object key : map.keySet()) {
|
||||
if (key instanceof String) {
|
||||
final Property<?> property = vo.get((String)key);
|
||||
property.copyValueFromParameterMap((Map<String, Object>) map);
|
||||
}
|
||||
}
|
||||
value.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
|
||||
public class DefaultListPersistentObjectMapper<VO extends ValueObject> implements PersistentObjectMapper<List<VO>> {
|
||||
|
||||
private final Class<? extends VO> elementsType;
|
||||
|
||||
public DefaultListPersistentObjectMapper(Class<? extends VO> elementsType) {
|
||||
this.elementsType = elementsType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueToPersistentObject(Object persistentObject, String propertyName, List<VO> value) throws TechnicalException, UserException {
|
||||
final List<VO> valueFromPersistentObject = readValueFromPersistentObject(persistentObject, propertyName);
|
||||
valueFromPersistentObject.clear();
|
||||
// for (final VO elem : value) {
|
||||
// valueFromPersistentObject.add(elem);
|
||||
// elem.
|
||||
// }
|
||||
// ReflectionUtil.invokeSetter(persistentObject, propertyName, ???;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VO> readValueFromPersistentObject(Object persistentObject, String propertyName) throws TechnicalException, UserException {
|
||||
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
if (object instanceof Collection<?>) {
|
||||
final List<VO> valueList = new ArrayList<>();
|
||||
final Collection<?> coll = (Collection<?>) object;
|
||||
for (Object o : coll) {
|
||||
try {
|
||||
final VO newInstance = elementsType.newInstance();
|
||||
newInstance.copyPropertiesFromPersistentObject(o);
|
||||
valueList.add(newInstance);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
return valueList;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public class DefaultStringParameterMapMapper implements ParameterMapMapper<String> {
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, final String value)
|
||||
throws TechnicalException, UserException {
|
||||
if (value != null) {
|
||||
rpcParameter.put(propertyName, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName) throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
|
||||
public class DefaultStringPersistentObjectMapper implements
|
||||
PersistentObjectMapper<String> {
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject, final String propertyName, final String value) throws TechnicalException {
|
||||
ReflectionUtil.invokeSetter(persistentObject, propertyName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readValueFromPersistentObject(final Object persistentObject, final String propertyName) throws TechnicalException {
|
||||
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
if (object instanceof String) {
|
||||
return (String) object;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.module.property.StringSet;
|
||||
|
||||
public class DefaultStringSetParameterMapMapper implements
|
||||
ParameterMapMapper<StringSet> {
|
||||
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, final StringSet value) throws TechnicalException,
|
||||
UserException {
|
||||
final String[] strings = value.getStrings();
|
||||
if (strings != null) {
|
||||
rpcParameter.put(propertyName, Arrays.asList(strings));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringSet readValueFromParameterMap(
|
||||
final Map<String, Object> rpcParameter, final String propertyName)
|
||||
throws TechnicalException, UserException {
|
||||
final Object rpcParam = rpcParameter.get(propertyName);
|
||||
final StringSet value = new StringSet();
|
||||
String[] strings = new String[] { };
|
||||
if (rpcParam instanceof Object[]) {
|
||||
strings = new String[((Object[]) rpcParam).length];
|
||||
int idx = 0;
|
||||
for (final Object o : (Object[]) rpcParam) {
|
||||
strings[idx] = (String) o;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
value.setStrings(strings);
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
import de.hsadmin.module.property.StringSet;
|
||||
|
||||
public class DefaultStringSetPersistentObjectMapper implements
|
||||
PersistentObjectMapper<StringSet> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public StringSet readValueFromPersistentObject(final Object persistentObject,
|
||||
final String propertyName) throws TechnicalException, UserException {
|
||||
final Object strings = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
final StringSet value = new StringSet();
|
||||
if (strings instanceof Collection<?>) {
|
||||
value.setStrings(((Collection<String>) strings).toArray(new String[] { }));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject,
|
||||
final String propertyName, final StringSet value) throws TechnicalException {
|
||||
final String[] strings = value.getStrings();
|
||||
if (strings != null) {
|
||||
ReflectionUtil.invokeSetter(persistentObject, propertyName, Arrays.asList(strings));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Mapping {
|
||||
|
||||
Class<? extends PersistentObjectMapper<?>> boMapping();
|
||||
Class<? extends ParameterMapMapper<?>> rpcMapping();
|
||||
String boMappingPath() default "";
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public interface ParameterMapMapper<T> {
|
||||
|
||||
void writeValueToParameterMap(Map<String, Object> rpcParameter, String propertyName, T value) throws TechnicalException, UserException;
|
||||
|
||||
T readValueFromParameterMap(Map<String, Object> rpcParameter, String propertyName) throws TechnicalException, UserException;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public interface PersistentObjectMapper<T> {
|
||||
|
||||
T readValueFromPersistentObject(Object persistentObject, String propertyName) throws TechnicalException, UserException;
|
||||
|
||||
void writeValueToPersistentObject(Object persistentObject, String propertyName, T value) throws TechnicalException, UserException;
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
public interface ReferredPropertyPath {
|
||||
|
||||
void setPropertyPath(String path);
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
|
||||
public class ReferredStringPersistentObjectMapper implements PersistentObjectMapper<String>, ReferredPropertyPath {
|
||||
|
||||
private String propertyPath;
|
||||
|
||||
@Override
|
||||
public void setPropertyPath(final String path) {
|
||||
propertyPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readValueFromPersistentObject(final Object persistentObject, final String propertyName) throws TechnicalException, UserException {
|
||||
String path = propertyName;
|
||||
if (propertyPath != null) {
|
||||
path = propertyPath;
|
||||
}
|
||||
final String[] strings = path.split("\\.");
|
||||
Object pathObject = persistentObject;
|
||||
for (int idx = 0; idx < strings.length && pathObject != null; idx++) {
|
||||
final String propName = strings[idx];
|
||||
pathObject = ReflectionUtil.invokeGetter(pathObject, propName);
|
||||
}
|
||||
return pathObject instanceof String ? (String) pathObject : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject,
|
||||
final String propertyName, final String value) throws TechnicalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package de.hsadmin.module.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Join;
|
||||
import javax.persistence.criteria.ParameterExpression;
|
||||
import javax.persistence.criteria.Path;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.property.Property;
|
||||
import de.hsadmin.module.property.mapping.Mapping;
|
||||
|
||||
public class QueryBuilder<BO> {
|
||||
|
||||
final private EntityManager em;
|
||||
final private Class<BO> clasz;
|
||||
|
||||
private QueryBuilder(final EntityManager em, final Class<BO> clasz) {
|
||||
this.em = em;
|
||||
this.clasz = clasz;
|
||||
}
|
||||
|
||||
public static <BO> QueryBuilder<BO> newBuilder(final EntityManager em, final Class<BO> clasz) {
|
||||
return new QueryBuilder<BO>(em, clasz);
|
||||
}
|
||||
|
||||
public List<BO> getResultList(final ValueObject criteria)
|
||||
throws UserException, TechnicalException {
|
||||
final CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
|
||||
final CriteriaQuery<BO> criteriaQuery = criteriaBuilder.createQuery(clasz);
|
||||
final Root<BO> root = criteriaQuery.from(clasz);
|
||||
final List<Predicate> predicates = new ArrayList<>();
|
||||
for (Property<?> p : criteria.properties()) {
|
||||
if (!p.valueIsNullOrEmpty()) {
|
||||
Mapping mappingAnnotation = (Mapping) ReflectionUtil.getAnnotation(criteria.getClass(), p.getName(), Mapping.class);
|
||||
final String mapping = mappingAnnotation != null ? mappingAnnotation.boMappingPath() : p.getName();
|
||||
int pos = 0;
|
||||
Join<Object, Object> join = null;
|
||||
while (mapping.substring(pos).contains(".")) {
|
||||
join = join == null ?
|
||||
root.join(mapping.substring(0, mapping.indexOf('.', pos)))
|
||||
: join.join(mapping.substring(0, mapping.indexOf('.', pos)));
|
||||
pos = mapping.indexOf('.') + 1;
|
||||
}
|
||||
final Path<Object> path = join == null ?
|
||||
root.get(mapping.substring(pos))
|
||||
: join.get(mapping.substring(pos));
|
||||
final ParameterExpression<?> parameter = criteriaBuilder.parameter(p.getValueType(), p.getName());
|
||||
predicates.add(criteriaBuilder.equal(path, parameter));
|
||||
}
|
||||
}
|
||||
if (predicates.size() > 0) {
|
||||
criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()]));
|
||||
}
|
||||
final TypedQuery<BO> query = em.createQuery(criteriaQuery);
|
||||
for (Property<?> p : criteria.properties()) {
|
||||
if (!p.valueIsNullOrEmpty()) {
|
||||
query.setParameter(p.getName(), p.getValue());
|
||||
}
|
||||
}
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.service.property;
|
||||
|
||||
import de.hsadmin.xmlrpc.AbstractRemote;
|
||||
import de.hsadmin.xmlrpc.Remote;
|
||||
|
||||
|
||||
public class PropertyRemote extends AbstractRemote<PropertyVO> implements Remote {
|
||||
|
||||
@Override
|
||||
protected String getModuleLookup() {
|
||||
return "PropertyServiceLocal";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package de.hsadmin.service.property;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
import de.hsadmin.login.ScopePolicy;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractModule;
|
||||
import de.hsadmin.module.property.Display;
|
||||
import de.hsadmin.module.property.DisplayPolicy;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.Search;
|
||||
import de.hsadmin.module.property.SearchPolicy;
|
||||
import de.hsadmin.xmlrpc.AbstractRemote;
|
||||
|
||||
@Stateless
|
||||
public class PropertyService extends AbstractModule<PropertyVO> implements PropertyServiceLocal {
|
||||
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
public PropertyVO buildVO() throws TechnicalException {
|
||||
return new PropertyVO();
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.NONE)})
|
||||
public PropertyVO create(final RequestContext requestContext, final PropertyVO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.ANY)})
|
||||
public List<PropertyVO> read(final RequestContext requestContext, final PropertyVO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
final List<PropertyVO> emptyList = super.read(requestContext, criteria);
|
||||
final Properties remoteServicesProperties = new Properties();
|
||||
final String requestedModuleName = criteria.getModule();
|
||||
try {
|
||||
remoteServicesProperties.load(getClass().getClassLoader().getResourceAsStream("org/apache/xmlrpc/webserver/XmlRpcServlet.properties"));
|
||||
final Enumeration<?> propertyNames = remoteServicesProperties.propertyNames();
|
||||
while (propertyNames.hasMoreElements()) {
|
||||
final String properyName = (String) propertyNames.nextElement();
|
||||
if (requestedModuleName != null && !requestedModuleName.equals(properyName)) {
|
||||
continue;
|
||||
}
|
||||
final Class<?> serviceRemoteClass = Class.forName(remoteServicesProperties.getProperty(properyName));
|
||||
@SuppressWarnings("unchecked")
|
||||
final AbstractRemote<ValueObject> serviceRemote = (AbstractRemote<ValueObject>) serviceRemoteClass.newInstance();
|
||||
final ValueObject valueObject = serviceRemote.createValueObject();
|
||||
final Field[] declaredFields = valueObject.getClass().getDeclaredFields();
|
||||
for (Field f : declaredFields) {
|
||||
final PropertyVO vo = buildVO();
|
||||
vo.setModule(properyName);
|
||||
vo.setName(f.getName());
|
||||
final ReadWrite readWrite = f.getAnnotation(ReadWrite.class);
|
||||
if (readWrite == null) {
|
||||
vo.setReadwriteable(ReadWritePolicy.NONE.name().toLowerCase());
|
||||
} else {
|
||||
vo.setReadwriteable(readWrite.value().name().toLowerCase());
|
||||
}
|
||||
final Search search = f.getAnnotation(Search.class);
|
||||
if (search == null) {
|
||||
vo.setSearchable(SearchPolicy.NONE.name().toLowerCase());
|
||||
} else {
|
||||
vo.setSearchable(search.value().name().toLowerCase());
|
||||
}
|
||||
final Display sequence = f.getAnnotation(Display.class);
|
||||
if (sequence == null) {
|
||||
vo.setDisplaySequence(Integer.valueOf(9999));
|
||||
vo.setDisplayVisible(DisplayPolicy.ALWAYS.name().toLowerCase());;
|
||||
} else {
|
||||
vo.setDisplaySequence(sequence.sequence());
|
||||
vo.setDisplayVisible(sequence.visible().name().toLowerCase());;
|
||||
}
|
||||
final Pattern pattern = f.getAnnotation(Pattern.class);
|
||||
if (pattern == null) {
|
||||
vo.setValidationRegexp("[a-zA-Z0-9\\_\\-\\.\\,\\ ]*");
|
||||
} else {
|
||||
vo.setValidationRegexp(pattern.regexp());
|
||||
}
|
||||
final Size size = f.getAnnotation(Size.class);
|
||||
if (size == null) {
|
||||
vo.setMinLength(Integer.valueOf(0));
|
||||
vo.setMaxLength(Integer.valueOf(999));
|
||||
} else {
|
||||
vo.setMinLength(size.min());
|
||||
vo.setMaxLength(size.max());
|
||||
}
|
||||
vo.setType(printableTypeName(valueObject.get(f.getName()).getValueType()));
|
||||
emptyList.add(vo);
|
||||
}
|
||||
}
|
||||
} catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
return emptyList;
|
||||
}
|
||||
|
||||
private String printableTypeName(Class<?> type) {
|
||||
String name = type.getName().toLowerCase();
|
||||
if (name.indexOf('.') >= 0) {
|
||||
final int lastDot = name.lastIndexOf('.');
|
||||
name = name.substring(lastDot + 1);
|
||||
}
|
||||
if ("arraylist".equals(name)) {
|
||||
name = "array";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.NONE)})
|
||||
public List<PropertyVO> update(RequestContext requestContext, PropertyVO criteria, PropertyVO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.NONE)})
|
||||
public void delete(RequestContext requestContext, PropertyVO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.hsadmin.service.property;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import de.hsadmin.module.Module;
|
||||
|
||||
@Local
|
||||
public interface PropertyServiceLocal extends Module<PropertyVO>{
|
||||
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
package de.hsadmin.service.property;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractVO;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.Search;
|
||||
import de.hsadmin.module.property.SearchPolicy;
|
||||
import de.hsadmin.module.property.Display;
|
||||
|
||||
public class PropertyVO extends AbstractVO implements ValueObject {
|
||||
|
||||
@Display(sequence = 10)
|
||||
@Search(SearchPolicy.EQUALS)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String module;
|
||||
|
||||
@Display(sequence = 20)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String name;
|
||||
|
||||
@Display(sequence = 50)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String searchable;
|
||||
|
||||
@Display(sequence = 40)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String readwriteable;
|
||||
|
||||
@Display(sequence = 30)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String type;
|
||||
|
||||
@Display(sequence = 60)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private Integer displaySequence;
|
||||
|
||||
@Display(sequence = 70)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String displayVisible;
|
||||
|
||||
@Display(sequence = 80)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private Integer minLength;
|
||||
|
||||
@Display(sequence = 81)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private Integer maxLength;
|
||||
|
||||
@Display(sequence = 90)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String validationRegexp;
|
||||
|
||||
public PropertyVO() throws TechnicalException {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSearchable() {
|
||||
return searchable;
|
||||
}
|
||||
|
||||
public void setSearchable(String searchable) {
|
||||
this.searchable = searchable;
|
||||
}
|
||||
|
||||
public String getReadwriteable() {
|
||||
return readwriteable;
|
||||
}
|
||||
|
||||
public void setReadwriteable(String readwriteable) {
|
||||
this.readwriteable = readwriteable;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getDisplaySequence() {
|
||||
return displaySequence;
|
||||
}
|
||||
|
||||
public void setDisplaySequence(Integer sequence) {
|
||||
this.displaySequence = sequence;
|
||||
}
|
||||
|
||||
public String getDisplayVisible() {
|
||||
return displayVisible;
|
||||
}
|
||||
|
||||
public void setDisplayVisible(String displayVisible) {
|
||||
this.displayVisible = displayVisible;
|
||||
}
|
||||
|
||||
public Integer getMinLength() {
|
||||
return minLength;
|
||||
}
|
||||
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
public String getValidationRegexp() {
|
||||
return validationRegexp;
|
||||
}
|
||||
|
||||
public void setMinLength(Integer minLength) {
|
||||
this.minLength = minLength;
|
||||
}
|
||||
|
||||
public void setMaxLength(Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
public void setValidationRegexp(String validationRegexp) {
|
||||
this.validationRegexp = validationRegexp;
|
||||
}
|
||||
|
||||
}
|
179
framework/src/main/java/de/hsadmin/xmlrpc/AbstractRemote.java
Normal file
179
framework/src/main/java/de/hsadmin/xmlrpc/AbstractRemote.java
Normal file
@ -0,0 +1,179 @@
|
||||
package de.hsadmin.xmlrpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.EJBException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.persistence.EntityExistsException;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserErrorList;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.LoginServiceLocal;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.module.Module;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.property.Property;
|
||||
|
||||
public abstract class AbstractRemote<VO extends ValueObject> implements Remote {
|
||||
|
||||
final private LoginServiceLocal login;
|
||||
final private Module<VO> module;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public AbstractRemote() {
|
||||
final Properties props = new Properties();
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
|
||||
Context ctx = null;
|
||||
try {
|
||||
ctx = new InitialContext(props);
|
||||
login = (LoginServiceLocal) ctx.lookup("LoginServiceLocal");
|
||||
module = (Module<VO>) ctx.lookup(getModuleLookup());
|
||||
} catch (NamingException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (ctx != null) {
|
||||
try { ctx.close(); } catch (NamingException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> search(final String runAsUser, final String ticket,
|
||||
final Map<String, Object> whereParams) throws RemoteException {
|
||||
try {
|
||||
final RequestContext requestContext = login.createContext(ticket, runAsUser);
|
||||
final VO queryValue = module.buildVO();
|
||||
mapXmlRpc2VO(whereParams, queryValue);
|
||||
final List<VO> list = module.read(requestContext, queryValue);
|
||||
final List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (VO value : list) {
|
||||
final Map<String, Object> resultValue = new HashMap<>();
|
||||
mapVO2XmlRpc(value, resultValue);
|
||||
resultList.add(resultValue);
|
||||
}
|
||||
return resultList;
|
||||
} catch (UserException | TechnicalException | EJBException e) {
|
||||
if (e instanceof EJBException && e.getCause() != null) {
|
||||
analyzeEJBException(e.getCause());
|
||||
}
|
||||
throw new RemoteException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> add(final String runAsUser, final String ticket,
|
||||
final Map<String, Object> setParams) throws RemoteException {
|
||||
try {
|
||||
final RequestContext requestContext = login.createContext(ticket, runAsUser);
|
||||
final VO setValue = module.buildVO();
|
||||
mapXmlRpc2VO(setParams, setValue);
|
||||
final VO newValue = module.create(requestContext, setValue);
|
||||
final Map<String, Object> resultValue = new HashMap<>();
|
||||
mapVO2XmlRpc(newValue, resultValue);
|
||||
return resultValue;
|
||||
} catch (UserException | TechnicalException | EJBException e) {
|
||||
if (e instanceof EJBException && e.getCause() != null) {
|
||||
throw analyzeEJBException(e.getCause());
|
||||
}
|
||||
throw new RemoteException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> update(final String runAsUser, final String ticket,
|
||||
final Map<String, Object> setParams, final Map<String, Object> whereParams)
|
||||
throws RemoteException {
|
||||
try {
|
||||
final RequestContext requestContext = login.createContext(ticket, runAsUser);
|
||||
final VO queryValue = module.buildVO();
|
||||
mapXmlRpc2VO(whereParams, queryValue);
|
||||
final VO setValue = module.buildVO();
|
||||
mapXmlRpc2VO(setParams, setValue);
|
||||
final List<VO> list = module.update(requestContext, queryValue, setValue);
|
||||
final List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (VO value : list) {
|
||||
final Map<String, Object> resultValue = new HashMap<>();
|
||||
mapVO2XmlRpc(value, resultValue);
|
||||
resultList.add(resultValue);
|
||||
}
|
||||
return resultList;
|
||||
} catch (UserException | TechnicalException | EJBException e) {
|
||||
if (e instanceof EJBException && e.getCause() != null) {
|
||||
analyzeEJBException(e.getCause());
|
||||
}
|
||||
throw new RemoteException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(final String runAsUser, final String ticket,
|
||||
final Map<String, Object> whereParams) throws RemoteException {
|
||||
try {
|
||||
final RequestContext requestContext = login.createContext(ticket, runAsUser);
|
||||
final VO queryValue = module.buildVO();
|
||||
mapXmlRpc2VO(whereParams, queryValue);
|
||||
module.delete(requestContext, queryValue);
|
||||
} catch (UserException | TechnicalException | EJBException e) {
|
||||
if (e instanceof EJBException && e.getCause() != null) {
|
||||
throw analyzeEJBException(e.getCause());
|
||||
}
|
||||
throw new RemoteException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getModuleLookup();
|
||||
|
||||
public ValueObject createValueObject() throws TechnicalException {
|
||||
return module.buildVO();
|
||||
}
|
||||
|
||||
private RemoteException analyzeEJBException(final Throwable cause) {
|
||||
final TechnicalException analyzedException = new TechnicalException("EJBException: " + cause.getMessage());
|
||||
if (cause instanceof EntityExistsException) {
|
||||
return new RemoteException(new UserException(new UserError(UserError.MSG_ENTITY_EXISTS)));
|
||||
}
|
||||
if (cause instanceof PersistenceException) {
|
||||
final Throwable cause2 = ((PersistenceException)cause).getCause();
|
||||
if (cause2 instanceof EntityExistsException) {
|
||||
return new RemoteException(new UserException(new UserError(UserError.MSG_ENTITY_EXISTS)));
|
||||
}
|
||||
}
|
||||
return new RemoteException(analyzedException);
|
||||
}
|
||||
|
||||
private void mapVO2XmlRpc(final ValueObject valueObject, final Map<String, Object> resultValue)
|
||||
throws UserException, TechnicalException {
|
||||
final UserErrorList errors = new UserErrorList();
|
||||
final List<Property<?>> props = valueObject.properties();
|
||||
for (Property<?> p : props) {
|
||||
p.copyValueToParameterMap(resultValue);
|
||||
}
|
||||
errors.raiseException();
|
||||
}
|
||||
|
||||
private void mapXmlRpc2VO(final Map<String, Object> paramsMap,
|
||||
final VO valueObject) throws UserException, TechnicalException {
|
||||
final UserErrorList errors = new UserErrorList();
|
||||
final Set<String> keySet = paramsMap.keySet();
|
||||
for (String key : keySet) {
|
||||
if (valueObject.hasProperty(key)) {
|
||||
final Property<?> property = valueObject.get(key);
|
||||
property.copyValueFromParameterMap(paramsMap);
|
||||
} else {
|
||||
errors.add(UserError.MSG_FIELD_DOESNOT_EXIST, key);
|
||||
}
|
||||
}
|
||||
errors.raiseException();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package de.hsadmin.xmlrpc;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
import org.apache.xmlrpc.metadata.XmlRpcSystemImpl;
|
||||
import org.apache.xmlrpc.server.PropertyHandlerMapping;
|
||||
import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
|
||||
import org.apache.xmlrpc.webserver.XmlRpcServlet;
|
||||
|
||||
public class HSXmlRpcServlet extends XmlRpcServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected XmlRpcHandlerMapping newXmlRpcHandlerMapping()
|
||||
throws XmlRpcException {
|
||||
XmlRpcHandlerMapping handlerMapping = super.newXmlRpcHandlerMapping();
|
||||
XmlRpcSystemImpl.addSystemHandler((PropertyHandlerMapping) handlerMapping);
|
||||
return handlerMapping;
|
||||
}
|
||||
|
||||
}
|
34
framework/src/main/java/de/hsadmin/xmlrpc/Remote.java
Normal file
34
framework/src/main/java/de/hsadmin/xmlrpc/Remote.java
Normal file
@ -0,0 +1,34 @@
|
||||
package de.hsadmin.xmlrpc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface Remote {
|
||||
|
||||
public abstract List<Map<String, Object>> search(
|
||||
String runAsUser,
|
||||
String ticket,
|
||||
Map<String, Object> whereParams
|
||||
) throws RemoteException;
|
||||
|
||||
public abstract Map<String, Object> add(
|
||||
String runAsUser,
|
||||
String ticket,
|
||||
Map<String, Object> setParams
|
||||
) throws RemoteException;
|
||||
|
||||
public abstract void delete(
|
||||
String runAsUser,
|
||||
String ticket,
|
||||
Map<String, Object> whereParams
|
||||
) throws RemoteException;
|
||||
|
||||
public abstract List<Map<String, Object>> update(
|
||||
String runAsUser,
|
||||
String ticket,
|
||||
Map<String, Object> setParams,
|
||||
Map<String, Object> whereParams
|
||||
) throws RemoteException;
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package de.hsadmin.xmlrpc;
|
||||
|
||||
public class RemoteException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public RemoteException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
}
|
13
persistence/.gitignore
vendored
Normal file
13
persistence/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
222
persistence/database/hsdb-bootstrap.sql
Normal file
222
persistence/database/hsdb-bootstrap.sql
Normal file
@ -0,0 +1,222 @@
|
||||
--
|
||||
-- Table: basepacket
|
||||
--
|
||||
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
|
||||
VALUES ('PAC/DW', 'Dynamic-Web/Base', 300, true, 100);
|
||||
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
|
||||
VALUES ('PAC/SW', 'Static-Web/Base', 400, true, 200);
|
||||
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
|
||||
VALUES ('PAC/WEB', 'Web/Base', 100, true, 300);
|
||||
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
|
||||
VALUES ('SRV/MGD', 'Managed Server', 200, true, 400);
|
||||
|
||||
--
|
||||
-- Table: basecomponent
|
||||
--
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('MULTI', 'Accounts', 100, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('TRAFFIC', 'Monatliches Datenvolumen in GB', 200, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('QUOTA', 'Festplattenspeicherplatz in MB', 300, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('DAEMON', 'Nutzung eines eigenen Servers/Daemons', 400, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('MIRROR', 'Echtzeitspiegelung der Daten', 500, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('BACKUP', 'Nächtliches Backup', 600, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('DISK', 'Nächtliches Backup', 700, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('CPU', 'Nächtliches Backup', 800, true);
|
||||
|
||||
--
|
||||
-- Table: component
|
||||
--
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 1, 10, 1, 1, 1, false, 100 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='MULTI';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 1, 10, 1, 1, 1, false, 200 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='MULTI';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 1, 10, 1, 1, 1, false, 300 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='MULTI';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 128, 40960, 128, 128, 128, false, 101 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='QUOTA';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 512, 40960, 512, 512, 512, false, 201 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='QUOTA';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 512, 40960, 512, 512, 0, false, 301 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='QUOTA';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 2, 40960, 2, 2, 2, false, 102 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='TRAFFIC';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 4, 40960, 4, 4, 4, false, 202 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='TRAFFIC';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 5, 40960, 5, 5, 0, false, 302 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='TRAFFIC';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false, 103 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='DAEMON';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false, 303 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='DAEMON';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 104 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='MIRROR';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 204 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='MIRROR';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 304 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='MIRROR';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 105 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='BACKUP';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 205 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='BACKUP';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 305 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='BACKUP';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 25, 100, 25, 25, 0, false, 410 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='DISK';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 1, 16, 1, 1, 0, false, 420 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='CPU';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 10, 1000, 10, 10, 0, false, 430 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='TRAFFIC';
|
||||
|
||||
--
|
||||
-- Table: role
|
||||
--
|
||||
INSERT INTO role (role_name) VALUES ('billing');
|
||||
INSERT INTO role (role_name) VALUES ('operation');
|
||||
|
||||
--
|
||||
-- Table: business_partner
|
||||
--
|
||||
INSERT INTO business_partner (member_id, member_code, member_since, shares_signed, free, indicator_vat, exempt_vat)
|
||||
VALUES (10000, 'hsh00-hsh', current_date, 0, TRUE, 'NET', FALSE);
|
||||
|
||||
--
|
||||
-- table: contact
|
||||
--
|
||||
INSERT INTO contact (bp_id, salut, first_name, last_name, firma, email)
|
||||
SELECT bp_id, 'Herr', 'Sigi', 'Superb', 'Hosting Inc.', 'info@example.com' FROM business_partner WHERE member_id=10000;
|
||||
|
||||
--
|
||||
-- table: contactrole_ref
|
||||
--
|
||||
INSERT INTO contactrole_ref ( contact_id, role )
|
||||
SELECT contact_id, 'billing' FROM contact WHERE email='info@example.com';
|
||||
INSERT INTO contactrole_ref ( contact_id, role )
|
||||
SELECT contact_id, 'operation' FROM contact WHERE email='info@example.com';
|
||||
|
||||
--
|
||||
-- Table: inet_addr
|
||||
--
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.67', 'address 67');
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.72', 'address 72');
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.73', 'address 73');
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.74', 'address 74');
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.75', 'address 75');
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.76', 'address 76');
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.77', 'address 77');
|
||||
INSERT INTO inet_addr (inet_addr, description)
|
||||
VALUES (inet '176.9.242.78', 'address 78');
|
||||
|
||||
--
|
||||
-- Table: Hive
|
||||
--
|
||||
INSERT INTO hive (hive_name, inet_addr_id, description)
|
||||
SELECT 'h99', inet_addr_id, 'Test Hive h99' FROM inet_addr WHERE inet_addr = inet '176.9.242.67';
|
||||
|
||||
--
|
||||
-- table: packet
|
||||
--
|
||||
INSERT INTO packet (packet_name, bp_id, hive_id, created, cur_inet_addr_id, free, basepacket_id)
|
||||
SELECT 'hsh00', business_partner.bp_id, hive.hive_id, current_date, inet_addr.inet_addr_id, true, basepacket.basepacket_id
|
||||
FROM business_partner, hive, inet_addr, basepacket
|
||||
WHERE hive_name='h99' AND inet_addr = inet '176.9.242.72' AND member_id = 10000 AND basepacket.basepacket_code='PAC/DW';
|
||||
INSERT INTO packet (packet_name, bp_id, hive_id, created, cur_inet_addr_id, free, basepacket_id)
|
||||
SELECT 'hsh01', business_partner.bp_id, hive.hive_id, current_date, inet_addr.inet_addr_id, true, basepacket.basepacket_id
|
||||
FROM business_partner, hive, inet_addr, basepacket
|
||||
WHERE hive_name='h99' AND inet_addr = inet '176.9.242.73' AND member_id = 10000 AND basepacket.basepacket_code='PAC/DW';
|
||||
|
||||
--
|
||||
-- table: packet_component
|
||||
--
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 1, packet.packet_id, 2, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh00';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 2, packet.packet_id, 128, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh00';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 3, packet.packet_id, 1, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh00';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 4, packet.packet_id, 1, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh00';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 5, packet.packet_id, 1, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh00';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 1, packet.packet_id, 2, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh01';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 2, packet.packet_id, 128, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh01';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 3, packet.packet_id, 1, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh01';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 4, packet.packet_id, 1, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh01';
|
||||
INSERT INTO packet_component (basecomponent_id, packet_id, quantity, created)
|
||||
SELECT 5, packet.packet_id, 1, current_date FROM packet
|
||||
WHERE packet.packet_name = 'hsh01';
|
||||
|
||||
--
|
||||
-- table: unixuser
|
||||
--
|
||||
INSERT INTO unixuser (name, comment, shell, homedir, locked, packet_id, userid)
|
||||
SELECT 'hsh00', 'packet hsh00', '/bin/bash', '/home/pacs/hsh00', FALSE, packet_id, 10001 FROM packet
|
||||
WHERE packet_name='hsh00';
|
||||
INSERT INTO unixuser (name, comment, shell, homedir, locked, packet_id, userid)
|
||||
SELECT 'hsh01', 'packet hsh01', '/bin/bash', '/home/pacs/hsh01', FALSE, packet_id, 10002 FROM packet
|
||||
WHERE packet_name='hsh01';
|
||||
INSERT INTO unixuser (name, comment, shell, homedir, locked, packet_id, userid)
|
||||
SELECT 'hsh01-ad', 'hostmaster ad', '/bin/bash', '/home/pacs/hsh01/users/ad', FALSE, packet_id, 10003 FROM packet
|
||||
WHERE packet_name='hsh01';
|
||||
|
||||
--
|
||||
-- table: domain
|
||||
--
|
||||
INSERT INTO domain (domain_name, domain_since, domain_dns_master, domain_owner)
|
||||
SELECT 'hostsharing.net', current_date, 'dns.hostsharing.net', unixuser_id FROM unixuser
|
||||
WHERE unixuser.name='hsh00';
|
||||
|
||||
--
|
||||
-- table: domain_option
|
||||
--
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('backupmxforexternalmx');
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('greylisting');
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('htdocsfallback');
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('includes');
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('indexes');
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('multiviews');
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('php');
|
||||
|
||||
--
|
||||
-- table: price_list
|
||||
--
|
||||
INSERT INTO price_list VALUES (1, 'Default Price List');
|
||||
|
||||
--
|
||||
-- table: customer_price_list_mapping
|
||||
--
|
||||
INSERT INTO pricelist_ref (SELECT bp_id, 'Default Price List' FROM business_partner);
|
||||
|
615
persistence/database/hsdb-schema.sql
Normal file
615
persistence/database/hsdb-schema.sql
Normal file
@ -0,0 +1,615 @@
|
||||
CREATE SEQUENCE bank_account_bank_account_i_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE SEQUENCE bank_account_bank_account_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE basecomponent (
|
||||
basecomponent_id integer DEFAULT nextval(('"basecomponent_basecomponent_seq"'::text)::regclass) NOT NULL,
|
||||
basecomponent_code character varying(10) NOT NULL,
|
||||
description character varying(100) NOT NULL,
|
||||
sorting integer NOT NULL,
|
||||
valid boolean NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE basecomponent_basecomponent_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE basepacket (
|
||||
basepacket_id integer DEFAULT nextval(('"basepacket_basepacket_id_seq"'::text)::regclass) NOT NULL,
|
||||
basepacket_code character varying(10) NOT NULL,
|
||||
description character varying(100) NOT NULL,
|
||||
sorting integer NOT NULL,
|
||||
valid boolean NOT NULL,
|
||||
article_number integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE basepacket_basepacket_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE SEQUENCE billdata_billdata_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE business_partner (
|
||||
bp_id integer DEFAULT nextval(('"business_partner_bp_id_seq"'::text)::regclass) NOT NULL,
|
||||
member_id integer NOT NULL,
|
||||
member_code character varying(20) NOT NULL,
|
||||
member_since date,
|
||||
member_until date,
|
||||
member_role character varying(100),
|
||||
author_contract date,
|
||||
nondisc_contract date,
|
||||
shares_updated date,
|
||||
shares_signed integer NOT NULL,
|
||||
uid_vat character varying(20),
|
||||
free boolean DEFAULT false NOT NULL,
|
||||
indicator_vat character varying(20) DEFAULT 'GROSS'::character varying NOT NULL,
|
||||
exempt_vat boolean DEFAULT false NOT NULL,
|
||||
CONSTRAINT ckc_member_id_business CHECK (((member_id >= 10000) AND (member_id <= 99999))),
|
||||
CONSTRAINT ckc_shares_signed_business CHECK ((shares_signed >= 0)),
|
||||
CONSTRAINT ckt_business_partner CHECK ((((((member_since IS NULL) AND (member_until IS NULL)) OR ((member_since IS NOT NULL) AND (member_until IS NULL))) OR (((member_since IS NOT NULL) AND (member_until IS NOT NULL)) AND (member_since < member_until))) AND ((member_code)::text ~~ 'hsh00-%'::text)))
|
||||
);
|
||||
|
||||
CREATE SEQUENCE business_partner_bp_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE contact (
|
||||
contact_id integer DEFAULT nextval(('"contact_contact_id_seq"'::text)::regclass) NOT NULL,
|
||||
bp_id integer NOT NULL,
|
||||
salut character varying(30),
|
||||
first_name character varying(40) NOT NULL,
|
||||
last_name character varying(40) NOT NULL,
|
||||
title character varying(20),
|
||||
firma character varying(120),
|
||||
co character varying(50),
|
||||
street character varying(50),
|
||||
zipcode character varying(10),
|
||||
city character varying(40),
|
||||
country character varying(30),
|
||||
phone_private character varying(30),
|
||||
phone_office character varying(30),
|
||||
phone_mobile character varying(30),
|
||||
fax character varying(30),
|
||||
email character varying(100) NOT NULL,
|
||||
CONSTRAINT ckc_email_contact CHECK (((email)::text ~~ '%@%.%'::text))
|
||||
);
|
||||
|
||||
CREATE VIEW business_partner_ticket AS
|
||||
SELECT (business_partner.member_id)::character varying(20) AS member_id, "substring"((business_partner.member_code)::text, 7) AS member_code, contact.salut, contact.first_name, contact.last_name, contact.title, contact.firma, contact.co, contact.street, contact.zipcode, contact.city, contact.country, contact.phone_private, contact.phone_office, contact.phone_mobile, contact.fax, contact.email, ((COALESCE(to_char((business_partner.member_since)::timestamp with time zone, 'YYYY-DD-MM'::text), '-'::text) || ' / '::text) || COALESCE(to_char((business_partner.member_until)::timestamp with time zone, 'YYYY-DD-MM'::text), '-'::text)) AS comment, 1 AS valid FROM (business_partner LEFT JOIN contact ON ((contact.bp_id = business_partner.bp_id))) ORDER BY (business_partner.member_id)::character varying(20);
|
||||
|
||||
CREATE TABLE component (
|
||||
basepacket_id integer NOT NULL,
|
||||
basecomponent_id integer NOT NULL,
|
||||
min_quantity integer NOT NULL,
|
||||
max_quantity integer NOT NULL,
|
||||
default_quantity integer NOT NULL,
|
||||
increment_quantity integer NOT NULL,
|
||||
include_quantity integer NOT NULL,
|
||||
admin_only boolean NOT NULL,
|
||||
article_number integer NOT NULL,
|
||||
component_id integer DEFAULT nextval(('"component_id_seq"'::text)::regclass) NOT NULL,
|
||||
CONSTRAINT ckt_component CHECK ((((((((((0 <= min_quantity) AND (min_quantity <= default_quantity)) AND (default_quantity <= max_quantity)) AND (include_quantity <= default_quantity)) AND (0 <= include_quantity)) AND (mod(min_quantity, increment_quantity) = 0)) AND (mod(max_quantity, increment_quantity) = 0)) AND (mod(default_quantity, increment_quantity) = 0)) AND (mod(include_quantity, increment_quantity) = 0)))
|
||||
);
|
||||
|
||||
CREATE SEQUENCE component_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE SEQUENCE contact_contact_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE contactrole_ref (
|
||||
contact_id integer NOT NULL,
|
||||
role character varying(40) NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE database_database_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE database (
|
||||
database_id integer DEFAULT nextval('database_database_id_seq'::regclass) NOT NULL,
|
||||
engine character varying(12) NOT NULL,
|
||||
packet_id integer NOT NULL,
|
||||
name character varying(64) NOT NULL,
|
||||
owner character varying(24) NOT NULL,
|
||||
encoding character varying(12) NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE dbuser_dbuser_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE database_user (
|
||||
dbuser_id integer DEFAULT nextval('dbuser_dbuser_id_seq'::regclass) NOT NULL,
|
||||
engine character varying(12) NOT NULL,
|
||||
packet_id integer NOT NULL,
|
||||
name character varying(64) NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE domain_domain_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE domain (
|
||||
domain_name character varying(256) NOT NULL,
|
||||
domain_since date,
|
||||
domain_dns_master character varying(64),
|
||||
domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL,
|
||||
domain_owner integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE domain__domain_option (
|
||||
domain_option_id integer NOT NULL,
|
||||
domain_id integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE domain_option (
|
||||
domain_option_id integer DEFAULT nextval(('"domain_option_id_seq"'::text)::regclass) NOT NULL,
|
||||
domain_option_name character varying(50) NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE domain_option_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE SEQUENCE emailaddr_emailaddr_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE emailaddr (
|
||||
emailaddr_id integer DEFAULT nextval('emailaddr_emailaddr_id_seq'::regclass) NOT NULL,
|
||||
localpart character varying(64) NOT NULL,
|
||||
domain_id integer NOT NULL,
|
||||
target text,
|
||||
subdomain character varying(64)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE emailalias_emailalias_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE emailalias (
|
||||
emailalias_id integer DEFAULT nextval('emailalias_emailalias_id_seq'::regclass) NOT NULL,
|
||||
pac_id integer NOT NULL,
|
||||
target text NOT NULL,
|
||||
name character varying(96) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE hive (
|
||||
hive_id integer DEFAULT nextval(('"hive_hive_id_seq"'::text)::regclass) NOT NULL,
|
||||
hive_name character varying(3) NOT NULL,
|
||||
inet_addr_id integer NOT NULL,
|
||||
description character varying(100)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE hive_hive_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE inet_addr (
|
||||
inet_addr_id integer DEFAULT nextval(('"inet_addr_inet_addr_id_seq"'::text)::regclass) NOT NULL,
|
||||
inet_addr inet NOT NULL,
|
||||
description character varying(100),
|
||||
CONSTRAINT ckc_inet_addr_inet_add CHECK ((masklen(inet_addr) = 32))
|
||||
);
|
||||
|
||||
CREATE SEQUENCE inet_addr_inet_addr_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE SEQUENCE member_id_seq
|
||||
START WITH 10200
|
||||
INCREMENT BY 1
|
||||
MINVALUE 10200
|
||||
MAXVALUE 99999
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE packet (
|
||||
packet_id integer DEFAULT nextval(('"packet_packet_id_seq"'::text)::regclass) NOT NULL,
|
||||
packet_name character varying(5) NOT NULL,
|
||||
bp_id integer NOT NULL,
|
||||
hive_id integer NOT NULL,
|
||||
created date NOT NULL,
|
||||
cancelled date,
|
||||
cur_inet_addr_id integer,
|
||||
old_inet_addr_id integer,
|
||||
free boolean DEFAULT false NOT NULL,
|
||||
basepacket_id integer,
|
||||
CONSTRAINT ckt_packet CHECK (((cancelled IS NULL) OR (cancelled > created)))
|
||||
);
|
||||
|
||||
CREATE TABLE packet_component (
|
||||
basecomponent_id integer NOT NULL,
|
||||
packet_id integer NOT NULL,
|
||||
quantity integer NOT NULL,
|
||||
created date,
|
||||
cancelled date,
|
||||
packet_component_id integer DEFAULT nextval(('"packet_component_id_seq"'::text)::regclass) NOT NULL,
|
||||
CONSTRAINT ckt_packet_component CHECK (((cancelled IS NULL) OR (cancelled > created)))
|
||||
);
|
||||
|
||||
CREATE SEQUENCE packet_component_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE SEQUENCE packet_packet_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE price (
|
||||
id integer NOT NULL,
|
||||
article_number integer NOT NULL,
|
||||
price numeric(10,2) NOT NULL,
|
||||
vat numeric(4,2) NOT NULL,
|
||||
price_list integer
|
||||
);
|
||||
|
||||
CREATE SEQUENCE price_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE price_id_seq OWNED BY price.id;
|
||||
|
||||
CREATE TABLE price_list (
|
||||
id integer NOT NULL,
|
||||
name character varying(20)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE price_list_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE price_list_id_seq OWNED BY price_list.id;
|
||||
|
||||
CREATE TABLE pricelist_ref (
|
||||
bp_id integer NOT NULL,
|
||||
price_list character varying(40) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE queue (
|
||||
queue_entry_id integer DEFAULT nextval(('"queue_queue_entry_id_seq"'::text)::regclass) NOT NULL,
|
||||
user_id integer NOT NULL,
|
||||
started timestamp without time zone NOT NULL,
|
||||
finished timestamp without time zone,
|
||||
title character varying(192),
|
||||
details text,
|
||||
CONSTRAINT ckt_queue CHECK (((finished IS NULL) OR (finished >= started)))
|
||||
);
|
||||
|
||||
CREATE SEQUENCE queue_queue_entry_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE queue_task (
|
||||
task_id integer DEFAULT nextval(('"queue_task_id_seq"'::text)::regclass) NOT NULL,
|
||||
proc bytea,
|
||||
exception text,
|
||||
started timestamp without time zone NOT NULL,
|
||||
finished timestamp without time zone,
|
||||
title character varying(192),
|
||||
details text,
|
||||
user_id integer
|
||||
);
|
||||
|
||||
CREATE SEQUENCE queue_task_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE role (
|
||||
role_name character varying(40) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE sepa_mandat (
|
||||
sepa_mandat_id integer DEFAULT nextval(('"sepa_mandat_id_seq"'::text)::regclass) NOT NULL,
|
||||
bp_id integer NOT NULL,
|
||||
bank_customer character varying(50) NOT NULL,
|
||||
bank_name character varying(50),
|
||||
bank_iban character varying(40) NOT NULL,
|
||||
bank_bic character varying(40) NOT NULL,
|
||||
mandat_ref character varying(40) NOT NULL,
|
||||
mandat_signed date NOT NULL,
|
||||
mandat_since date NOT NULL,
|
||||
mandat_used date,
|
||||
mandat_until date,
|
||||
CONSTRAINT dateschk1 CHECK (((mandat_signed <= mandat_since) AND (mandat_since <= mandat_until))),
|
||||
CONSTRAINT dateschk2 CHECK ((((mandat_since <= mandat_until) AND (mandat_since <= mandat_used)) AND (mandat_used <= mandat_until)))
|
||||
);
|
||||
|
||||
CREATE SEQUENCE sepa_mandat_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE SEQUENCE unixuser_unixuser_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE TABLE unixuser (
|
||||
unixuser_id integer DEFAULT nextval('unixuser_unixuser_id_seq'::regclass) NOT NULL,
|
||||
name character varying(64) NOT NULL,
|
||||
comment character varying(128),
|
||||
shell character varying(64) NOT NULL,
|
||||
homedir character varying(128) NOT NULL,
|
||||
locked boolean NOT NULL,
|
||||
packet_id integer NOT NULL,
|
||||
quota_softlimit integer DEFAULT 0 NOT NULL,
|
||||
userid integer NOT NULL,
|
||||
quota_hardlimit integer DEFAULT 0,
|
||||
CONSTRAINT unixuser_userid CHECK ((userid >= 10000))
|
||||
);
|
||||
|
||||
ALTER TABLE ONLY price ALTER COLUMN id SET DEFAULT nextval('price_id_seq'::regclass);
|
||||
|
||||
ALTER TABLE ONLY price_list ALTER COLUMN id SET DEFAULT nextval('price_list_id_seq'::regclass);
|
||||
|
||||
ALTER TABLE ONLY business_partner
|
||||
ADD CONSTRAINT business_partner_bp_id_key UNIQUE (bp_id);
|
||||
|
||||
ALTER TABLE ONLY database
|
||||
ADD CONSTRAINT database_uniq UNIQUE (engine, name);
|
||||
|
||||
ALTER TABLE ONLY database_user
|
||||
ADD CONSTRAINT database_user_uniq UNIQUE (engine, name);
|
||||
|
||||
ALTER TABLE ONLY emailaddr
|
||||
ADD CONSTRAINT emailaddr_uniq UNIQUE (localpart, subdomain, domain_id);
|
||||
|
||||
ALTER TABLE ONLY emailalias
|
||||
ADD CONSTRAINT emailalias_pkey PRIMARY KEY (emailalias_id);
|
||||
|
||||
ALTER TABLE ONLY emailalias
|
||||
ADD CONSTRAINT emailalias_uniq UNIQUE (name);
|
||||
|
||||
ALTER TABLE ONLY basecomponent
|
||||
ADD CONSTRAINT pk_basecomponent PRIMARY KEY (basecomponent_id);
|
||||
|
||||
ALTER TABLE ONLY basepacket
|
||||
ADD CONSTRAINT pk_basepacket PRIMARY KEY (basepacket_id);
|
||||
|
||||
ALTER TABLE ONLY business_partner
|
||||
ADD CONSTRAINT pk_business_partner PRIMARY KEY (bp_id);
|
||||
|
||||
ALTER TABLE ONLY component
|
||||
ADD CONSTRAINT pk_component PRIMARY KEY (component_id);
|
||||
|
||||
ALTER TABLE ONLY contact
|
||||
ADD CONSTRAINT pk_contact PRIMARY KEY (contact_id);
|
||||
|
||||
ALTER TABLE ONLY contactrole_ref
|
||||
ADD CONSTRAINT pk_contactrole_ref PRIMARY KEY (contact_id, role);
|
||||
|
||||
ALTER TABLE ONLY database
|
||||
ADD CONSTRAINT pk_database PRIMARY KEY (database_id);
|
||||
|
||||
ALTER TABLE ONLY database_user
|
||||
ADD CONSTRAINT pk_database_user PRIMARY KEY (dbuser_id);
|
||||
|
||||
ALTER TABLE ONLY domain__domain_option
|
||||
ADD CONSTRAINT pk_domain__domain_option PRIMARY KEY (domain_option_id, domain_id);
|
||||
|
||||
ALTER TABLE ONLY domain_option
|
||||
ADD CONSTRAINT pk_domain_option PRIMARY KEY (domain_option_id);
|
||||
|
||||
ALTER TABLE ONLY hive
|
||||
ADD CONSTRAINT pk_hive PRIMARY KEY (hive_id);
|
||||
|
||||
ALTER TABLE ONLY inet_addr
|
||||
ADD CONSTRAINT pk_inet_addr PRIMARY KEY (inet_addr_id);
|
||||
|
||||
ALTER TABLE ONLY packet
|
||||
ADD CONSTRAINT pk_packet PRIMARY KEY (packet_id);
|
||||
|
||||
ALTER TABLE ONLY packet_component
|
||||
ADD CONSTRAINT pk_packet_component PRIMARY KEY (packet_component_id);
|
||||
|
||||
ALTER TABLE ONLY role
|
||||
ADD CONSTRAINT pk_role PRIMARY KEY (role_name);
|
||||
|
||||
ALTER TABLE ONLY sepa_mandat
|
||||
ADD CONSTRAINT pk_sepa_mandat PRIMARY KEY (sepa_mandat_id);
|
||||
|
||||
ALTER TABLE ONLY unixuser
|
||||
ADD CONSTRAINT pk_unixuser PRIMARY KEY (unixuser_id);
|
||||
|
||||
ALTER TABLE ONLY price_list
|
||||
ADD CONSTRAINT price_list_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY price_list
|
||||
ADD CONSTRAINT price_list_uniq_name UNIQUE (name);
|
||||
|
||||
ALTER TABLE ONLY price
|
||||
ADD CONSTRAINT price_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY unixuser
|
||||
ADD CONSTRAINT unixuser_name_key UNIQUE (name);
|
||||
|
||||
CREATE UNIQUE INDEX basecomponent_in_1 ON basecomponent USING btree (basecomponent_code);
|
||||
|
||||
CREATE UNIQUE INDEX basepacket_in_1 ON basepacket USING btree (basepacket_code);
|
||||
|
||||
CREATE INDEX component_in_1 ON component USING btree (basecomponent_id);
|
||||
|
||||
CREATE INDEX contact_in_1 ON contact USING btree (bp_id);
|
||||
|
||||
CREATE UNIQUE INDEX customer_in_1 ON business_partner USING btree (member_code);
|
||||
|
||||
CREATE UNIQUE INDEX customer_in_2 ON business_partner USING btree (member_id);
|
||||
|
||||
CREATE UNIQUE INDEX database_unique_owner ON database_user USING btree (name, engine);
|
||||
|
||||
CREATE UNIQUE INDEX domain_option_name_idx ON domain_option USING btree (domain_option_name);
|
||||
|
||||
CREATE UNIQUE INDEX domain_unique_id ON domain USING btree (domain_id);
|
||||
|
||||
CREATE UNIQUE INDEX domain_unique_name ON domain USING btree (domain_name);
|
||||
|
||||
CREATE UNIQUE INDEX emailaddr_uniq2 ON emailaddr USING btree (localpart, domain_id) WHERE (subdomain IS NULL);
|
||||
|
||||
CREATE UNIQUE INDEX hive_in_1 ON hive USING btree (hive_name);
|
||||
|
||||
CREATE UNIQUE INDEX inet_addr_in_1 ON inet_addr USING btree (inet_addr);
|
||||
|
||||
CREATE INDEX packet_component_in_1 ON packet_component USING btree (packet_id);
|
||||
|
||||
CREATE INDEX packet_component_in_2 ON packet_component USING btree (basecomponent_id);
|
||||
|
||||
CREATE UNIQUE INDEX packet_in_1 ON packet USING btree (packet_name);
|
||||
|
||||
CREATE INDEX packet_in_2 ON packet USING btree (bp_id);
|
||||
|
||||
ALTER TABLE ONLY packet
|
||||
ADD CONSTRAINT base_packet_ref FOREIGN KEY (basepacket_id) REFERENCES basepacket(basepacket_id);
|
||||
|
||||
ALTER TABLE ONLY database
|
||||
ADD CONSTRAINT database_owner FOREIGN KEY (owner, engine) REFERENCES database_user(name, engine);
|
||||
|
||||
ALTER TABLE ONLY database
|
||||
ADD CONSTRAINT database_packet_id_fkey FOREIGN KEY (packet_id) REFERENCES packet(packet_id) DEFERRABLE;
|
||||
|
||||
ALTER TABLE ONLY database_user
|
||||
ADD CONSTRAINT dbuser_packet_id_fkey FOREIGN KEY (packet_id) REFERENCES packet(packet_id) DEFERRABLE;
|
||||
|
||||
ALTER TABLE ONLY domain__domain_option
|
||||
ADD CONSTRAINT domain_id_fkey FOREIGN KEY (domain_id) REFERENCES domain(domain_id) DEFERRABLE;
|
||||
|
||||
ALTER TABLE ONLY domain__domain_option
|
||||
ADD CONSTRAINT domain_option_id_fkey FOREIGN KEY (domain_option_id) REFERENCES domain_option(domain_option_id) DEFERRABLE;
|
||||
|
||||
ALTER TABLE ONLY domain
|
||||
ADD CONSTRAINT domain_owner_chk FOREIGN KEY (domain_owner) REFERENCES unixuser(unixuser_id) MATCH FULL;
|
||||
|
||||
ALTER TABLE ONLY emailaddr
|
||||
ADD CONSTRAINT email_domain FOREIGN KEY (domain_id) REFERENCES domain(domain_id);
|
||||
|
||||
ALTER TABLE ONLY emailalias
|
||||
ADD CONSTRAINT emailalias_pac_id_fkey FOREIGN KEY (pac_id) REFERENCES packet(packet_id) DEFERRABLE;
|
||||
|
||||
ALTER TABLE ONLY sepa_mandat
|
||||
ADD CONSTRAINT fk_bank_acc_reference_business FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY component
|
||||
ADD CONSTRAINT fk_bcomp_bpack FOREIGN KEY (basepacket_id) REFERENCES basepacket(basepacket_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY packet_component
|
||||
ADD CONSTRAINT fk_comp_pack FOREIGN KEY (packet_id) REFERENCES packet(packet_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY contact
|
||||
ADD CONSTRAINT fk_contact_reference_business FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY contactrole_ref
|
||||
ADD CONSTRAINT fk_contactrole_ref_contact FOREIGN KEY (contact_id) REFERENCES contact(contact_id);
|
||||
|
||||
ALTER TABLE ONLY contactrole_ref
|
||||
ADD CONSTRAINT fk_contactrole_ref_role FOREIGN KEY (role) REFERENCES role(role_name);
|
||||
|
||||
ALTER TABLE ONLY hive
|
||||
ADD CONSTRAINT fk_hive_inet FOREIGN KEY (inet_addr_id) REFERENCES inet_addr(inet_addr_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY packet
|
||||
ADD CONSTRAINT fk_pac_cur_inet FOREIGN KEY (cur_inet_addr_id) REFERENCES inet_addr(inet_addr_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY packet
|
||||
ADD CONSTRAINT fk_pac_old_inet FOREIGN KEY (old_inet_addr_id) REFERENCES inet_addr(inet_addr_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY packet
|
||||
ADD CONSTRAINT fk_packet_bp FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY packet
|
||||
ADD CONSTRAINT fk_packet_hive FOREIGN KEY (hive_id) REFERENCES hive(hive_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY pricelist_ref
|
||||
ADD CONSTRAINT fk_pricelist_ref_bp FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY pricelist_ref
|
||||
ADD CONSTRAINT fk_pricelist_ref_pricelist FOREIGN KEY (price_list) REFERENCES price_list(name) ON UPDATE RESTRICT ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY component
|
||||
ADD CONSTRAINT fk_reference_13 FOREIGN KEY (basecomponent_id) REFERENCES basecomponent(basecomponent_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY price
|
||||
ADD CONSTRAINT price_price_list_fkey FOREIGN KEY (price_list) REFERENCES price_list(id);
|
||||
|
||||
ALTER TABLE ONLY queue_task
|
||||
ADD CONSTRAINT queue_task_user_id_fkey FOREIGN KEY (user_id) REFERENCES unixuser(unixuser_id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE ONLY queue
|
||||
ADD CONSTRAINT queue_user_id_fkey FOREIGN KEY (user_id) REFERENCES unixuser(unixuser_id) DEFERRABLE;
|
0
persistence/database/migrate.sql
Normal file
0
persistence/database/migrate.sql
Normal file
48
persistence/pom.xml
Normal file
48
persistence/pom.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>persistence</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin Persistence</name>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
234
persistence/src/main/java/de/hsadmin/bo/customer/Contact.java
Normal file
234
persistence/src/main/java/de/hsadmin/bo/customer/Contact.java
Normal file
@ -0,0 +1,234 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity(name = "Contact")
|
||||
@Table(name = "contact")
|
||||
public class Contact implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "contact_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
@JoinColumn(name = "bp_id", columnDefinition = "integer")
|
||||
@ManyToOne(fetch = EAGER)
|
||||
private Customer customer;
|
||||
|
||||
@Column(name = "salut", columnDefinition = "character varying(30)")
|
||||
private String salut;
|
||||
|
||||
@Column(name = "first_name", columnDefinition = "character varying(40)")
|
||||
private String firstName;
|
||||
|
||||
@Column(name = "last_name", columnDefinition = "character varying(40)")
|
||||
private String lastName;
|
||||
|
||||
@Column(name = "title", columnDefinition = "character varying(20)")
|
||||
private String title;
|
||||
|
||||
@Column(name = "firma", columnDefinition = "character varying(120)")
|
||||
private String firma;
|
||||
|
||||
@Column(name = "co", columnDefinition = "character varying(50)")
|
||||
private String co;
|
||||
|
||||
@Column(name = "street", columnDefinition = "character varying(50)")
|
||||
private String street;
|
||||
|
||||
@Column(name = "zipcode", columnDefinition = "character varying(10)")
|
||||
private String zipCode;
|
||||
|
||||
@Column(name = "city", columnDefinition = "character varying(40)")
|
||||
private String city;
|
||||
|
||||
@Column(name = "country", columnDefinition = "character varying(30)")
|
||||
private String country;
|
||||
|
||||
@Column(name = "phone_private", columnDefinition = "character varying(30)")
|
||||
private String phonePrivate;
|
||||
|
||||
@Column(name = "phone_office", columnDefinition = "character varying(30)")
|
||||
private String phoneOffice;
|
||||
|
||||
@Column(name = "phone_mobile", columnDefinition = "character varying(30)")
|
||||
private String phoneMobile;
|
||||
|
||||
@Column(name = "fax", columnDefinition = "character varying(30)")
|
||||
private String fax;
|
||||
|
||||
@Column(name = "email", columnDefinition = "character varying(50)")
|
||||
private String email;
|
||||
|
||||
@ElementCollection(fetch = EAGER)
|
||||
@CollectionTable(
|
||||
name="contactrole_ref",
|
||||
joinColumns=@JoinColumn(name="contact_id")
|
||||
)
|
||||
@Column(name="role")
|
||||
private List<String> roles;
|
||||
|
||||
public Contact() {
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(final Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getSalut() {
|
||||
return salut;
|
||||
}
|
||||
|
||||
public void setSalut(final String salut) {
|
||||
this.salut = salut;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(final String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(final String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getFirma() {
|
||||
return firma;
|
||||
}
|
||||
|
||||
public void setFirma(final String firma) {
|
||||
this.firma = firma;
|
||||
}
|
||||
|
||||
public String getCo() {
|
||||
return co;
|
||||
}
|
||||
|
||||
public void setCo(final String co) {
|
||||
this.co = co;
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(final String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getZipCode() {
|
||||
return zipCode;
|
||||
}
|
||||
|
||||
public void setZipCode(final String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(final String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(final String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getPhonePrivate() {
|
||||
return phonePrivate;
|
||||
}
|
||||
|
||||
public void setPhonePrivate(final String phonePrivate) {
|
||||
this.phonePrivate = phonePrivate;
|
||||
}
|
||||
|
||||
public String getPhoneOffice() {
|
||||
return phoneOffice;
|
||||
}
|
||||
|
||||
public void setPhoneOffice(final String phoneOffice) {
|
||||
this.phoneOffice = phoneOffice;
|
||||
}
|
||||
|
||||
public String getPhoneMobile() {
|
||||
return phoneMobile;
|
||||
}
|
||||
|
||||
public void setPhoneMobile(final String phoneMobile) {
|
||||
this.phoneMobile = phoneMobile;
|
||||
}
|
||||
|
||||
public String getFax() {
|
||||
return fax;
|
||||
}
|
||||
|
||||
public void setFax(final String fax) {
|
||||
this.fax = fax;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(final String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
}
|
279
persistence/src/main/java/de/hsadmin/bo/customer/Customer.java
Normal file
279
persistence/src/main/java/de/hsadmin/bo/customer/Customer.java
Normal file
@ -0,0 +1,279 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
import static javax.persistence.CascadeType.ALL;
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
import static javax.persistence.FetchType.LAZY;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
|
||||
import de.hsadmin.bo.pac.Pac;
|
||||
|
||||
|
||||
@Entity(name = "Customer")
|
||||
@Table(name = "business_partner")
|
||||
public class Customer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "bp_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
@Column(name = "member_id", columnDefinition = "integer")
|
||||
private int memberNo;
|
||||
|
||||
@Column(name = "member_code", columnDefinition = "character varying(20)")
|
||||
private String name;
|
||||
|
||||
@Column(name = "member_since", columnDefinition = "date", nullable = true)
|
||||
private Date memberSince;
|
||||
|
||||
@Column(name = "member_until", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date memberUntil;
|
||||
|
||||
@Column(name = "member_role", columnDefinition = "character varying(100)", nullable = true)
|
||||
private String memberRole;
|
||||
|
||||
@Column(name = "author_contract", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date authorContract;
|
||||
|
||||
@Column(name = "nondisc_contract", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date nonDiscContract;
|
||||
|
||||
@Column(name = "shares_updated", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date sharesUpdated;
|
||||
|
||||
@Column(name = "shares_signed", columnDefinition = "integer")
|
||||
private int sharesSigned;
|
||||
|
||||
@Column(name = "free", nullable = false)
|
||||
private boolean free = false;
|
||||
|
||||
@Column(name = "exempt_vat", nullable = false)
|
||||
private boolean exemptVAT = false;
|
||||
|
||||
@Column(name = "indicator_vat", nullable = false)
|
||||
@Basic
|
||||
@Enumerated(EnumType.STRING)
|
||||
private IndicatorVAT indicatorVAT = IndicatorVAT.GROSS;
|
||||
|
||||
@Column(name = "uid_vat", columnDefinition = "character varying(20)", nullable = true)
|
||||
private String uidVAT;
|
||||
|
||||
@OneToMany(fetch = EAGER, cascade = ALL, mappedBy = "customer")
|
||||
private Set<Contact> contacts;
|
||||
|
||||
@ElementCollection(fetch = EAGER)
|
||||
@CollectionTable(
|
||||
name="pricelist_ref",
|
||||
joinColumns=@JoinColumn(name="bp_id")
|
||||
)
|
||||
@Column(name="price_list")
|
||||
private List<String> priceLists;
|
||||
|
||||
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer")
|
||||
@OrderBy("mandatSigned")
|
||||
private Set<SEPADirectDebit> sepaDirectDebits;
|
||||
|
||||
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer")
|
||||
@OrderBy("name")
|
||||
private Set<Pac> pacs;
|
||||
|
||||
public Customer() {
|
||||
contacts = new HashSet<>();
|
||||
pacs = new HashSet<>();
|
||||
priceLists = new ArrayList<>();
|
||||
sepaDirectDebits = new HashSet<>();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getMemberNo() {
|
||||
return memberNo;
|
||||
}
|
||||
|
||||
public void setMemberNo(final int memberNo) {
|
||||
this.memberNo = memberNo;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String memberCode) {
|
||||
this.name = memberCode;
|
||||
}
|
||||
|
||||
public Date getMemberSince() {
|
||||
return memberSince;
|
||||
}
|
||||
|
||||
public void setMemberSince(final Date memberSince) {
|
||||
this.memberSince = memberSince;
|
||||
}
|
||||
|
||||
public Date getMemberUntil() {
|
||||
return memberUntil;
|
||||
}
|
||||
|
||||
public void setMemberUntil(final Date memberUntil) {
|
||||
this.memberUntil = memberUntil;
|
||||
}
|
||||
|
||||
public String getMemberRole() {
|
||||
return memberRole;
|
||||
}
|
||||
|
||||
public void setMemberRole(final String memberRole) {
|
||||
this.memberRole = memberRole;
|
||||
}
|
||||
|
||||
public Date getAuthorContract() {
|
||||
return authorContract;
|
||||
}
|
||||
|
||||
public void setAuthorContract(final Date authorContract) {
|
||||
this.authorContract = authorContract;
|
||||
}
|
||||
|
||||
public Date getNonDiscContract() {
|
||||
return nonDiscContract;
|
||||
}
|
||||
|
||||
public void setNonDiscContract(final Date nonDiscContract) {
|
||||
this.nonDiscContract = nonDiscContract;
|
||||
}
|
||||
|
||||
public Date getSharesUpdated() {
|
||||
return sharesUpdated;
|
||||
}
|
||||
|
||||
public void setSharesUpdated(final Date sharesUpdated) {
|
||||
this.sharesUpdated = sharesUpdated;
|
||||
}
|
||||
|
||||
public int getSharesSigned() {
|
||||
return sharesSigned;
|
||||
}
|
||||
|
||||
public void setSharesSigned(final int sharesSigned) {
|
||||
this.sharesSigned = sharesSigned;
|
||||
}
|
||||
|
||||
public String getUidVAT() {
|
||||
return uidVAT;
|
||||
}
|
||||
|
||||
public void setUidVAT(final String uidVAT) {
|
||||
this.uidVAT = uidVAT;
|
||||
}
|
||||
|
||||
public Set<Contact> getContacts() {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public void setContacts(final Set<Contact> contacts) {
|
||||
if (contacts == null) {
|
||||
this.contacts.clear();
|
||||
} else {
|
||||
this.contacts = contacts;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Pac> getPacs() {
|
||||
return pacs;
|
||||
}
|
||||
|
||||
public void setPacs(final Set<Pac> pacs) {
|
||||
if (pacs == null) {
|
||||
this.pacs.clear();
|
||||
} else {
|
||||
this.pacs = pacs;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFree() {
|
||||
return free;
|
||||
}
|
||||
|
||||
public boolean getFree() {
|
||||
return free;
|
||||
}
|
||||
|
||||
public void setFree(final boolean free) {
|
||||
this.free = free;
|
||||
}
|
||||
|
||||
public IndicatorVAT getIndicatorVAT() {
|
||||
return indicatorVAT;
|
||||
}
|
||||
|
||||
public void setIndicatorVAT(final IndicatorVAT indicatorVAT) {
|
||||
this.indicatorVAT = indicatorVAT;
|
||||
}
|
||||
|
||||
public boolean isExemptVAT() {
|
||||
return exemptVAT;
|
||||
}
|
||||
|
||||
public boolean getExemptVAT() {
|
||||
return exemptVAT;
|
||||
}
|
||||
|
||||
public void setExemptVAT(final boolean exemptVAT) {
|
||||
this.exemptVAT = exemptVAT;
|
||||
}
|
||||
|
||||
public List<String> getPriceLists() {
|
||||
return priceLists;
|
||||
}
|
||||
|
||||
public void setPriceLists(final List<String> priceLists) {
|
||||
if (priceLists == null) {
|
||||
this.priceLists.clear();
|
||||
} else {
|
||||
this.priceLists = priceLists;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<SEPADirectDebit> getSepaDirectDebits() {
|
||||
return sepaDirectDebits;
|
||||
}
|
||||
|
||||
public void setSepaDirectDebits(final Set<SEPADirectDebit> sepaDirectDebits) {
|
||||
this.sepaDirectDebits = sepaDirectDebits;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
public enum IndicatorVAT {
|
||||
NET, GROSS
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
|
||||
@Entity(name = "SEPADirectDebit")
|
||||
@Table(name = "sepa_mandat")
|
||||
public class SEPADirectDebit implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "sepa_mandat_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
@JoinColumn(name = "bp_id", columnDefinition = "integer")
|
||||
@OneToOne(fetch = EAGER)
|
||||
private Customer customer;
|
||||
|
||||
@Column(name = "bank_customer", columnDefinition = "character varying(50)", nullable = false)
|
||||
private String bankCustomer;
|
||||
|
||||
@Column(name = "bank_name", columnDefinition = "character varying(50)")
|
||||
private String bankName;
|
||||
|
||||
@Column(name = "bank_iban", columnDefinition = "character varying(34)", nullable = false)
|
||||
private String bankIBAN;
|
||||
|
||||
@Column(name = "bank_bic", columnDefinition = "character varying(11)", nullable = false)
|
||||
private String bankBIC;
|
||||
|
||||
@Column(name = "mandat_ref", columnDefinition = "character varying(10)", nullable = false)
|
||||
private String mandatRef;
|
||||
|
||||
@Column(name = "mandat_signed", columnDefinition = "date", nullable = false)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date mandatSigned;
|
||||
|
||||
@Column(name = "mandat_since", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date mandatSince;
|
||||
|
||||
@Column(name = "mandat_until", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date mandatUntil;
|
||||
|
||||
@Column(name = "mandat_used", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date mandatUsed;
|
||||
|
||||
public SEPADirectDebit() {
|
||||
this.customer = null;
|
||||
}
|
||||
|
||||
public SEPADirectDebit(final Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(final Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getBankCustomer() {
|
||||
return bankCustomer;
|
||||
}
|
||||
|
||||
public void setBankCustomer(final String bankCustomer) {
|
||||
this.bankCustomer = bankCustomer;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return bankName;
|
||||
}
|
||||
|
||||
public void setBankName(final String bankName) {
|
||||
this.bankName = bankName;
|
||||
}
|
||||
|
||||
public String getBankIBAN() {
|
||||
return bankIBAN;
|
||||
}
|
||||
|
||||
public void setBankIBAN(final String bankIBAN) {
|
||||
this.bankIBAN = bankIBAN;
|
||||
}
|
||||
|
||||
public String getBankBIC() {
|
||||
return bankBIC;
|
||||
}
|
||||
|
||||
public void setBankBIC(final String bankBIC) {
|
||||
this.bankBIC = bankBIC;
|
||||
}
|
||||
|
||||
public String getMandatRef() {
|
||||
return mandatRef;
|
||||
}
|
||||
|
||||
public void setMandatRef(String mandatRef) {
|
||||
this.mandatRef = mandatRef;
|
||||
}
|
||||
|
||||
public Date getMandatSigned() {
|
||||
return mandatSigned;
|
||||
}
|
||||
|
||||
public void setMandatSigned(Date mandatSigned) {
|
||||
this.mandatSigned = mandatSigned;
|
||||
}
|
||||
|
||||
public Date getMandatSince() {
|
||||
return mandatSince;
|
||||
}
|
||||
|
||||
public void setMandatSince(Date mandatSince) {
|
||||
this.mandatSince = mandatSince;
|
||||
}
|
||||
|
||||
public Date getMandatUntil() {
|
||||
return mandatUntil;
|
||||
}
|
||||
|
||||
public void setMandatUntil(Date mandatUntil) {
|
||||
this.mandatUntil = mandatUntil;
|
||||
}
|
||||
|
||||
public Date getMandatUsed() {
|
||||
return mandatUsed;
|
||||
}
|
||||
|
||||
public void setMandatUsed(Date mandatUsed) {
|
||||
this.mandatUsed = mandatUsed;
|
||||
}
|
||||
|
||||
}
|
118
persistence/src/main/java/de/hsadmin/bo/database/Database.java
Normal file
118
persistence/src/main/java/de/hsadmin/bo/database/Database.java
Normal file
@ -0,0 +1,118 @@
|
||||
package de.hsadmin.bo.database;
|
||||
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
import static javax.persistence.GenerationType.SEQUENCE;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import de.hsadmin.bo.pac.Pac;
|
||||
|
||||
@Entity
|
||||
@Table(name = "database")
|
||||
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(name="engine", discriminatorType=DiscriminatorType.STRING)
|
||||
@SequenceGenerator(name = "DatabaseSeqGen", sequenceName = "database_database_id_seq")
|
||||
public abstract class Database implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = SEQUENCE, generator = "DatabaseSeqGen")
|
||||
@Column(name = "database_id", columnDefinition = "integer", updatable=false, insertable=false)
|
||||
private long id;
|
||||
|
||||
@Column(name = "engine", columnDefinition = "character varying(12)", updatable=false)
|
||||
private String instance;
|
||||
|
||||
@Column(name = "name", columnDefinition = "character varying(24)", updatable=false)
|
||||
private String name;
|
||||
|
||||
@Column(name = "owner", columnDefinition = "character varying(24)")
|
||||
private String owner;
|
||||
|
||||
@JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false)
|
||||
@ManyToOne(fetch = EAGER)
|
||||
private Pac pac;
|
||||
|
||||
@Column(name = "encoding", columnDefinition = "character varying(24)", updatable=false)
|
||||
private String encoding;
|
||||
|
||||
protected Database() {
|
||||
encoding = "UTF-8";
|
||||
}
|
||||
|
||||
protected Database(String instance, Pac pac, String name, String owner,
|
||||
String encoding) {
|
||||
this.instance = instance;
|
||||
this.pac = pac;
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public abstract String getSystemEncoding();
|
||||
|
||||
public abstract Class<? extends DatabaseUser> getSqlUserClass();
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
protected void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void setInstance(String instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Pac getPac() {
|
||||
return pac;
|
||||
}
|
||||
|
||||
public void setPac(Pac pac) {
|
||||
this.pac = pac;
|
||||
}
|
||||
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public void setEncoding(String encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user